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
What's a method in programming?
What are constructors in java?
Differentiate between class and structure.
Does java have extension methods?
What is the size of arraylist in java?
What is :: operator in java 8?
what is the purpose of "virtual"?
Why does java not allow multiple public classes in a java file ?
What is a flag value?
Why do we use bufferedreader?
What exceptions occur during serialization?
What are the ways to instantiate the class class?
What is the difference between jvm and jre? What is an interface?
What is string value?
What is use of set in java?