Classes And Objects
Consider this situation, you are working as a civil engineer and you want to build more than 100 houses (same design) for government project.
First of all, as an engineer you will prepare a plan like blue print that plan have all the things about house. Using that plan or blue print we can build all the houses easily. Without your house blueprint you cannot make house.
We can compare this case with object-oriented programming. In OOP world, class is blue print using that we can create objects.
Class just a plan. It is a logical thing and it does not consume any memory in programming. Whenever we create objects that time only memory will be consumed.
If you take animal is a class then dog is an object and if you take fruit as a class then mango is an object.
For example, dog is an object so it has state like color, name, breed etc. as well as behaviors like wagging the tail, barking, eating, etc.
Class
Get Karnan Sooriyakumar’s stories in your inbox
Join Medium for free to get updates from this writer.
A class can be defined as a blueprint from which we can create an individual objects. Collection of objects is called as class.
Object
Object is an entity that has state and behavior.
Instance Variables
Things an object knows about itself are called instance variables. They represent the state of an object.
Methods
Things an object does are called methods. They represent the behavior of an object.
References
[1] Sierra, K., & Bates, B. (2005). Head First Java, 2nd Edition (2nd ed.). O’Reilly Media.








