Question
What is the purpose of Inheritance in Object-Oriented
Programming?                           ÂSolution
Inheritance is a key feature of Object-Oriented Programming (OOP) that allows a class (called the derived or child class) to inherit properties and methods from another class (called the base or parent class). This helps in reusing code and establishing hierarchical relationships between classes. The derived class can access and modify the behaviors of the base class, and it can also add its own additional methods and properties.
- Why It Is Important: Inheritance promotes code reuse , reduces redundancy, and enhances maintainability. It also enables the creation of a hierarchical relationship between classes, where a base class defines general behaviors, and derived classes specialize or extend those behaviors. This leads to a more organized and structured codebase.
- Real-World Example: Consider a class Vehicle with methods like start() and stop() . A subclass Car can inherit these methods from Vehicle and add its own methods, such as playMusic() , without having to re-implement the start() and stop() methods.
- Â To allow one object to create another object: This describes object creation or composition , not inheritance.
- To enable the hiding of internal details of an object: This refers to encapsulation , not inheritance.
- To allow the association between two independent objects: This refers to association or aggregation , not inheritance.
- To enable communication between objects of different types: This is an example of polymorphism or message passing , not inheritance.
MNP Inc. has Gross Profit of ₹75,000 on Sales of ₹3,50,000. Average Total Assets are ₹2,00,000 and Average Inventory is ₹50,000. Calculate Total...
As per the RBI report, what is India's share in the global real-time payments volume?Â
A company forfeited 200 shares of ₹10 each, on which ₹7 was called up and the shareholder had paid ₹4 per share. What amount will be credited to t...
Hyperinflation means _______
Present liability of uncertain amount, which can be measured reliably by using a substantial degree of estimation is termed as ?
Which inventory costing formula calculates value of closing inventory considering that inventory most recently purchased has not been sold?
An actively managed Mutual Fund Scheme will not invest in more than ……………….of its NAV in debt and money market securities rated AA of a sing...
In the financial statements, contingent liability is ________
On April 1, 2024, a listed company grants 5,000 stock options to its employees. The Fair Value per option on the Grant Date is ₹120. The options are s...
An actively managed Mutual Fund Scheme will not invest in more than ……………….of its NAV in debt and money market securities rated A and below ...