A)
Object creation process involves 4 steps.
1) “new” operator causes the object’s construction (JVM constructs the object).
2) JVM gives default values to the instance variable of the object.
3) JVM calls a special method known as constructor.
4) new operator returning the hash code of the object.
->the garbage collector is the sub processor of the JVM.
-> Destruction of memory in not required in java because the dynamic memory is released automatically by the garbage collector.
->stack area is there until control in that area only.
Ex:
Main method calls x() using reference “r” on the object.
->new A().x(); it is also valid.
Comments
Post a Comment