In Java, a class is a user-defined data type from which objects are created. It can also be called as a blueprint or prototype. A class is a collection of various methods and variables which represent a set of properties that are common to all the objects of one type. A class includes components such as: –
- Modifiers: it states that a class can be public or can have a default access.
- Class name: the name of a class should begin with a letter and should be the same as the file name.
- Body: the class body is surrounded by braces- {}.