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 Recursion Function?
Can a static block throw exception?
What is the difference between method and means?
Explain restrictions on using enum?
Differences between traditional programming language and object oriented programming language?
How many types of keywords are there?
What are exception handling keywords in java?
What is arraylist e in java?
Is node a data type in java?
What is array size in java?
Can an interface extend a class?
How do you compare objects in java?
What is function and its uses?
What is the use of :: in java?
What is use of inner class in java?