Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

Since all non static methods in JAVA supports polymorphism,
we can call the respective methods using its instances..
considering that methodA is non static method we can call it
using instance of the respective class.. so Create instances
of the respective classes and then call the methods ..


for eg:

ClassA ins1=new ClassA();
ClassB ins2=new ClassB();

ins1.methodA();
ins2.methodA();

Is This Answer Correct ?    5 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

explain the concept of virtual method invocation in polymorphism in detail?

2155


Java is pass by value or pass by reference? Explain

934


What does int argc char * argv [] mean?

932


What restrictions are placed on method overloading?

1118


What is java thread dump, how can we get java thread dump of a program?

933


What is final method?

1014


What is skeleton and stub?

985


Which method must be implemented by all threads?

1194


Which is better stringbuilder or stringbuffer?

868


Explain about version control?

983


Which variables are stored in stack?

854


Hi.... I applied for the post of scientific officer/Engineer-SB(Programmer).Please post the syllabus and sample papers.

1950


Define "Access specifiers" in java.

1121


Tell us something about an iterator.

898


What is collection class in java? List down its methods and interfaces.

897