nerdexam
Python_Institute

PCPP-32-101 · Question #55

Analyze the following snippet. Which method should be distinguished as a static method?

The correct answer is A. The isElementCorrect() method should be static. The isElementCorrect() method does not use self or any instance attributes and only processes its input parameter, so it should be defined as a static method. The isSolved() method relies on the instance attribute self.progress and must remain an instance method.

Advanced OOP

Question

Analyze the following snippet. Which method should be distinguished as a static method?

Exhibit

PCPP-32-101 question #55 exhibit

Options

  • AThe isElementCorrect() method should be static.
  • BBoth methods should be static.
  • CThe isSolved() method should be static.
  • DNone of the methods should be static.

How the community answered

(31 responses)
  • A
    55% (17)
  • B
    13% (4)
  • C
    6% (2)
  • D
    26% (8)

Explanation

The isElementCorrect() method does not use self or any instance attributes and only processes its input parameter, so it should be defined as a static method. The isSolved() method relies on the instance attribute self.progress and must remain an instance method.

Topics

#static methods#@staticmethod#method analysis#OOP design

Community Discussion

No community discussion yet for this question.

Full PCPP-32-101 Practice