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
I want to control database connections in my program and want that only one thread should be able to make database connection at a time. How can I implement this logic?
What are the different access modifiers available in java?
Can we call the run() method instead of start()?
Print Vertical traversal of a Binary Tree.
What is data type modifier?
what state does a thread enter when it terminates its processing? : Java thread
Is null in java?
Explain the difference between a Thread and a Process.
What are examples of modifiers?
Define an abstract class with reference to java.
How to implement a multithreaded applet?
Is it possible to define a method in java class but provide it’s implementation in the code of another language like c?
What is the difference between equals() and?
How do you convert bytes to character in java?
How do you check whether the list is empty or not in java?