250+ TOP MCQs on Memory Management and Answers

This set of Java Multiple Choice Questions & Answers (MCQs) on “Memory Management”.

1. Which of the following is not a segment of memory in java?
a) Stack Segment
b) Heap Segment
c) Code Segment
d) Register Segment

Answer: d
Clarification: There are only 3 types of memory segment. Stack Segment, Heap Segment and Code Segment.

2. Does code Segment loads the java code?
a) True
b) False

Answer: a
Clarification: Code Segment loads compiled java bytecode. Bytecode is platform independent.

3. What is JVM?
a) Bootstrap
b) Interpreter
c) Extension
d) Compiler

Answer: b
Clarification: JVM is Interpreter. It reads .class files which is the byte code generated by compiler line by line and converts it into native OS code.

4. Which one of the following is a class loader?
a) Bootstrap
b) Compiler
c) Heap
d) Interpreter

Answer: a
Clarification: Bootstrap is a class loader. It loads the classes into memory.

5. Which class loader loads jar files from JDK directory?
a) Bootstrap
b) Extension
c) System
d) Heap

Answer: b
Clarification: Extension loads jar files from lib/ext directory of the JRE. This gives the basic functionality available.

6. Which of the following is not a memory classification in java?
a) Young
b) Old
c) Permanent
d) Temporary

Answer: d
Clarification: Young generation is further classified into Eden space and Survivor space. Old generation is also the tenured space. The permanent generation is the non heap space.

7. What is the Java 8 update of PermGen?
a) Code Cache
b) Tenured Space
c) Metaspace
d) Eden space

Answer: c
Clarification: Metaspace is the replacement of PermGen in Java 8. It is very similar to PermGen except that it resizes itself dynamically. Thus, it is unbounded.

8. Classes and Methods are stored in which space?
a) Eden space
b) Survivor space
c) Tenured space
d) Permanent space

Answer: d
Clarification: The permanent generation holds objects which JVM finds convenient to have the garbage collector. Objects describing classes and methods, as well as the classes and methods themselves, are a part of Permanent generation.

9. Where is String Pool stored?
a) Java Stack
b) Java Heap
c) Permanent Generation
d) Metaspace

Answer: b
Clarification: When a string is created; if the string already exists in the pool, the reference of the existing string will be returned, else a new object is created and its reference is returned.

10. The same import package/class be called twice in java?
a) True
b) False

Answer: a
Clarification: We can import the same package or same class multiple times. Neither compiler nor JVM complains will complain about it. JVM will internally load the class only once no matter how many times we import the same class or package.

Leave a Reply

Your email address will not be published. Required fields are marked *