9. Explain 'Inheritance with a suitable example.
10. What is meant by Polymorphism? Explain with an example.
Answers
Answered by
2
Inheritance is the mechanism by which an object acquires the some/all properties of another object.
Example: Shape :: Triangle, Square they inherit properties (like side) from Shape (base class).
Polymorphism means to process objects differently based on their data type.
In other words it means, one method with multiple implementation, for a certain class of action. And which implementation to be used is decided at runtime depending upon the situation (i.e., data type of the object)
Example: Power button of a Phone. Same button is used to turn On the phone (when it’s off) and turn Off the phone (when it’s on).
Example: Shape :: Triangle, Square they inherit properties (like side) from Shape (base class).
Polymorphism means to process objects differently based on their data type.
In other words it means, one method with multiple implementation, for a certain class of action. And which implementation to be used is decided at runtime depending upon the situation (i.e., data type of the object)
Example: Power button of a Phone. Same button is used to turn On the phone (when it’s off) and turn Off the phone (when it’s on).
Answered by
0
Answer: inheritance is a mechanism iin which one class acquires the property of another class for ex:a child inherits the traits of his / her parents with inheritance
Explanation:plz follow me plz thank me also I have no thanks till now help mee
Similar questions