Define class and object with an example.

Short Answer
Views 26

Answer:

An object is an entity having a specific identity, specific characteristics and specific behavior.

A class is a blue print that represents a set of objects that share common characteristics and behaviour.

Take the example of a house. An architect will have the blueprints for a house. Those blueprints will be plans that explain exactly what properties the house will have and how they are all laid out. However, it is just the blueprint, we can't live in it. Builders will look at the blueprints and use those blueprints to make a physical house. They can use the same blueprint to make as many houses as they want. Each house will have the same layout and properties. Each house can accommodate its own families. So, in this example, the blueprint is the class, the house is the object and the people living in the house are data stored in the object's properties.

Related Articles:

This section is dedicated exclusively to Questions & Answers. For an in-depth exploration of Java Programming Language, click the links and dive deeper into this subject.

Join Our telegram group to ask Questions

Click below button to join our groups.