Interview Questions on Garbage Collection in Java

Questions on garbage collection play a crucial role in cracking interviews. The garbage collection concept is critical in Java, particularly for memory management.

1) Garbage Collection in Java enables ——— management of memory.

A) Systematic

B) Manual

C) Automatic

D) Semi-automatic

Click Here for Answer

Ans. C

2) Objects in Java are stored inside the ————-.

A) JVM

B) JRE

C) RAM

D) Heap Memory

Click Here for Answer

Ans. D


3) In Java, garbage collection helps to simplify the process of 

A) Memory Management

B) Improving free space in the memory

C) Collecting waste from memory

D) All the above

Click Here for Answer

Ans. D

4) The purpose of the garbage collector is to scan the heap memory periodically to find ———- objects.

A) Unused

B) Reachable

C) Useful

Click Here for Answer

Ans. A

5) The garbage collection involves the following steps in the order of ——-.

A) Compacting, Sweeping, and Marking

B) Sweeping, Compacting, and Marking

C) Marking, Sweeping, and Compacting

D) Compacting, Marking, and Sweeping

Click Here for Answer

Ans. C

Questions on Garbage Collection in Java

6) The System.gc() method helps to request the JVM for running the

A) Heap Memory

B) Exception Handling

C) Garbage Collector

D) All the Above

Click Here for Answer

Ans. C

7) The garbage collector, while running —— the normal program execution.

A) Affects

B) Do not Affect

Click Here for Answer

Ans. B

8) Garbage collection enables —— allocation of memory, allowing the development of an efficient program.

A) Dynamic

B) Vertical

C) Horizontal

D) Static

Click Here for Answer

Ans. A

9) —– is the benefit of running a garbage collector in Java.

A) Memory Optimization

B) Improved Performance

C) Avoid Memory Leaks

D) All the Above

Click Here for Answer

Ans. D

10) Lastly, garbage collector helps to enhance productivity and reduce errors.

A) True

B) False

Click Here for Answer

Ans. A

Leave a ReplyCancel reply

Discover more from BerylSoft

Subscribe now to keep reading and get access to the full archive.

Continue reading

Exit mobile version