Java Questions & Answers – Memory Management

This set of Java Multiple Choice Questions & Answers (MCQs) focuses 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
View Answer

Answer: d
Explanation: 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
View Answer

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

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

Answer: b
Explanation: 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.
advertisement
advertisement

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

Answer: a
Explanation: 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
View Answer

Answer: b
Explanation: 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
View Answer

Answer: d
Explanation: 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
View Answer

Answer: c
Explanation: 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.
advertisement

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

Answer: d
Explanation: 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
View Answer

Answer: b
Explanation: 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.
advertisement

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

Answer: a
Explanation: 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.

Sanfoundry Global Education & Learning Series – Java Programming Language.

To practice all areas of Java language, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.