Package1 and Package2 both have a method name lets say
"methodA" with different implementation. When I import both
the packages in a java class how can I use both the methods?
Answer Posted / mohan
Since all non static methods in JAVA supports polymorphism,
we can call the respective methods using its instances..
considering that methodA is non static method we can call it
using instance of the respective class.. so Create instances
of the respective classes and then call the methods ..
for eg:
ClassA ins1=new ClassA();
ClassB ins2=new ClassB();
ins1.methodA();
ins2.methodA();
| Is This Answer Correct ? | 5 Yes | 1 No |
Post New Answer View All Answers
what is the difference between Object Based Language and Object Oriented Language?
What are the steps in the jdbc connection?
Is break statement can be used as labels in java?
What are class members by default?
How an object is serialized in java?
What is the difference between delete and delete[]
What is a predicate method?
What are the classes of java?
Define locale.
What does singleton class mean?
What is a 16 bit word?
What does int [] mean in java?
Write a program to print the pattern given below
What is the difference between stringbuffer and stringbuilder class?
Can we use this () and super () in a method?