Bird
0
0

Which statement best describes the order of execution when creating an object in Python?

hard📝 Conceptual Q10 of 15
Python - Constructors and Object Initialization
Which statement best describes the order of execution when creating an object in Python?
AThe <code>__new__</code> method creates the object, then <code>__init__</code> initializes it
BThe <code>__init__</code> method creates and initializes the object
CThe object is created after <code>__init__</code> runs
DOnly <code>__new__</code> runs during object creation
Step-by-Step Solution
Solution:
  1. Step 1: Understand object creation flow

    __new__ is a special method that creates the object in memory.
  2. Step 2: Role of __init__

    __init__ is called after __new__ to initialize the object's attributes.
  3. Final Answer:

    The __new__ method creates the object, then __init__ initializes it -> Option A
  4. Quick Check:

    Creation = __new__, Initialization = __init__ = C [OK]
Quick Trick: __new__ creates, __init__ initializes objects [OK]
Common Mistakes:
  • Thinking __init__ creates the object
  • Ignoring __new__ method
  • Assuming object is created after __init__

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes