How objects can change your life

from HeadFirst Java chapter 02

Bavatharany Mahathevan
2 min readOct 12, 2021

In this article, I hope to share the knowledge on how to analyse and organize the objects, classes and procedures of a program.

Think about it, what is exactly OOP, does means that putting all code in the main methods? Nope.

OOP means that playing with the collection objects and the behaviour of the objects. Objects are real word entities, class is a collection of objects while the behaviour is that what the particular object does.

The below image gives the overall idea about objects and class and I hope that you all get an idea about the concept of OOP.

So, as an oop developer, you have to think about who are key players and the procedure of the key player of the particular application before starting your coding to develop an application.

Lets we go into the example from Head Frist Java book.

specification: There are three things square, circle and triangle. when clicking on a thing, the thing has to rotate 360 degrees based on its centre and play music.

as these three objects have the same behaviour, we can categorize these classes into a superclass name as Shape . From now, Shape is a superclass and the other three Square, circle and triangle are subclasses and these subclass can inherit the methods from the Shape class. we can read as Square inherits from Shape, Circle inherits from Shape class, Triangle inherits from Shape class. This process is known as is one of the OOP concepts.

suppose, by the change of existing specification, if another shape Amoeba will be introduced in the specification and the new class Amoeba has an own way to do the same behaviour, but we don’t need to separate it as a new class from others. Like before, the new shape class also inherits from the superclass and to have its own unique behaviour by overriding the methods from supper class and having different implementations in the class.

overriding: the process of redefining a method that is inherited by subclass from superclass when subclass has its own implementation for the particular method.

the below image illustrates the above concept.

subclasses inherit the superclass

From here, we have learnt about objects, classes, inheritance, method overriding and what we should consider before starting programming as well.