Top 50+ Advanced Java Interview Questions 2020-2021 - 1

Question: 1

How all can you free memory?

With the help of finalize() method.

If a programmer really wants to explicitly requests a garbage collection at some point, System.gc() or Runtime.gc() can be invoked, which will fire off a garbage collection at that time.

Question: 2

What do you know about the garbage collector?

In Java, memory management is done automatically by JVM.

A programmer is free of this responsibility of handling memory.

A garbage collector is a part of JVM responsible for removing objects from heap, which is no longer in use.

The garbage collector typically runs in a background thread, periodically scanning the heap, identifying garbage objects, and releasing the memory they occupy so that the memory is a available for future objects.

Question: 3

What is the difference between serial and throughput garbage collector?

The throughput garbage collector uses a parallel version of the young generation collector and is meant to be used with applications that have medium to large data sets.

On the other hand, the serial collector is usually adequate for most small applications.

Question: 4

Can we unreferenced objects be refrenced again?

Yes

Related Questions