Top 50+ Java Garbage Collections Interview Questions and Answers - 1
What are the disadvantages of reference counting in garbage collection?
An advantage of this schema is that it can run in small chunks of time closely interwoven with the execution of the program.
This characteristic makes it particularly suitable for real time environments where the program can’t be interrupted for very long.
A disadvantage of reference counting is that it does not detect cycles.
A cycle is two or more objects that refer to one another.
Another disadvantage is the overhead of incrementing and decrementing the reference count each time.
Because of these disadvantages, references counting currently is out of favor.
What class of exceptions are generated by the Java run time system?
The Java runtime system generates Run time exception and Error exceptions.
What is garbage collection?
If no reference to an object, that object is assumed to be no longer needed, and the memory occupied by the object can be reclaimed.
This is known as garbage collection.
What is gc()?
gc() is a daemon thread.gc() method is defined in System class that is used to send request to JVM to perform garbage collection.
Does Java have destructors?
Garbage collector does the job working in the back ground. Java does not have destructors; but it has finalizers that do a similar job.
The syntax is
public void finalize()
If an object has a finalizer, the method is invoked before the system garbage collects the object.
100+ Common Puzzles asked in Interviews with Answers More
100+ TNPSC General Studies Question Paper with Answers More
100+ TNPSC Indian Economy Mock Test More
100+ World Economy Objective Type Questions and Answers More
100+ Economics Quiz Questions and Answers Pdf More
1000+ Sentence Correction Verbal Ability Questions & Answers More
General Science Quiz Questions and Answers More
List of Diseases Caused by Virus and their Symptoms More
Computer Awareness MCQ Pdf for Bank Exams More
Database Management System Mcq Questions with Answers More