What is the life-cycle of an object?

Answer Posted / chantiraji

Object creation
---------------
The operator new allocates storage in the heap and invokes a constructor method for initialization of the object.

Object deletion
---------------
The Java garbage collector runs in parallel (as a thread) with the executing program, so garbage collection is in some sense continuous in Java. A class can have a finalize method that is to be invoked (automatically) before deleting an object. This is useful in case there are any resources, such as an open file, that need to be released by the object before it is removed from the system.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do I write a self declaration?

549


why java uses class level type casting ?

2251


What is adapter in java?

512


Is 0 a real number?

587


What is the benefit of singleton pattern?

520






How do you remove duplicates in java?

520


What about main() method in java ?

565


What is the arraylist in java?

528


Justify your answer that you can't define a method inside another method in java, if you can then how?

600


Which data type is a class in java?

569


What is the difference between serial and throughput garbage collector?

575


How do you check if two strings are equal in java?

577


Does java support multiple inheritances?

556


Can a class be a super class and a sub-class at the same time? Give example.

795


What are register variables what are the advantages?

444