0
0
LLDsystem_design~10 mins

Piece movement rules (polymorphism) in LLD - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare the base class method for movement.

LLD
class Piece {
    public void [1]() {
        // base movement logic
    }
}
Drag options to blanks, or click blank then click option'
Arun
Bmove
Cjump
Dwalk
Attempts:
3 left
💡 Hint
Common Mistakes
Using unrelated method names like 'run' or 'jump' which do not fit the context.
2fill in blank
medium

Complete the code to override the move method in a subclass.

LLD
class Knight extends Piece {
    @Override
    public void [1]() {
        // knight specific movement
    }
}
Drag options to blanks, or click blank then click option'
Ajump
Bwalk
Crun
Dmove
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different method name which does not override the base method.
3fill in blank
hard

Fix the error in the method signature to correctly override the base method.

LLD
class Bishop extends Piece {
    public void [1]() {
        // bishop movement logic
    }
}
Drag options to blanks, or click blank then click option'
Amove
BmoveTo
CmovePieceTo
DmovePiece
Attempts:
3 left
💡 Hint
Common Mistakes
Changing the method name breaks overriding and polymorphism.
4fill in blank
hard

Fill both blanks to define an abstract base class and abstract move method.

LLD
abstract class Piece {
    public abstract void [1]();
}

class Queen extends Piece {
    @Override
    public void [2]() {
        // queen movement logic
    }
}
Drag options to blanks, or click blank then click option'
Amove
Brun
Cjump
Dwalk
Attempts:
3 left
💡 Hint
Common Mistakes
Using different method names breaks the abstract method contract.
5fill in blank
hard

Fill all three blanks to implement polymorphic move calls for different pieces.

LLD
Piece p1 = new [1]();
Piece p2 = new [2]();
p1.[3]();
p2.move();
Drag options to blanks, or click blank then click option'
AKnight
BBishop
Cmove
Drun
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect class names or method names breaks polymorphism.