Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam PCPP-32-101 All Questions

View all questions & answers for the PCPP-32-101 exam

Exam PCPP-32-101 topic 1 question 10 discussion

Actual exam question from Python Institute's PCPP-32-101
Question #: 10
Topic #: 1
[All PCPP-32-101 Questions]

Which sentence about the @property decorator is false?

  • A. The @property decorator should be defined after the method that is responsible for setting an encapsulated attribute.
  • B. The @property decorator designates a method which is responsible for returning an attribute value.
  • C. The @property decorator marks the method whose name will be used as the name of the instance attribute.
  • D. The @property decorator should be defined before the methods that are responsible for setting and deleting an encapsulated attribute.
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
rafles
1 year, 4 months ago
Selected Answer: A
The getter method should always come before the setter and deletter. In python, the getter method is decorated only with @property, and has the name of the attribute it's setting. The setter and deleter use the attribute as part of the decorator (@[attribute].setter and @[attribute].deleter), therefore the getter must exist before they are declared. Note the question is which one is false
upvoted 2 times
...
w_w_w_w_w_w
1 year, 4 months ago
Selected Answer: A
The @property decorator: * designates a method which will be called automatically when another object wants to read the encapsulated attribute value * the name of the designated method will be used as the name of the instance attribute corresponding to the encapsulated attribute * should be defined before the method responsible for setting the value of the encapsulated attribute, and before the method responsible for deleting the encapsulated attribute A states it should be used AFTER the setter, so that's the wrong answer.
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...