1. What is memory management in programming?
(A) A method to define classes
(B) A type of loop
(C) A function to print output
(D) The process of storing and retrieving data efficiently
2. Which type of memory is used for temporary storage while a program runs?
(A) ROM
(B) RAM
(C) Hard Disk
(D) Cache
3. Which type of memory is non-volatile and used to store permanent data?
(A) RAM
(B) Stack
(C) Cache
(D) ROM
4. What is a stack in memory management?
(A) A memory structure that stores data in last-in, first-out order
(B) A memory structure that stores data in first-in, first-out order
(C) Permanent storage
(D) Temporary files
5. What is a heap in memory management?
(A) Memory for storing loops
(B) Memory for storing constants
(C) A memory area for dynamic allocation during program execution
(D) Temporary disk storage
6. What is dynamic memory allocation?
(A) Allocating memory at compile time
(B) Allocating memory at runtime
(C) Allocating memory on disk
(D) Allocating memory in ROM
7. What is static memory allocation?
(A) Memory allocated during program execution
(B) Memory allocated at compile time
(C) Memory allocated dynamically
(D) Memory allocated on heap
8. What is memory leak?
(A) Memory that is no longer used but not released
(B) Memory used efficiently
(C) Memory that is cleared automatically
(D) Memory for loops
9. Which of the following helps in automatic memory management?
(A) Loops
(B) Arrays
(C) Functions
(D) Garbage collection
10. Which memory area stores global and static variables?
(A) Heap
(B) Stack
(C) Cache
(D) Data segment
11. Which memory area stores local variables and function call information?
(A) Heap
(B) Data segment
(C) Stack
(D) ROM
12. Which memory area is used for dynamic objects?
(A) ROM
(B) Stack
(C) Heap
(D) Cache
13. What is pointer in memory management?
(A) A data type
(B) A function
(C) A loop counter
(D) A variable that stores memory address of another variable
14. Which of the following can prevent memory leaks in languages like Python and Java?
(A) Static allocation
(B) Garbage collection
(C) Loops
(D) Conditional statements
15. What is virtual memory?
(A) A memory management technique that uses disk space as additional memory
(B) Temporary memory only
(C) Memory for functions
(D) Memory in CPU registers
16. What is the difference between stack and heap memory?
(A) Stack is slow, heap is fast
(B) Stack is for temporary data, heap is for dynamic allocation
(C) Stack stores constants, heap stores variables
(D) There is no difference
17. What is memory fragmentation?
(A) Allocating memory in heap
(B) Combining memory efficiently
(C) Splitting of memory into small unused blocks
(D) Allocating memory in stack
18. Which of the following is an advantage of using stack memory?
(A) Prevents memory leaks automatically
(B) Can store large dynamic objects
(C) Fast allocation and deallocation
(D) Non-volatile storage
19. Which of the following is an advantage of using heap memory?
(A) Fast allocation and deallocation
(B) Can store large dynamic objects
(C) Always automatic cleanup
(D) Stores only local variables
20. What is the main goal of memory management in programming?
(A) Printing output
(B) Creating loops
(C) Storing functions
(D) Efficient use of memory and prevention of errors