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
How do you define a class in oop?
Is oop better than procedural?
Where You Can Use Interface in your Project
What is difference between pop and oop?
write a program to find 2 power of a 5digit number with out using big int and exponent ?
What does enum stand for?
Why do we use class in oops?
What is difference between abstraction and encapsulation?
write knight tour problem which is present in datastructure
Question: Write a program that prints a paycheck. Ask the program user for the name of the employee, the hourly rate, and the number of hours worked. If the number of hours exceeds 40, the employee is paid “time and a half”, that is, 150 percent of the hourly rate on the hours exceeding 40. Be sure to use stepwi se refine ment and break your solution into several functions. Use the int_name function to print the dollar amount of the check.
Prepare me a program for the animation of train
Write a program to sort the number with different sorts in one program ??
officer say me - i am offered to a smoking , then what can you say
What is a class in oop?
What is class and object in oops?