Which of the following is mandatory while creating a class

  1. Pattern Inheritance

  2. Direct Inheritance

  3. Both

  4. None of the above


Correct Option: B

AI Explanation

To answer this question, we need to understand the concept of inheritance in object-oriented programming.

Inheritance is a feature in object-oriented programming that allows a class to inherit properties and methods from another class. It establishes a parent-child relationship between classes, where the child class (also known as the derived class) inherits the characteristics of the parent class (also known as the base class).

When creating a class, inheritance is not mandatory. However, if we are referring specifically to the concept of inheritance in the context of class creation, direct inheritance is the mandatory requirement.

Option A) Pattern Inheritance - This option is incorrect because pattern inheritance is not a mandatory requirement while creating a class. Option B) Direct Inheritance - This option is correct because direct inheritance is the mandatory requirement while creating a class. Option C) Both - This option is incorrect because pattern inheritance is not a mandatory requirement while creating a class. Option D) None of the above - This option is incorrect because direct inheritance is a mandatory requirement while creating a class.

The correct answer is B) Direct Inheritance. This option is correct because direct inheritance is the mandatory requirement while creating a class.

Find more quizzes: