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
How do you replace a string in java?
Explain java coding standards for interfaces?
What is boolean law?
Where is the singleton class used?
Is hashmap thread safe?
What is difference between final and immutable?
Can you change array size in java?
what is recursion in java
What is a locale?
Is java map thread safe?
Difference difference paint() and paintcomponent()?
Which non-unicode letter characters may be used as the first character of an identifier?
What is meant by singleton class?
What is a pointer and does java support pointers?
How do you sort in ascending order in java?