Step 1: Understanding classes in Java.
In Object-Oriented Programming, a class is a blueprint or template used to create objects. It defines the structure and behavior that the objects created from it will possess.
A class contains two major components:
Attributes (Variables): These represent the properties or characteristics of an object.
Methods (Functions): These define the actions or behaviors that objects can perform.
Step 2: Role of class in Java programs.
When a class is created, it acts as a design for objects. Multiple objects can be created using the same class, and each object will have its own set of attribute values but share the same methods defined in the class.
For example, a Student class may define attributes such as name, roll number, and marks, along with methods such as displayDetails().
Step 3: Evaluation of options.
(A) Class: Correct. A class defines attributes and methods in Java.
(B) Object: Incorrect. An object is an instance of a class, not the definition of attributes and methods.
(C) Instance: Incorrect. Instance is another term for an object created from a class.
(D) Variable: Incorrect. A variable stores a value but does not define methods.
Step 4: Conclusion.
Therefore, the entity that defines attributes and methods in Java is the Class.
Final Answer: Class