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

What is the java virtual machine?

869


Write code of any action class?

766


Can we initialize the final blank variable?

839


What are the different types of collections in java?

758


What is encapsulation in java?

881


Can we force the garbage collection to run?

748


How big is a 32 bit integer?

790


Where local and global variables are stored?

826


What is an class?

786


What is generic type?

824


How many arguments can be passed to main ()?

771


Are static members inherited to sub classes?

914


How many bits are used to represent unicode, ascii, utf-16, and utf-8 characters in java programming?

817


How to Sort Strings which are given in List and display in ascending order without using java api.

4118


What is finally block?

779