Significance of Classes and Object

Java is a pure object oriented language, so all the functionality revolves around classes and objects. Without classes, there can be no objects and without objects, no computation takes place. Thus, classes form the basis of all computation in Java. When a class is declared, no memory space is allotted to it. This is because a class is simply a blueprint containing objects and methods. Memory space is allocated when objects of a class type are created.

The declarations of member variables take place in the body of the class. Member variables can be of two types: class/static variable and instance variable. Class variables are the data members that are declared once for a class. All objects of the class type share these data members as their single copy is available in memory. Class variables are made by declaring variable with static keyword. Instance variable is a data member that is created for every object of the class. All objects of a class have their own copies of instance variable. The declarations of member methods take place in the body of the class after member variables. Member methods can be of two types: class method and instance method. Class methods operate only on class variables and do not have access to instance variable. The static keyword is used in declaration. Instance method operates on instance variables of current object but also have access to the class variable. Java provides four types of access specifiers: public, private, default and protected.

To Access the full content, Please Purchase