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 polymorphism ? Explain with examples

Answer Posted / danneel

The previous example is overloading not polymorphism.

Polymorphism is multiple classes having the same method -
for example - a DOG and CAT class that are sub classes of
ANIMAL - ANIMAL has a virtual function - SPEAK. DOG
implements speak via System.out.println("WOOF") and CAT
implements it as System.out.println("MEOW") then

ANIMAL anim = null;
anim = New DOG();
anim.speak();
anim = New CAT();
anim.speak()

will each put out the appropriate string.

Is This Answer Correct ?    18 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why we use classes in oop?

1045


What is the difference between inheritance and polymorphism?

1114


What is an example of genetic polymorphism?

1187


What is the point of oop?

1192


Why is object oriented programming so hard?

1087


write string class as your own class in java without using any built-in function

2502


Why do we use class?

1090


What is polymorphism in oops with example?

1056


What is encapsulation in ict?

1062


class type to basic type conversion

2413


What is difference between abstraction and encapsulation?

1083


How can you overcome the diamond problem in inheritance?

1184


What is multilevel inheritance explain with example?

1149


How do you achieve runtime polymorphism?

1049


Can you inherit a private class?

1105