The memory in the Ram which is reserved for the non-static elements of the .class file is known as an object. The concept of reserving memory in the RAM dynamically (i.e at the run time) for the contents of a hard disk is known as an instance.

Note that in the case of an object, the memory is reserved in the contents of the .class file (in fact they are also contents of a hard disk) in the RAM. Hence object is called as an instance of the class.

Class object1


Int i=0, j =0;

Void function ()


I = i+1;

J =j+1;

Function2 ();

System. Out. prinln (“ inside function1());


Void function2 ()


System. Out. Prinln (i);

System. Out. Prinln (j);

System. Out. Prinln (“inside function2()”);


Public static void main (string args [ ])


Obj1   0 = new obj1 ();

0. Function 1();

O .j = 115;

System. Out. Prinln (“end of main”);

} //end main

} // end class

On the above program, as soon as it is compiled and executed, first the main method is loaded into the RAM. Inside the main method, when the statement Obj1   o = new obj1 (); is encountered the JVM loads the all non-static elements of the class obj1 into the RAM from the hard disk and allocates a memory for these non-static elements and assigns the address of this memory to the variable 0. Hence the object of class obj1 is said to be created.

The non-static members are int i=0, j = 0; and void fun1 () {=} and void fun2 () {=}. But here we have to note that JVM loads only signatures and addresses of fun1 and fun2 into the RAM, instead of loading the entire body of the function. We have to keep in mind that JVM follows the concept of dynamic loading.

Object Programming Help