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
What are the steps that are followed when two computers connect through tcp?
What the difference is between execute, execute Query, execute Update?
Explain how to force the garbage collection in java.
Is a class subclass of itself?
What is class forname used for?
What are local variables?
What is maximum size of arraylist in java?
What restrictions are placed on method overloading in java programming?
What is computer compiler?
What are "class access modifiers" in Java?
What is array in java?
How do you write a scanner class in java?
Does .length start 0 java?
What is the set interface in java programming?
Why are parameters used in functions?