NEW
Font size
S
M
L
XL
WorksheetsMemory Allocation + java-visual
Total questions: 79
Worksheet time: 40mins
Name
Class
Date
1.
Which of the following memory areas is used to store objects that are created dynamically?
a)
Stack memory
b)
Heap memory
c)
String pool
d)
Main memory
2.
Which of the following memory areas is used to store local variables and method parameters?
a)
Stack Area
b)
Heap Area
c)
Method Area
d)
Native Method Stack
3.
Where is the string "Tom" stored in memory?
a)
(A) Stack
b)
(B) Heap
c)
(C) String pool
d)
(D) Permanent generation
4.
Which of the following is the largest memory area in a Java virtual machine (JVM)?
a)
Stack
b)
Heap
c)
Permanent Generation
d)
Code Segment
5.
Which of the following memory areas is used to store native methods?
a)
Class (Method) Area
b)
Heap
c)
Stack
d)
Native Method Libraries
6.
Which of the following memory areas is used to store the order of method execution and local variables?
a)
The stack
b)
The heap
c)
The global variables
d)
The static variables
7.
Which of the following statements correctly describes the difference between stack memory and heap memory?
a)
Stack memory is used to store local variables, while heap memory is used to store global variables.
b)
Stack memory is used to store data that is allocated at compile time, while heap memory is used to store data that is allocated at runtime.
c)
Stack memory is used to store the order of method execution, while heap memory is used to store the objects that are created by the program.
d)
Stack memory is used to store data that is stored in a LIFO (last in, first out) order, while heap memory is used to store data that is stored in a FIFO (first in, first out) order.
8.
Where is the value 100 stored?
a)
Stack
b)
Heap
c)
Both stack and heap
d)
Neither stack nor heap
9.
What is the purpose of the code in the image?
a)
To create a list of strings.
b)
To print a list of strings.
c)
To add strings to a list.
d)
To delete strings from a list.
10.
What is the purpose of the cloud in the image?
a)
To store data
b)
To provide computing resources
c)
To deliver applications
d)
To manage user accounts
11.
Which of the following memory areas is used to store objects created by the new keyword?
a)
Stack memory
b)
String pool
c)
Java Runtime Memory
d)
Heap memory
12.
Which of the following software layers is responsible for managing the memory of a Java application?
a)
Application layer
b)
JIT layer
c)
JVM layer
d)
OS layer
13.
Where is the memory for the local variable c allocated?
a)
Stack
b)
Heap
c)
Both stack and heap
d)
Neither stack nor heap
14.
What is the area in the Java heap where string literals are stored?
a)
The string pool
b)
The object heap
c)
The stack
d)
The method area
15.
Which of the following methods is currently being executed by the thread?
a)
methodOne() [Image shows methodOne() is on top of the stack]
b)
methodTwo() [Image shows methodTwo() is below methodOne() on the stack]
c)
methodThree() [Image does not show methodThree()]
d)
methodFour() [Image does not show methodFour()]
16.
Which of the following memory areas in Java is used to store objects that are created dynamically?
a)
Heap area
b)
Method area
c)
JVM stack
d)
Native method stack
17.
Which of the following is the most common type of memory in a computer?
a)
Heap memory
b)
Permanent generation memory
c)
Young generation memory
d)
Non-heap memory
18.
Which of the following sections of the heap is used to store objects that are likely to be short-lived?
a)
Survivor space
b)
Tenured generation
c)
Permanent generation
d)
Young generation
19.
Where is the string "hello" stored in memory?
a)
Stack
b)
Heap
c)
Both stack and heap
d)
Neither stack nor heap
20.
Where are the Java objects stored?
a)
A. The heap
b)
B. The stack
c)
C. The PermGen/Metaspace
d)
D. The Java Virtual Machine
21.
Which memory area is used to store the local variables and method call stack?
a)
A: Stack
b)
B: Heap
c)
C: Code segment
d)
D: Native method stack
22.
Where is the actual Student object located?
a)
Stack
b)
Heap
c)
Both Stack and Heap
d)
None of the above
23.
Where is the string "Java" stored in the image?
a)
The heap
b)
The stack
c)
The string pool
d)
The Demo object
24.
Which of the following memory regions is used to store the return address of the current function call?
a)
Stack
b)
Heap
c)
Code segment
d)
Data segment
25.
What is the relationship between the parent and child in the image?
a)
The parent is a function that calls the child function.
b)
The parent is a variable that contains the address of the child function.
c)
The parent is a class that contains the child class.
d)
The parent is a process that contains the child process.
26.
What action is taken by the JVM when it detects a conflict between two objects that are using the same cache line?
a)
The JVM moves object B to a non-conflicting location.
b)
The JVM terminates the program.
c)
The JVM prints an error message.
d)
The JVM does nothing.
27.
Which of the following objects is stored in the heap?
a)
A: SNOWBOARD
b)
B: doStuff()
c)
C: main()
d)
D: BUTTON
28.
In the image, which type of memory allocation does the application use?
a)
Explicit memory allocation
b)
Implicit memory allocation
c)
Both explicit and implicit memory allocation
d)
None of the above
29.
The following diagram shows the different regions of the Java heap memory. Which region is used to store newly created objects?
a)
Eden
b)
S1
c)
Old
d)
Permanent
30.
The image shows a cloud with the words "Memory Allocation & Management in Java" under it. What is the purpose of memory allocation and management in Java?
a)
To store data for objects
b)
To free up memory that is no longer in use
c)
To prevent memory leaks
d)
To ensure that all objects have a unique address
31.
Which of the following memory areas is used to store class metadata in Java 8?
a)
Metaspace
b)
New Gen
c)
Old Gen
d)
Native Memory
32.
What is the name of the variable that is pointing to the object in the heap?
a)
ref
b)
P
c)
9
d)
m3
33.
Where is the local variable c allocated in memory?
a)
Stack
b)
Heap
c)
Both stack and heap
d)
Neither stack nor heap
34.
Which of the following is NOT stored in the JVM stack?
a)
Method local variables
b)
Method arguments
c)
Object references
d)
Heap objects
35.
In the image, which of the following variables is passed by value?
a)
args
b)
name
c)
e1
d)
emailAddress
36.
What is the difference between the memory allocated to the student and student2 objects in the image?
a)
student has more memory allocated to it because it has more instance fields.
b)
student2 has more memory allocated to it because it has more methods.
c)
Both student and student2 have the same amount of memory allocated to them.
d)
The amount of memory allocated to student and student2 depends on the values of their instance fields.
37.
Where are string literals stored in Java?
a)
A. Stack
b)
B. Heap
c)
C. String Constant Pool
d)
D. Permanent Generation
38.
Which of the following memory areas is used to store local variables and method parameters?
a)
Class/Method Area
b)
Heap
c)
Stack
d)
Program Counter Register
39.
Where is the stack memory located in the Java Virtual Machine (JVM)?
a)
A. Stack memory is located in the heap memory of the JVM.
b)
B. Stack memory is located in the method area of the JVM.
c)
C. Stack memory is located in the PC registers of the JVM.
d)
D. Stack memory is located in the native area of the JVM.
40.
Which of the following data structures is represented by the boxes in the image?
a)
Stack
b)
Heap
c)
Array
d)
Linked List
41.
Which of the following strings is not stored in the string pool?
a)
Cat"
b)
"Dog"
c)
"Cat" (the second instance)
d)
new String("Cat")
42.
The image shows a stack of objects in the following memory space:
a)
[A] Stack
b)
[B] Heap
c)
[C] Static space
d)
[D] None of the above
43.
What is the difference between user code and machine code?
a)
A. User code is written in a language that the machine can understand, while machine code is written in a language that the user can understand.
b)
B. User code is written in a high-level language, while machine code is written in a low-level language.
c)
C. User code is platform-dependent, while machine code is platform-independent.
d)
D. User code is compiled into machine code by the Java Virtual Machine (JVM), while machine code is executed directly by the CPU.
44.
Which of the following is NOT a component of the HotSpot JVM architecture?
a)
Classloader Subsystem
b)
Method Area
c)
Heap Memory
d)
Native Method Stack
45.
Which of the following memory areas is used to store local variables and method parameters?
a)
Stack area
b)
Heap area
c)
Native method area
d)
Method area
46.
What is the most common type of memory allocation in Java?
a)
Stack memory
b)
Heap memory
c)
Native memory
d)
Code memory
47.
What is the value of the MaxPermit registry key in the image?
a)
1024
b)
4
c)
2048
d)
1000
48.
Which of the following memory areas is used to store the stack of a typical thread?
a)
A: Allocated
b)
Answer B: Mapping
c)
Answer C: Unallocated
d)
Answer D: Guard page
49.
What is the purpose of dynamic memory allocation?
a)
To allocate memory for data structures whose size is known at compile time.
b)
To allocate memory for data structures whose size is known only at runtime.
c)
To free memory that is no longer needed.
d)
To manage the heap of a process' virtual memory.
50.
Which of the following is the most common type of stack in a computer?
a)
Stack
b)
Non-Heap
c)
Heap
d)
Survivor Spaces
51.
What are the three generations of memory in Java?
a)
Eden, Survivor, Permanent
b)
Eden, Survivor, Old
c)
Eden, Old, Permanent
d)
Young, Tenured, Permanent
52.
What is the purpose of the arrows in the image?
a)
o show the flow of data between the stack and heap.
b)
To show the different types of memory in Java.
c)
To show the relationship between the stack and heap.
d)
To show the order in which objects are created and destroyed.
53.
Where is the string "abc" stored in memory?
a)
Stack
b)
Heap
c)
Both stack and heap
d)
Neither stack nor heap
54.
What is the arrow pointing to?
a)
A. The stack
b)
B. The help
c)
C. The heap
d)
D. The value "123"
55.
The image shows a diagram of memory management in Java. Which of the following types of memory management is depicted in the image?
a)
Stack memory management
b)
Heap memory management
c)
Garbage collection
d)
Reference counting
56.
What is the format for "minidata"?
a)
Start address, end address, process ID
b)
Start address, end address, size of memory slot
c)
Process ID, start address, end address
d)
Size of memory slot, start address, end address
57.
Which of the following is the name of the memory region that is used to store objects that are newly created?
a)
A: Eden Space
b)
Answer B: From Space
c)
Answer C: To Space
d)
Answer D: PermGen
58.
Which of the following memory areas is used to store dynamically allocated memory?
a)
Data segment
b)
Stack
c)
Heap
d)
Program code
59.
Which of the following runtime data areas is used to store objects?
a)
JVM Stack
b)
Native Method Stack
c)
Heap
d)
Method Area
60.
What does the arrow in the image point to?
a)
The m3() method
b)
The boolean c variable
c)
The Account ref variable
d)
The public void m2() method
61.
Which of the following memory areas is used to store class metadata in Java?
a)
Metaspace
b)
Heap
c)
Stack
d)
Permanent Generation
62.
Which of the following data structures is represented by the diagram in the image?
a)
Stack
b)
Queue
c)
Hash table
d)
Binary tree
63.
Which of the following activities is the current state of the MainActivity in the image?
a)
Stopped
b)
Saved
c)
Destroyed
d)
Running
64.
The image shows a diagram of dynamic memory allocation in C. Which of the following statements correctly describes the process of dynamic memory allocation?
a)
A pointer is allocated to a memory location on the heap.
b)
The memory location is initialized to a specific value.
c)
The memory location is deallocated when it is no longer needed.
d)
All of the above.
65.
What is the most common cause of StackOverflowError in Java?
a)
A recursive method with no base case
b)
An infinite loop
c)
A memory leak
d)
A heap overflow
66.
Which of the following memory areas is used for dynamic memory allocation in C or Java?
a)
(A) Heap
b)
(B) Static
c)
(C) Stack
d)
(D) Virtual memory
67.
Which of the following memory areas is used to store Java objects?
a)
Heap
b)
Metaspace/PermGen
c)
Stack
d)
Native
68.
Which of the following memory areas is used to store temporary variables and function call information?
a)
STACK MEMORY
b)
HEAP MEMORY
c)
RAM
d)
HARD DRIVE
69.
Which of the following memory types has the fastest access time?
a)
A. CPU registers
b)
B. CPU cache memory
c)
C. RAM
d)
D. Hard disk
70.
What is the highest level of JVM heap memory?
a)
5 GB
b)
4820 MB
c)
2892 MB
d)
1446 MB
71.
Where are objects stored in Java?
a)
Stack
b)
Heap
c)
Both stack and heap
d)
Neither stack nor heap
72.
In the image, which of the following types of memory allocation is the application responsible for both allocating and freeing memory?
a)
Explicit memory allocation
b)
Implicit memory allocation
c)
Stack memory allocation
d)
Heap memory allocation
73.
Which of the following processes was not successfully allocated?
a)
Process 1
b)
Process 2
c)
Process 3
d)
All processes were successfully allocated
74.
Where are local variables stored in memory?
a)
Stack memory
b)
Heap memory
c)
Program memory
d)
Random access memory
75.
What is the maximum memory allocation for Minecraft in the image?
a)
1024 MB
b)
2048 MB
c)
4096 MB
d)
6000 MB
76.
Which of the following is the most important setting in the system properties window?
a)
(A) System Restore
b)
(B) Automatic Updates
c)
(C) Computer Name
d)
(D) Hardware
77.
Which of the following is a static variable in the image?
a)
static x
b)
Java Heap
c)
main()
d)
Object
78.
What is the value of the element on the top of the stack?
a)
1
b)
2
c)
3
d)
4
79.
What is the name of the area in the Java heap where string literals are stored?
a)
String Pool
b)
String Constant Pool
c)
String Literal Pool
d)
String Intern Pool
Reset
