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
Explanation: There are only 3 type of memory segment. Stack Segment, Heap Segment and Code Segment.
2. Does code Segment loads the java code?
Explanation: Code Segment loads compiled java bytecode.Byte code is platform independent.
3. What is JVM?
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?
Explanation: Bootstrap is a class loader. It loads the classes into memory.
5. Which class loader loads jar files from JDK directory?
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?
Explanation: Young generation is further classified into Eden space and Survivor space. Old generation is also the tenured space. Permanent generation is the non heap space.
7. What is the java 8 update of PermGen?
a) Code Cache
b) Tenured Space
d) Eden space
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
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
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?
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 features of Java programming language, here is complete set on 1000+ Multiple Choice Questions and Answers on Java.