MCQ on JVM and Java Memory management

(Last Updated On: March 13, 2019)

MCQ on JVM and Java Memory Management – Multiple choice questions in Java memory management with answers and explanation. 60% of the objective questions are asked in interviews. But, additional has been added to cover memory concept in Java programming.

 


Q) Where an object of a class get stored?
  1. Heap
  2. Stack
  3. Disk
  4. File
View Answer
Answer: A

 

Q) In what memory area, variable temp and variable card written in main () get stored?
  1. Heap, Heap
  2. Stack, stack
  3. Heap, Stack
  4. Stack, Heap
View Answer
Answer: B
Both variable temp and card will be in stack frames. Temp is primitive data type and card is of reference type. Variable card will be used to store the address/ reference of an object of CreditCard class.


Q) Java uses two stage system for program execution. They are
  1. Compiler and instruction
  2. Compiler and interpreter
  3. Copy and compiler
  4. None
View Answer
Answer: B

Q) Garbage collection in Java is
  1. Unused package in a program automatically gets deleted.
  2. Memory occupied by objects with no reference is automatically reclaimed for deletion.
  3. Java deletes all unused java files on the system.
  4. The JVM cleans output of Java program.
View Answer
Answer: B