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

what is dynamic method dispatch ?

Answer Posted / salman

In dynamic method dispatch,super class refers to subclass object and implements method overriding.
Example:

class Flower {
void which() {
System.out.println("A Beautiful flower.");
}
}
class Rose extends Flower {
void which() {
System.out.println("Rose");
}
}
class Lotus extends Flower {
void which() {
System.out.println("Lotus.");
}
}
class Test {

public static void main(String[] args) {
Flower ref1 = new Flower();
Flower ref2 = new Rose();
Flower ref3 = new Lotus();
ref1.which();
ref2.which();
ref3.which();
}
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a instance variable?

1129


What are the types of exceptions?

1104


What are keyboard events?

1207


Explain about join() method?

1026


What differences exist between iterator and listiterator?

1086


What is java string pool?

1058


Is it possible to compare various strings with the help of == operator?

1048


give an example for encapsulation?

1093


Which one of the following suits the description of a string better: derived or primitive?

1010


How do generics work in java?

1102


Can we cast any other type to boolean type with type casting?

1002


Explain java code for recursive solution's base case?

1089


how is final different from finally and finalize in java?

1105


Explain treeset?

1167


How to call one constructor from the other constructor ?

1118