These days, I have had chances to teach Java to a couple of students. Unfortunately, they do not know why they learn the concepts of Object-Oriented Programming and how Java language approach the Object-Oriented concepts as I did when I was a student. They know only there is a class that is a unit of Java programming, and an instance of a class can be called an object. Yes, their idea is not wrong, but the idea is not enough to understand Java programming.
First, let’s talk about “object”. As you know, an object can be a thing that exists physically or a business process that does not exist physically. For examples, a student, a computer, or a pencil can be an object and even a bank account can be regarded as an object. Now, we are clear that anything in the world can be viewed as an object irrespective of its physical existence.
Next, a class is a description about an object. That means a class explains the characteristics of a group of objects that have common characteristics to be identified from other groups of objects. Some people probably think this explanation is weird. Yes, it’s weird to our brain’s mechanism. You should know programming is not for human beings, and it is necessary to make computers understand our world. Therefore, programming languages have been developing to the direction that makes developers and computers have common ground efficiently between our brain’s mechanism and computers’ mechanism.
Anyway, a class is a description about a group of objects that have common characteristics. There are two categories of characteristics to define a class. The two categories are called ‘state (also known as properties or member variables)’ and ‘behavior (also known as member methods)’. For examples, a bicycle can also have manufacturing ID and numbers of wheels as its states and the processes of changing gears and applying brakes as its behaviors. Please, be aware of this process is to express our world in our programming (in memory of our computers). Therefore, if an object is created by following a class in our programing, it is called an instance of the class and the process is called instantiation.
In next posting, I will explain how Java language cover these Object-Oriented concepts.