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
Difference between vector and arraylist.
What is a percentage sign called?
What are the library functions in java?
What type of value does sizeof return?
What are static blocks in java ?
What is method reference?
How to perform binary search in java?
What is internal iteration in java se 8?
What is basic syntax?
What are computer functions?
What do you understand by casting in java language?
What is methods and methodology?
what is mutual exclusion? How can you take care of mutual exclusion using java threads? : Java thread
What are the differences between wait() and sleep()?
How do you calculate roots in java?