In java , Class is a type that defines the implementation of a particular kind of object.
A class is a blue print of the object. A class describes all the attributes and methods of object.
Class keyword is used to declare the new class.
Data(variables) and methods defined within the class.
Variables and methods are called members of class.
Data are data members or instance variables of the class.
Methods are called member functions of the class.
Object is an instance of class. It is basic unit of system. An object is an real world entity that has some attributes, behavior and identity. Attributes and behavior of an object are defined by the class definition.
new keyword is used to create the object of the class.
Objects have states and behaviours -
• State defines the characteristic of the object e.g. Car brand is BMW, color Black etc.
• Behaviour defines the functionality of the object e.g. gear change, sun roof open etc.
Example: In this example we have created a Car class which has two method carRun() and gearChange(). We have creating a object of Car class and print it.