Classes and objects are basic concepts of object-oriented programming which revolve around the real life entities.
A collection of objects is called a class.
A class is a user defined blueprint or prototype from which objects are created.
It represents the set of properties or methods that are common to all objects of one type.
In general, class declarations can include the following components, in order:
Modifiers:
Several modifiers like public exist or has the default access.
Class name:
The name should begin with an initial letter (capitalized by convention).
Superclass (if any):
The name of the class’s parent (superclass), if any, preceded by the keyword extends.
A class (subclass) can only extend one parent.
Interfaces (if any):
A comma-separated list of interfaces implemented by the class, if any, preceded by the keyword implements.
A class can implement more than one interface.
Body: The class body surrounded by braces, { }.
Constructors are used for initializing new objects.
Fields are variables that provides the state of the class and its objects, and methods are used to implement the behavior of the class and its objects.
There are various types of classes that are used in real world applications such as nested classes, anonymous classes, lambda expressions.