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.
DI Pie Chart Questions and Answers for Bank Exams More
100+ Area Aptitude Questions and Answers Pdf More
100+ Data Interpretation Pie Chart Questions and Answers More
True Discount Questions and Answers for Bank Exams More
100+ HCF and LCM Questions and Answers for SSC Exams More
Hidden Tricky Picture Puzzles with Answers More
10+ Hard Sequence Puzzles Questions with Answers More
1000+ IAS General Knowledge Questions and Answers More
Top 100+ Advanced Multithreading Interview Questions 2019-2020 More
100+ Direct and Indirect Democracy UPSC Quiz Questions More