Classes & Objects · Question 5 · Easy

Manager inherits from Employee and defines nothing of its own. What does calling role() on a Manager print?

class Employee:
    def role(self):
        return "staff"

class Manager(Employee):
    pass

print(Manager().role())
  1. staff
  2. Manager
  3. None
  4. AttributeError
Answer and explanation

Answer: A. staff

Explanation: A child class gets all the methods of its parent. Manager has no role method of its own, so Python finds and runs the one in Employee.

Previous: Which special method does Python call automatically, right after an object is… · Next: Square overrides the area method of its parent Shape. What is printed for a…

Practise classes & objects

Try a fresh set of classes & objects questions with an explanation after every answer, free and without signing up: Classes & Objects practice. Or sit a full placement mock test.

More classes & objects questions

More python practice

Exceptions & Files · Built-ins & Standard Library · Variables, Types & Operators · Python Strings · Lists & Tuples · Dictionaries & Sets · Conditions & Loops · Functions & Scope

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge