wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

PPL (QUIZ 6) Memory Management Quiz

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

What type of memory is allocated at compile time?

a)

Stack

b)

Heap

c)

Static

d)

Dynamic

2.

Which memory allocation happens during function calls and is automatically freed after the function ends?

a)

Heap

b)

Static

c)

Stack

d)

Data Segment

3.

In C++, which keyword is used to allocate memory on the heap?

a)

malloc

b)

alloc

c)

new

d)

make

4.

What will likely happen if stack memory exceeds its limit?

a)

OutOfMemoryError

b)

Memory Leak

c)

Garbage Collection

d)

Stack Overflow

5.

Which of the following is an example of static memory allocation?

a)

Memory allocated using malloc

b)

Local variables in a function

c)

Global variables

d)

Objects created using new

6.

In Java, which mechanism handles heap memory automatically?

a)

Pointer management

b)

malloc()

c)

Garbage Collection

d)

Manual Deletion

7.

What is the main risk of heap memory allocation if not managed properly?

a)

Stack Overflow

b)

Memory Leak

c)

Compile Error

d)

Buffer Underflow

8.

Which of the following is true about stack memory?

a)

Slower than heap

b)

Has larger size than heap

c)

Is shared among threads

d)

Is thread-safe

9.

Which technique is NOT used in garbage collection?

a)

Reference Counting

b)

Mark-and-Sweep

c)

Paging

d)

Generational GC

10.

What function in Python forces garbage collection?

a)

delete()

b)

clean()

c)

gc()

d)

gc.collect()

11.

Which of the following is a symptom of a memory leak?

a)

Faster program speed

b)

Decreased RAM usage

c)

Increased RAM usage over time

d)

Compile-time error

12.

What type of memory does this code allocate to? `int *ptr = new int[10];`

a)

Stack

b)

Static

c)

Heap

d)

Data Segment

13.

Smart pointers in C++ help prevent:

a)

Stack overflows

b)

Memory leaks

c)

Compile errors

d)

Garbage collection

14.

Which of the following is automatically freed when the program ends?

a)

Heap

b)

Static

c)

Stack

d)

Data Segment

15.

What is the main issue in heap memory?

a)

Speed

b)

Memory shortage

c)

Memory fragmentation

d)

Syntax error

16.

Where is a function's local variable typically stored?

a)

Static memory

b)

Heap

c)

Stack

d)

Cache

17.

In which language is garbage collection not automatic by default?

a)

Java

b)

Python

c)

C++

d)

Kotlin

18.

Which part of memory stores global variables?

a)

Heap

b)

Static segment

c)

Stack

d)

Cache

19.

What does `free(ptr);` do in C?

a)

Allocates memory

b)

Deletes global variable

c)

Frees memory from heap

d)

Reinitializes pointer

20.

What memory area persists for the entire duration of the program?

a)

Stack

b)

Heap

c)

Static

d)

Cache