~/ 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/e2581eb0-6bac-4452-bc1c-018638c166da/flashcard utf-8 LF