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 is the constructor?
When a thread is executing a synchronized method , then is it possible for the same thread to access other synchronized methods of an object ?
hi am an engineering student and my next plan is for ms in either in us or australia i got my passport but i dont know anything bout visa can u give brief idea 1)How to get prepared for visa and 2)How to apply for top universities and 3)How to pay the fee and so on These all are basic questions plz give me a clear idea
What is the meaning of 3 dots in java?
Difference between static synchronization vs. Instance synchronization?
What is hash code collision?
Explain about static imports in java?
How do you use parseint in java?
Can java inner class be static?
Can we use this () and super () in a method?
Is .net better than java?
Difference between start() and run() method of thread class?
What is string english?
What is lambda expression in java?
Explain about narrowing conversion in java?