Classes & Objects · Question 2 · Easy

Inside a method defined in a class, what does the first parameter, conventionally named self, refer to?

  1. The particular object on which the method was called
  2. The class in which the method is defined
  3. The parent class of the current class
  4. The module that contains the class
Answer and explanation

Answer: A. The particular object on which the method was called

Explanation: When you write obj.method(), Python passes obj itself as the first argument. That is how the method reaches the attributes of that specific object.

Previous: A Student object is created and one of its attributes is updated. What does… · Next: The deposit method of an Account object is called twice. What does the second…

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