Method Overriding in Java
Overriding = child rewrites a parent method with the same signature: same name, same parameters. Put @Override so the compiler catches mistakes.
At runtime, a parent reference can call the child’s version: Animal a = new Dog(); a.sound();. Access cannot be tighter in the child. Purpose is specialised behaviour.
If you change parameters, it is not overriding — it becomes overloading or a new method. Show Animal/Dog sound() with a parent reference.
Let's take this on the board with one tiny Main class — no extra files. Method Overriding in Java — output: 25. square(5) returns 5*5. Change to square(6) → 36. Start from main, go line by line, and stop at each print. That output is the proof for Method Overriding.
Parent ref + child object demo for overriding.