Skip to main content

Posts

Showing posts with the label OOPs Concepts

What happens when an object is created in Java?

Everyone knows Java is an object oriented programming la nguage. Ev ery object in java is a reference to a real entity. So whenever you create an object of class ma ny things will happened in JVM. Memory is allocated from heap to hold all instance variables and implementation-specific data of the object and its super classes. Implementation-specific data includes pointers to class and method data. The instance variables of the objects are initialized to their default values.   The constructor for the most derived class is invoked. The first thing the constructor does is call the constructor for its uppercase. 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 variables will be initialize d and initialization blocks are executed. Then the body of the constructor is executed. Thus, the constructor for the base class completes ...