Correct option is A
In
Object-Oriented Programming,
inheritance is the mechanism that allows one class (child/derived class) to be defined based on another class (parent/base class). It facilitates code reuse and establishes a hierarchical relationship between classes.
Here, the Dog class inherits the Animal class's properties and methods.
Important Key Points:
1. Inheritance allows a child class to use the properties and methods of its parent class.
2. It supports code reusability and reduces redundancy.
3. Syntax in C++: class DerivedClass : accessSpecifier BaseClass { };.
Knowledge Booster:
· Class: A blueprint for creating objects but does not inherently define one type in terms of another.
· Object: An instance of a class but unrelated to defining one type in terms of another.
· Polymorphism: Allows methods to behave differently based on the object it acts upon (e.g., method overriding or overloading).
· Encapsulation: Bundles data and methods together while restricting access to certain components.
Here, the Dog class inherits the Animal class's properties and methods.
Important Key Points:
1. Inheritance allows a child class to use the properties and methods of its parent class.
2. It supports code reusability and reduces redundancy.
3. Syntax in C++: class DerivedClass : accessSpecifier BaseClass { };.
Knowledge Booster:
· Class: A blueprint for creating objects but does not inherently define one type in terms of another.
· Object: An instance of a class but unrelated to defining one type in terms of another.
· Polymorphism: Allows methods to behave differently based on the object it acts upon (e.g., method overriding or overloading).
· Encapsulation: Bundles data and methods together while restricting access to certain components.