Which OOP features are demonstrated by the following Python code?

class Student:
    def __init__(self, marks):
        self.__marks = marks

class Topper(Student):
    pass
                        

Options

  • A. Polymorphism only
  • B. Inheritance and encapsulation
  • C. Abstraction only
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

B. Inheritance and encapsulation

Detailed Explanation

The Topper class inherits from Student, demonstrating inheritance. The double underscore attribute demonstrates name mangling, commonly used for encapsulation.