Top 50+ Java Garbage Collections Interview Questions and Answers - 2

Question: 6

Describe the Garbage Collection process in Java?

The JVM spec mandates automatic garbage collection outside of the programmer’s control.

The System.gc() or Runtime.gc() is merely a suggestion to the JVM to run the GC process but is NOT guaranteed.

Question: 7

Explain the keywords  native, transient, volatile, finally.

native – to use methods which written in other language.

transient – if u declare state of a class as transient then it’s not saved in persistent area.

 volatile – this is not optimized at the time of optimization because its value may be changed implicitly or explicitly.

finally – finally is used to do work prior of closing the program because of exception. It’s always called be compiler either exception generated or not.

Question: 8

What kind of thread is the Garbage collector thread?

It is a daemon thread.

Question: 9

If an object is garbage collected, can it become reachable again?

Once an object is garbage collected, it ceases to exist. It can no longer become reachable again.

Question: 10

How will you invoke any external process in Java?

By Runtime.getRuntime().exec(?) method

Related Questions