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
How do I write a self declaration?
why java uses class level type casting ?
What is adapter in java?
Is 0 a real number?
What is the benefit of singleton pattern?
How do you remove duplicates in java?
What about main() method in java ?
What is the arraylist in java?
Justify your answer that you can't define a method inside another method in java, if you can then how?
Which data type is a class in java?
What is the difference between serial and throughput garbage collector?
How do you check if two strings are equal in java?
Does java support multiple inheritances?
Can a class be a super class and a sub-class at the same time? Give example.
What are register variables what are the advantages?