Bird
0
0

What will be the output of this code?

medium📝 Analysis Q5 of 15
LLD - Design — Chess Game
What will be the output of this code?
class Piece:
    def move(self):
        return "Any move"

class Bishop(Piece):
    pass

b = Bishop()
print(b.move())
ABishop move
BAny move
CNone
DError: move() not implemented
Step-by-Step Solution
Solution:
  1. Step 1: Check if subclass overrides move()

    Bishop class does not override move(), so it inherits Piece.move().
  2. Step 2: Call move() on Bishop instance

    b.move() calls Piece.move() returning "Any move".
  3. Final Answer:

    Any move -> Option B
  4. Quick Check:

    Inherited method is called if not overridden [OK]
Quick Trick: Subclass inherits base method if not overridden [OK]
Common Mistakes:
  • Expecting error due to missing override
  • Assuming None is returned by default
  • Thinking subclass method is called without definition

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes