Bird
Raised Fist0

What happens if you create a Python class without an __init__ method and then instantiate it?

easy🧠 Conceptual Q1 of Q15
Python - Constructors and Object Initialization

What happens if you create a Python class without an __init__ method and then instantiate it?

AThe object is created but has no attributes unless added later.
BPython raises a syntax error.
CThe object cannot be created without an <code>__init__</code> method.
DThe object is created with default attributes from the parent class.
Step-by-Step Solution
Solution:
  1. Step 1: Understand default behavior without __init__

    If a class has no __init__, Python uses a default constructor that creates an empty object.
  2. Step 2: Check object attributes after creation

    The object exists but has no attributes unless they are added later manually.
  3. Final Answer:

    The object is created but has no attributes unless added later. -> Option A
  4. Quick Check:

    __init__ missing means empty object [OK]
Quick Trick: No __init__ means empty object created by default [OK]
Common Mistakes:
MISTAKES
  • Assuming syntax error occurs
  • Thinking object can't be created
  • Assuming default attributes exist

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes