Open a ride-sharing app in Dhaka and ask for the fare of a 4 km trip. The screen shows three lines: car, Tk 170; bike, Tk 80; CNG, Tk 88. Behind that screen the programmer wrote one loop, and inside the loop one call, v.fare(4). She did not write "if it's a car, do this; if it's a bike, do that". Next month the company adds a metro line, and nobody touches the loop at all. The new vehicle simply answers the same call in its own way.
You have already seen the seed of this. The last program of the previous chapter declared Player p = new Bowler(900, 36);, and p.average() ran the Bowler's formula, although the variable said Player. One call, a different body depending on the object. That is polymorphism, the fourth pillar of OOP, and it is where this chapter begins.
By the end you'll be able to tell the two kinds of polymorphism apart by one question, "who chooses the method, and when?". You'll write overloaded methods and predict which one the compiler picks, including the tricky cases of widening, boxing and the declared type. You'll write a valid override, list the rules that make one invalid, and explain why a static method can't be overridden, only hidden. You'll know what virtual does in C++ and why Python needs no such word. Then we leave single classes and look at how classes connect: has-a links (association, aggregation, composition), the design ideas of cohesion, coupling and SOLID, and the UML class diagram, which you'll read and draw. We finish with one of the most-asked written questions on OOP: "Write down the features of OOP", answered in full, with a Java program that implements them.
We'll go in four parts, from easy to hard: polymorphism and overloading; overriding and virtual; the links between classes and the rules of good design; UML and the written answers. Every program in this chapter was compiled and run, and the output you see is the real output.