A class comprises of various variables (or attributes). For e.g., the
Student class is comprised of variables name , marks and section , the Car class is comprised of variables owner , registrationNumber , engineCC etc., These class variables are also called as instance variables or member variables or class attributes.
class Student . ) operator. The variables in the student class can be accessed as shown below.
Student mahesh = new Student(); // LINE A mahesh is the reference pointing to the Student object created in LINE A
![]() Student ntr can be created and the variables in it can be accessed similarly.
Student ntr = new Student(); // LINE B mahesh and ntr , pointing to two objects created at LINE A and LINE B respectively.
Also note that when we try to access the variables using a reference which does not point to any object, we get a NullPointerException during run-time.
Student prabhas = null; // LINE B
|