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...

How to call the m1() method of Base class in below snippet ?


class Base
{
public void m1()
{
System.out.println("Base m1 ");
}

public void m2()
{
System.out.println("Base m1 ");
}
}

======================


class Derived extends Base
{
public void m1()
{
System.out.println("Derived m1");
}
public void m3()
{
System.out.println("Derived m3");
}

public static void main(String[] args)
{
Base ob=new Derived();
ob.m1();
//System.out.println("Hello
World!"+ob.m1());
}
}

Answer Posted / kishore

Nand asking in the about snippet is saying like: The base class is referenced to derived class object (i.e Polymorphism). As a polymorphism point of view only overidden methods of Derived class will be called. But how is it possible to access the m1() of Base class using the reference of Base Class ?

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How is hashset maintained in memory by java ?

1147


Hi Friends, i have searched in google but not clear. can you give bank example with synchronized keyword

2040


In hyderabad, which s/w training center is best for java, other than corejava what r the new tools to learn in java,which tool is best & have current requirement,pls give me information about java to learn ?

2153


What are the types of java collections? : java collections

1042


What are the differences between the java collection and the java list? : java collections

1106


HOW MUCH PERCENTAGE WE DEDUCT FOR OUR SUPPLIERS OR OTHER PROFESSIONALS

2041


What is iterator in the java collections framework? : java collections

967


What is an algorithm in java collection framework? : java collections

1049


What is the enumerator of the java collection framework? : java collections

1027


What is java collection? : java collections

1108


Which interface does java.util.hashtable implement?

1189


How do I find jre path in windows?

1019


What are the types of the main implementing classes in the map interfaces? : java collections

1150


What are the different types of classes implemented in the set interfaces? : java collections

1051


please mail me the interview question based on java/j2ee

1939