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
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
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
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.
4. Which one of the following is a class loader?
a) Bootstrap
b) Compiler
c) Heap
d) Interpreter
View Answer
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
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
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
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.
8. Classes and Methods are stored in which space?
a) Eden space
b) Survivor space
c) Tenured space
d) Permanent space
View Answer
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
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.
10. The same import package/class be called twice in java?
a) True
b) False
View Answer
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.
- Check Programming Books
- Apply for Computer Science Internship
- Practice Information Technology MCQs
- Practice Programming MCQs
- Check Java Books