About Lesson
Java Class
A class in Java is a set of objects which shares common characteristics/ behavior and common properties/ attributes. It is a user-defined blueprint or prototype from which objects are created. It defines the properties (attributes) and behaviors (methods) that objects of that type will have. For example, Student is a class while a particular student named Ravi is an object.
Properties of Java Classes
- Class is not a real-world entity. It is just a template or blueprint or prototype from which objects are created.
- Class does not occupy memory.
- Class is a group of variables of different data types and a group of methods.
- A Class in Java can contain:
- Data member/Fields
- Method
- Constructor
- Blocks
- Nested Class
- Interface
access_modifier class <class_name>
{
data member;
method;
constructor;
nested class;
interface;
}
Class is declared by the use of class
keyword.
Types of Class
- Top Level
- Nested