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

Should you use singleton pattern?

525


What is the difference between preemptive scheduling and time slicing in java programming?

536


What do you mean by default constructor in java?

580


What is a percentage sign called?

621


What is natural ordering in java?

530






Implement a stack with push (), pop() and min() in O(1) time.

638


What is java argument list?

522


What is string and example?

557


What is blank final variable?

567


What is the major drawback of internal iteration over external iteration?

589


Which is easier .net or java?

649


What is passed by reference and pass by value ?

584


What is jvm? Why is java called the platform independent programming language?

547


What is the use of isempty in java?

539


How to reverse a string in java?

526