All challenges
Abstract Classes and Polymorphism
mediumclasses100 XPProblem
Create an abstract class Animal with a protected name set via the constructor, an abstract method speak(): string, and a concrete method introduce(): string that returns "<name> says <sound>" using speak(). Implement Dog (speaks "Woof") and Cat (speaks "Meow") subclasses, then iterate over an Animal[] and log each introduction.
Expected output
Rex says Woof
Whiskers says MeowHints
Stuck? Reveal hints one at a time.
Solution
Try solving it yourself first — revealing is always available.
Press Run in the editor — your console output is checked automatically.
No errors
Loading...
Console output appears here. Press Run or just type — the code compiles automatically.