Which feature of OOP is indicated by the following code?

2023

Which feature of OOP is indicated by the following code?

  1. A.

    Encapsulation and inheritance

  2. B.

    Inheritance and polymorphism

  3. C.

    Polymorphism

  4. D.

    More than one of the above

  5. E.

    None of the above

Attempted by 296 students.

Show answer & explanation

Correct answer: A

The given code demonstrates two key features of Object-Oriented Programming (OOP): Encapsulation: The 'marks' variable in the 'student' class is declared as private, which restricts direct access and ensures data hiding. Inheritance: The 'topper' class inherits from the 'student' class using 'public student', allowing it to access public members of the base class. Polymorphism is not demonstrated as there are no virtual functions or function overriding.

Explore the full course: Up Lt Grade Assistant Teacher 2025