Classes & Objects

Java is a object Oriented Programming language. Programming deals with defining objects states and behaviors.

In Java, Objects are logical representation of a real world objects or a conceptual thing.

Class is a template, which defines the structure of the Object and its behavior.
Using a class, we can create any number of objects.,  

Example:

The above example Vehicle is a class, which has the following properties  & behaviors.

Properties:
numberOfWheels
numberOfDoors
vehicleName

Behaviors:
startEngine()
shutDownEngine()

In the Driver class, we have created 2 objects car & bike using the Vehicle Class.

However the car & bike has its own different properties (states) e.g,
numberOfWheels for car Object is 4, and numberOfWheels for bike object is 2.

Also both car and bike may have differents behaviours based on their usage., 

Leave a Reply

Your email address will not be published. Required fields are marked *