AI

Inheritance allows a class to derive features from another class. The extends keyword is used for this.

Your Task:

  • Create a class Dog that extends Animal (Animal is pre-defined for you in the background setup, but you need to redefine it or assume it exists. For this script, define both or just Dog if you can)
  • Let's define Animal first (copy from previous if needed) then Dog
  • Dog should override speak() to return "[name] barks."
  • Create a myDog instance named "Buddy"
  • Call myDog.speak()
TypeScript Solution
Loading...

Submit your code to see test results