Inheritance in Java
Inheritance lets a child reuse and extend a parent. Keyword: class Dog extends Animal. IS-A idea: Dog is an Animal, so Dog can use parent features.
Java allows one parent class only (single class inheritance). Write common code once in the parent. Special code goes in the child. The child can add new methods and override parent methods.
Deep inheritance trees become hard to change. Keep them shallow. Extra capabilities come from interfaces: one superclass + many interfaces.
Let's take this on the board with one tiny Main class — no extra files. Inheritance in Java — output: Eating then Bark. Dog did not rewrite eat — it inherited it from Animal. Start from main, go line by line, and stop at each print. That output is the proof for Inheritance.
Animal
sound()
│ extends
▼
Dog
sound() → barkIS-A + single class inheritance + interfaces for extra contracts.