Bird
0
0

Which of the following is the correct way to declare a subclass Rook that inherits from Piece in a typical object-oriented language?

easy📝 Conceptual Q3 of 15
LLD - Design — Chess Game
Which of the following is the correct way to declare a subclass Rook that inherits from Piece in a typical object-oriented language?
Aclass Rook extends Piece { }
Bclass Rook inherits Piece { }
Cclass Rook implements Piece { }
Dclass Rook uses Piece { }
Step-by-Step Solution
Solution:
  1. Step 1: Recall inheritance syntax

    In many OOP languages like JavaScript and Java, 'extends' keyword is used for subclassing.
  2. Step 2: Check other options

    'inherits' and 'uses' are incorrect keywords; 'implements' is for interfaces, not classes.
  3. Final Answer:

    class Rook extends Piece { } -> Option A
  4. Quick Check:

    Subclass syntax = extends [OK]
Quick Trick: Use 'extends' to inherit from a class [OK]
Common Mistakes:
  • Using 'inherits' or 'uses' keywords
  • Confusing 'implements' with inheritance
  • Omitting inheritance keyword

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes