🎭 Shape Shifter

Master Runtime Polymorphism!

⭐ Score: 0
🎯 Level: 1/8
📜 Class Hierarchy
abstract class Shape {
  abstract draw();
}

class Circle extends Shape {
  @Override
  draw() { print("Drawing ⭕"); }
}

class Rectangle extends Shape {
  @Override
  draw() { print("Drawing ⬜"); }
}
🧠 Key Concept: The reference type determines what methods you can call, but the object type determines which implementation runs!
🎬 Runtime Magic
Shape shape
⬇️
new Circle()
shape.draw();

What gets printed?

🎭 Shape Shifter

🔺

Learn Runtime Polymorphism!


In Java, the same method call can produce different results based on the actual object type, not the reference type.


Given a reference and object, predict what the method call will output!