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
Can we overload run() method in java?
Explain differences between checked and unchecked exceptions in java?
What are different type of exceptions in java?
What is the main difference between java platform and other platforms?
Does every java program need a main?
What is arraylist e in java?
How is abstraction implemented in java ?
What is data movement?
What is complexity in java?
What is intern method in java?
Can we override protected method in java?
Why do we declare a class static?
What is structure of java heap? What is perm gen space in heap?
what is ststic with example
You can create a string object as string str = “abc”; why cant a button object be created as button bt = “abc”;? Explain