JAVA Classes/Objects

Object : An object is an instance of a class. When a class is defined, no memory is allocated but when it is instantiated (i.e. an object is created) memory is allocated. 

To use the data and access functions defined in the class you need to create objects.

Syntax: 

ClassName ObjectName;

Class : Class is a user defined data type, which holds its own data members and member functions, which can be accessed and used by creating an instance o that class. 

A class is like a blueprint for an object.

Defining Class : A class is defined in Java  using keyword “class” followed by the name of class. The body of a class is defined inside the curly brackets and terminated by a semicolon at the end.

 

class className         //user defined className.
{
Access Specifier;       //can be private, public or protected.
Data Members;           //variables to be used.
Member Functions(){}    //method to be access data members.
};                      //class ends with a semicolon.