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 / manoj

// Do you want to say like this?

//import like this:

import Package1.classA
import Package2.classB

//use it in your class
class yourclass
{
classA.methodA(); // Package1 method call
classB.methodA(); // Package2 method call
}

Is This Answer Correct ?    27 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What do you know about the garbage collector in java?

570


If an application has multiple classes in it, is it okay to have a main method in more than one class?

534


What are the differences between throw and throws?

526


How finally used under exception handling?

510


How do you implement singleton class?

512






You can create a string object as string str = “abc”; why cant a button object be created as button bt = “abc”;? Explain

526


Why arraylist is not synchronized in java example?

465


What is meant by data hiding in java?

636


Is integer passed by reference in java?

560


I don’t want my class to be inherited by any other class. What should I do?

571


Enlist diffrent types of inheritance supported by java?

480


What is the different between get and post?

496


What are different types of constants?

515


Can you override static methods?

502


Explain the selection sort algorithm and state its time complexity?

603