Sunday, March 30, 2008

CORE JAVA FAQS

21. How many times may an object's finalize() method be invoked by the garbage collector and when it is invoked ?

An object's finalize() method may only be invoked once by the garbage collector when the object is unreachable.

22. Does garbage collection guarantee that a program will not run out of memory?

Garbage collection does not guarantee that a program will not run out of memory. It is possible for programs to use up memory resources faster than they are garbage collected. It is also possible for programs to create objects that are not subject to garbage collection.


23. How does the distributed garbage collection work in java?


· The RMI subsystem implements a reference counting-based distributed garbage collection (DGC) algorithm to provide automatic memory management facilities for remote server objects.

· Basically, DGC works by having the remote server keep track of all external client references to it at any given time. When a client obtains a remote reference, it is addded to the remote object's referenced set. The DGC then marks the remote object as dirty and increases its reference count by one. When a client drops a reference, the DGC decreases its reference count by one, and marks the object as clean.

When the reference count reaches zero, the remote object is free of any live client references. It is then placed on the weak reference list and subject to periodic garbage collection.


24.What is the priority of Garbage collection thread in java ?


This is a low-priority thread in java.


25. How many applications can be run by one run-time instance of JVM ?


One run-time instance of java application can run only one instance.


0 comments: