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

Difference between arraylist and hashset in java?

639


What are scriptlets?

669


How does enum work in java?

640


Explain thread life cycle in java?

673


What is Gang of four design patterns

685






Explain Basics of OOP Language in java

682


What is number data type?

626


What is oop in java?

611


Can we override the static method?

661


Can we use switch statement with strings?

707


Difference between stack and queue?

666


How do you compare two strings lexicographically?

633


why using interface interface ?

1618


Do you know why doesn't the java library use a randomized version of quicksort?

622


Which class is the superclass of all classes?

701