Before writing Java, it helps to understand the style of programming it uses. Java is object-oriented — programs are built around objects rather than just a list of steps. This chapter introduces that idea (ICSE Class 9).
1POP vs OOP
There are two big ways to structure a program:
| POP (Procedure-Oriented) | OOP (Object-Oriented) | |
|---|---|---|
| Built around | Functions/procedures (steps) | Objects (data + actions together) |
| Data is | Often shared/global — less protected | Kept inside objects — protected |
| Approach | Top-down | Bottom-up (build objects, combine them) |
| Example languages | C, early BASIC | Java, C++, Python |
- POP is built around procedures/functions (steps); OOP is built around objects (data + actions together).
- In OOP, data is kept inside objects and protected, not shared globally.
- Java, C++ and Python are object-oriented; C is procedure-oriented.
2The four pillars of OOP
OOP rests on four core ideas:
| Pillar | Means |
|---|---|
| Abstraction | Showing only the essential features and hiding the complex details (you drive a car without knowing the engine internals) |
| Encapsulation | Wrapping data and the methods that use it together inside an object, and protecting the data |
| Inheritance | A new class can reuse (inherit) the features of an existing class (a Car inherits from Vehicle) |
| Polymorphism | One name behaving in different ways (the same method works for different types) |
- Abstraction shows essentials and hides details; Encapsulation wraps data + methods together and protects data.
- Inheritance lets a new class reuse an existing class's features; Polymorphism lets one name behave in different ways.
- Remember A-PIE: Abstraction, Polymorphism, Inheritance, Encapsulation.
3OOP in real life
OOP models the real world. Think of a Car:
- State (data): colour, speed, fuel.
- Behaviour (actions): start(), accelerate(), brake().
Every real car is an object built from the Car class (the design). The pillars show up naturally:
- Abstraction — you press the accelerator; you don't need to know the engine details.
- Encapsulation — the fuel level is kept inside the car, changed only through proper actions.
- Inheritance — a SportsCar is a Car with extra features.
- Polymorphism — "start" works for a Car, a Bike or a Truck, each in its own way.
- OOP models real entities as objects with state (data) and behaviour (actions).
- A class is the design; each real thing is an object made from it.
- The four pillars appear naturally — e.g. a SportsCar inherits from Car (inheritance).
★ Practical: model with OOP
On paper, design an object-oriented model:
- Pick a real thing (e.g. a Mobile Phone). List its state (data) and behaviour (actions).
- Name the class and one object you'd create from it.
- Give one example each of abstraction and encapsulation for your object.
- Suggest a class that could inherit from yours.
Ready for the chapter test?
Answer 5 questions. Score 60% or more to mark this chapter complete.
Start the test →💡 Log in to save your progress and earn the certificate.