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
Does string is thread-safe in java?
Are arrays immutable in java?
What are predefined functions?
What is an infinite loop?
What is a function argument in java?
How define set in java?
How will you load a specific locale?
Give a brief description of java socket programming?
Can we override the static method?
What do the thread?class methods run() and start() do?
How does singleton class work?
What is finally and finalize in java?
Why to use nested classes in java? (Or) what is the purpose of nested class in java?
How can a gui component handle its own events?
What is super?