extends copies a parent class into your child; implements makes the child promise to deliver methods an interface demands.
1 extends = is-a
class Dog extends Animal — a Dog IS an Animal and inherits its fields and methods.
2 implements = can-do
An interface is a list of method promises. A class that implements it must write every one of them.
3 super calls up
super(...) runs the parent constructor first, so the inherited part of the object is ready.
4 One parent only
Java allows one superclass, but a class can implement many interfaces at once.
Two kinds of promise
extends = is-a1class Dog extends Animal — a Dog IS an Animal and inherits its fields and methods. implements = can-do2An interface is a list of method promises. A class that implements it must write every one of them. super calls up3super(...) runs the parent constructor first, so the inherited part of the object is ready. One parent only4Java allows one superclass, but a class can implement many interfaces at once. 4 building blocks make up Two kinds of promise
Call d.speak() and Java hunts up the family tree until the body is found.
process decision input / output start / end super(n) lets the Animal constructor set the inherited name, then Dog fulfils the Pet promise.
JVMThe file holds three players: the interface Pet, the subclass Dog and its superclass Animal.
Memory
no variables yet — press play
Console
output appears as the program runs…
A constructor chain pushes frames bottom-up: main, then Dog, then Animal on top.
Drag to orbit the scene. Press Play to watch memory in action.
Cat never mentions eating — can it still do it?
Your predicted output — one line per console line
Hint: A subclass inherits every method it does not override — Cat gets eat() for free from Animal.
01extends makes an is-a link: the child inherits fields and methods from the parent.
02implements is a promise: write a body for every method the interface declares.
03super(...) must run before the rest of the constructor — the parent part is built first.
04Method lookup goes child first, then up the tree; nothing found means a compile error.
05A class may extend only one class but implement many interfaces.