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 / munesh yadav

Frist make instances of the two classes and then call the
respective methods.

eg. Package1 has a classA with fun functionA(Arg1,Arg2)
and Package2 has a ClassB with fun functionA(Arg1,Arg2)
import package1.classA;
import package2.classB;
public Class main{
public void main(String a[]){
classA obj1=new classA();
obj1.functionA(arg1,arg2);
classB obj2=new classB();
obj2.functionA(arg1,arg2);
}
}

Is This Answer Correct ?    19 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the steps that are followed when two computers connect through tcp?

515


What the difference is between execute, execute Query, execute Update?

372


Explain how to force the garbage collection in java.

529


Is a class subclass of itself?

600


What is class forname used for?

538






What are local variables?

589


What is maximum size of arraylist in java?

490


What restrictions are placed on method overloading in java programming?

568


What is computer compiler?

532


What are "class access modifiers" in Java?

605


What is array in java?

533


How do you write a scanner class in java?

561


Does .length start 0 java?

561


What is the set interface in java programming?

623


Why are parameters used in functions?

527