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 is a generic type?

566


I am a fresher and know core java, c languge, html, css etc if I am illegible for any job then send it on my email tatranakshay276@gmail.com

1081


What are the two types of java programming?

541


Is there a way to increase the size of an array after its declaration?

606


Explain when classnotfoundexception will be raised ?

569






What is difference between path and classpath in java?

487


What is difference between array and arraylist in java?

466


What are some alternatives to inheritance?

563


Difference between Preemptive scheduling vs. Time slicing?

577


What is a pointer and does java support pointers?

562


Difference between method overloading and method overriding in java ?

578


What methods are used in Servlet?Applet communication?

1669


What is variable explain?

530


What is get () in java?

574


What are the major drawbacks of external iteration?

578