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 / shiv

//import like this:

import Package1.class
import Package2.class

//use it in your class
class yourclass
{
class.methodA(); // Package1 method call
class.methodA(); // Package2 method call
}

Is This Answer Correct ?    6 Yes 19 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the advantage of preparedstatement over statement?

829


What defines function?

748


Can we serialize singleton class?

778


Is there a way to increase the size of an array after its declaration?

816


What are implicit objects in java?

754


Can an interface be defined inside a class?

769


How do you achieve polymorphism in java?

726


What is the generic function?

741


What is the difference between yielding and sleeping in java programming?

817


Does collectionutils isempty check for null?

1123


What is the independent variable in an experiment?

749


List the different types of classloaders in java.

733


What is the difference between private & public & friendly classes?

796


What is the benefit of inner classes in java?

858


What is a memory leak in java?

791