Class, Object and the OOP

A class is a set of things or components having some common properties and attributes, and these components are differentiated at any point of time by the values they hold. We call such components as an instance or object of that class. A class is a abstract keyword which generalized a set of similar entities. It serves as the blueprint from which the objects are created in an application. For example, a Person can be a class, but Abhimanyu, Abhishek are the objects/instances of that particular class. A simple Person class looks like,

An object has three basic characteristics:

  1. Identity – That which distinguishes it from other objects
  2. State – Set of properties along with their values at a given point of time
  3. Behavior – The way an object behaves when receiving the request from other objects on the domain

To create a new object of a class:

where, memory is allocated for the person object, depending on the number of attributes that it has. This all is done by the JVM (Java Virtual Machine).

OOP (Object Oriented Programming) is a rule/paradigm of application development where the programs basically deal with the objects and the way these objects interact with each other.

There are some major advantages of using OOP to be kept in mind:

  1. Simplicity – OOP makes the program structure less complex
  2. Modularity – A single object is completely decoupled from all the other objects of the same class
  3. Modifiablity – OOP makes the modification of a class easier as it does not effect other parts of the program
  4. Extensibility – Comparatively easier by creating new objects instantly and modify the existing ones
  5. Maintainability – Easy to maintain and fix the problems if any
  6. Re-usability – As the objects remain decoupled, they can be re-used anywhere else in the program

In the next post, we will be understanding how exactly the JVM works out internally and makes sure that everything goes well.

Receive our updates to your inbox

Get more stuff like this
in your inbox

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.