Python_Institute
PCPP-32-101 · Question #67
You are developing a class where instances need to maintain a unique ID. Which approach would ensure this without duplicating IDs?
The correct answer is C. Use a class attribute to track the last assigned ID. You've hit your limit · resets 5am (America/New_York)
Advanced OOP
Question
You are developing a class where instances need to maintain a unique ID. Which approach would ensure this without duplicating IDs?
Options
- AGenerate IDs using hash() on the object.
- BDefine init and assign IDs randomly.
- CUse a class attribute to track the last assigned ID.
- DUse a dictionary with IDs as keys.
How the community answered
(41 responses)- A5% (2)
- B2% (1)
- C83% (34)
- D10% (4)
Explanation
You've hit your limit · resets 5am (America/New_York)
Topics
#class attributes#instance IDs#encapsulation#object design
Community Discussion
No community discussion yet for this question.