~/ learn/ java-from-zero/ cards/ Inheritance & Polymorphism
1 of 24

Type a subclass constructor that calls super()

Type a subclass constructor that calls super()

Answer

Dog(String name, String breed) { super(name); this.breed = breed; }

super(name) delegates to Animal's constructor. It must appear before any other statement. The compiler inserts super() automatically only when the parent has a no-arg constructor.

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/73c99b6d-7e11-4548-89f4-9996c1c2a0d1/flashcard utf-8 LF