Sunday 22 February 2015

Describe what happens when an object is created in Java?

Memory is allocated from heap to hold all instance variables
The instance variables of the objects are initialized to their default values.
The constructor for the most derived class is invoked.
This process continues until the constructor for java.lang.Object is called, as java.lang.Object is the base class for all objects in java.
Before the body of the constructor is executed, all instance variable initializers and initialization blocks are executed.

No comments:

Post a Comment