~/ learn/ java-from-zero/ cards/ extends, super() & constructor chaining
1 of 4

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/bf4a596f-f0da-4a21-bcba-f2e1f61f1721/flashcard utf-8 LF