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.
SAP SD Interview Questions and Answers More
Top 1000+ Bank Exams Question Papers with Answers Pdf More
1000+ SBI Computer Awareness Study Material More
Top 1000+ Preposition Questions for SSC Exams More
Preposition Quiz Questions and Answers for Bank Exams More
Inventions and Discoveries General Knowledge Questions and Answers More
1000+ Indian Polity Online Test More
1000+ World History General Knowledge Questions and Answers More
1,000+ Tamil Nadu General Knowledge Questions & Answers 2020-21 More
PG TRB Geography Question Bank 2020-21 More