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

//import like this:

import Package1.class
import Package2.class

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

Is This Answer Correct ?    6 Yes 19 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which number is denoted by leading 0x or 0x in java?

578


What is a stack class in java ?

618


What does opcode mean?

549


Is ++ operator thread-safe in java?

644


How can you avoid serialization in child class if the base class is implementing the serializable interface?

646






Which category the java thread do fall in?

579


What is the abstract class?

603


Which software is used for java programming?

565


How to reverse a string in java?

534


Is it possible for a yielded thread to get chance for its execution again?

522


When should the method invokelater() be used?

592


Difference between character constant and string constant in java ?

570


How do you create a first line indent?

516


Why local variables are stored in stack?

511


What are the different types of multitasking?

668