Bird
0
0

How do you correctly declare a subclass LectureHall that inherits from a base class Room in Python?

easy📝 Conceptual Q3 of 15
LLD - Design — Hotel Booking System
How do you correctly declare a subclass LectureHall that inherits from a base class Room in Python?
Aclass LectureHall extends Room:
Bclass LectureHall inherits Room:
Cclass LectureHall -> Room:
Dclass LectureHall(Room):
Step-by-Step Solution
Solution:
  1. Step 1: Recall Python Inheritance Syntax

    In Python, inheritance is declared by placing the base class name in parentheses after the subclass name.
  2. Step 2: Analyze Options

    Only class LectureHall(Room): uses the correct syntax: class LectureHall(Room):
  3. Final Answer:

    class LectureHall(Room): -> Option D
  4. Quick Check:

    Python uses parentheses for inheritance [OK]
Quick Trick: Use parentheses to inherit in Python classes [OK]
Common Mistakes:
  • Using 'inherits' or 'extends' keywords (not Python syntax)
  • Using arrows or other symbols incorrectly
  • Omitting parentheses

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes