nerdexam
Python_Institute

PCAP-31-03 · Question #85

The first parameter of each method:

The correct answer is A. holds a reference to the currently processed object. The first argument of every class method, including init, is always a reference to the current instance of the class. By convention, this argument is always named self. In the init method, self refers to the newly created object; in other class methods, it refers to the…

Technology and architecture

Question

The first parameter of each method:

Options

  • Aholds a reference to the currently processed object
  • Bis always set to None
  • Cis set to a unique random value
  • Dis set by the first argument's value

How the community answered

(36 responses)
  • A
    78% (28)
  • B
    14% (5)
  • C
    6% (2)
  • D
    3% (1)

Explanation

The first argument of every class method, including init, is always a reference to the current instance of the class. By convention, this argument is always named self. In the init method, self refers to the newly created object; in other class methods, it refers to the instance whose method

Topics

#Python OOP#self parameter#method definition#object reference

Community Discussion

No community discussion yet for this question.

Full PCAP-31-03 Practice