📢 Too many exams? Don’t know which one suits you best? Book Your Free Expert 👉 call Now!

  • google app store apple app store
  • ✖

      Question

      What is 'inheritance' in Object-Oriented

      Programming?
      A The process of creating multiple objects from a single class with every object having its own attributes Correct Answer Incorrect Answer
      B The mechanism by which one class acquires the properties and behaviours of another class Correct Answer Incorrect Answer
      C The process of hiding sensitive data from unauthorized access Correct Answer Incorrect Answer
      D The mechanism of converting a subclass object to its superclass type Correct Answer Incorrect Answer
      E The mechanism of running multiple threads simultaneously within the same class Correct Answer Incorrect Answer

      Solution

      Inheritance allows a child class (subclass/derived class) to inherit attributes and methods from a parent class (superclass/base class), enabling code reuse and establishing an IS-A relationship. Example: SavingsAccount and CurrentAccount both inherit from a BankAccount parent class, sharing common properties (accountNumber, balance) while having their own specific features (interestRate for Savings, overdraftLimit for Current). Java supports single inheritance; Python supports multiple inheritance.

      Practice Next

      Relevant for Exams:

      ask-question