Each question below shows the correct answer with a full explanation. Use these to build conceptual understanding before attempting a timed quiz.
Memory Management ConceptsEasy
Q1. What is RAM?
- A.Random Access Memory, volatile memory for programs✓ Correct
- B.A programming language for system-level development
- C.A type of hard drive for persistent data storage
- D.Read-Access Module for hardware communication
Explanation
RAM (Random Access Memory) is volatile memory that stores data and program code currently being used by the CPU.
Report an error in this question
Memory Management ConceptsEasy
Q2. What is the stack in memory?
- A.A memory region storing locals and call info in LIFO✓ Correct
- B.The hard drive used for persistent data storage
- C.A data structure only with no memory role
- D.A type of processor cache for fast data access
Explanation
The stack stores local variables, function parameters, and return addresses in a Last-In, First-Out manner.
Report an error in this question
Memory Management ConceptsEasy
Q3. What is a memory leak?
- A.A security vulnerability in network protocols
- B.A hardware failure in the memory modules
- C.A type of buffer overflow in array operations
- D.Allocated memory no longer used but not freed✓ Correct
Explanation
A memory leak occurs when a program allocates memory but fails to release it after use.
Report an error in this question
Memory Management ConceptsEasy
Q4. What is the heap in memory?
- A.Read-only memory that cannot be written to
- B.Identical to the stack memory region exactly
- C.A sorted data structure for priority access
- D.A memory region for dynamic memory allocation✓ Correct
Explanation
The heap is a memory region where dynamically allocated objects reside; memory is allocated and freed in any order.
Report an error in this question
Memory Management ConceptsEasy
Q5. What is a variable's lifetime?
- A.The duration the variable exists in memory✓ Correct
- B.Its declared data type in the program
- C.Its identifier name in the source program
- D.Its accessibility scope in the source code
Explanation
A variable's lifetime is the period from when memory is allocated for it until that memory is deallocated.
Report an error in this question
Memory Management ConceptsEasy
Q6. What is the difference between stack and heap allocation?
- A.Stack is automatic and fast with limited size; heap is larger but slower✓ Correct
- B.Heap allocation is always faster than stack allocation in all scenarios
- C.There is no meaningful difference between the two allocation methods
- D.Stack memory is unlimited while heap memory has a very strict size cap
Explanation
Stack allocation is automatic, fast, and limited; heap allocation is dynamic, larger, but slower and requires explicit deallocation or garbage collection.
Report an error in this question
Memory Management ConceptsEasy
Q7. What is garbage collection?
- A.A sorting algorithm for ordering data values
- B.Deleting files from the disk storage system
- C.Running disk cleanup utilities on the system
- D.Automatic reclamation of unused object memory✓ Correct
Explanation
Garbage collection automatically identifies and frees memory that is no longer referenced by the program.
Report an error in this question
Memory Management ConceptsEasy
Q8. What does 'free()' do in C?
- A.Frees up disk space on the storage drive
- B.Deallocates previously allocated heap memory✓ Correct
- C.Resets a variable back to its default value
- D.Allocates new memory on the heap for use
Explanation
free() releases dynamically allocated memory back to the system.
Report an error in this question
Memory Management ConceptsMedium
Q9. What is the difference between malloc() and calloc() in C?
- A.They are exactly the same function with no differences
- B.malloc initializes all allocated memory bytes to zero
- C.malloc allocates uninitialized; calloc initializes to zero✓ Correct
- D.calloc is always faster than malloc in all scenarios
Explanation
malloc() allocates uninitialized memory; calloc() allocates memory for an array and initializes all bytes to zero.
Report an error in this question
Memory Management ConceptsMedium
Q10. What is a dangling pointer?
- A.A pointer referencing already freed memory✓ Correct
- B.A pointer to a valid live object in memory
- C.A pointer with a null value assigned to it
- D.A smart pointer that manages object lifetime
Explanation
A dangling pointer points to memory that has been freed, leading to undefined behavior if accessed.
Report an error in this question
Memory Management ConceptsEasy
Q11. What is a pointer?
- A.A composite data type definition
- B.A variable storing a memory address✓ Correct
- C.A reusable block of executable code
- D.A variable holding a computed value
Explanation
A pointer holds the memory address of another variable, enabling indirect access to data.
Report an error in this question
Memory Management ConceptsMedium
Q12. What is a buffer overflow?
- A.Slow memory access due to fragmentation issues
- B.Writing data beyond the allocated buffer boundary✓ Correct
- C.Running out of available system memory completely
- D.A type of memory leak from unreleased resources
Explanation
A buffer overflow occurs when data exceeds the buffer's allocated size, overwriting adjacent memory.
Report an error in this question
Memory Management ConceptsEasy
Q13. What is a null pointer?
- A.A pointer to the memory address zero
- B.A pointer that has been deleted already
- C.A pointer to the stack memory region
- D.A pointer to no valid memory location✓ Correct
Explanation
A null pointer holds a special value indicating it does not point to any valid object or memory location.
Report an error in this question
Memory Management ConceptsMedium
Q14. What is reference counting as a garbage collection strategy?
- A.Counting variables in the current scope of code
- B.Tracking reference count and freeing at zero count✓ Correct
- C.A manual memory management technique using counters
- D.Counting the total number of memory blocks allocated
Explanation
Reference counting maintains a count of references to each object; when the count drops to zero, the object is immediately deallocated.
Report an error in this question
Memory Management ConceptsMedium
Q15. What is virtual memory?
- A.Shared memory accessible by multiple processes at once
- B.Cloud storage accessible over the internet network
- C.Using disk space to extend memory beyond physical RAM✓ Correct
- D.Encrypted memory for storing sensitive data securely
Explanation
Virtual memory maps memory addresses to physical RAM or disk, allowing programs to use more memory than physically available.
Report an error in this question
Memory Management ConceptsMedium
Q16. What is memory fragmentation?
- A.Memory that has been encrypted for data security
- B.Memory that has been compressed to save space
- C.Corrupted memory caused by hardware failures in RAM
- D.Free memory broken into small non-contiguous blocks✓ Correct
Explanation
Memory fragmentation occurs when free memory is scattered in small blocks, potentially preventing large contiguous allocations.
Report an error in this question
Memory Management ConceptsMedium
Q17. What is the difference between deep copy and shallow copy regarding memory?
- A.Deep copy allocates new memory for nested objects; shallow copies refs✓ Correct
- B.Shallow copy always uses more memory than deep copy for same structure
- C.There is no difference in memory usage between the two copy methods
- D.Deep copy uses less memory than shallow copy by sharing object refs
Explanation
Shallow copy copies references, sharing memory for nested objects. Deep copy allocates new memory and recursively duplicates all nested objects.
Report an error in this question
Memory Management ConceptsMedium
Q18. What are smart pointers in C++?
- A.Regular raw pointers with no extra features at all
- B.Objects that wrap pointers and manage memory automatically✓ Correct
- C.Pointers that point to function addresses in the program
- D.Pointers that find data faster through optimized algorithms
Explanation
Smart pointers (unique_ptr, shared_ptr, weak_ptr) automatically manage the lifetime of dynamically allocated objects, preventing memory leaks.
Report an error in this question
Memory Management ConceptsMedium
Q19. What is a memory pool?
- A.A pre-allocated block for smaller allocations reducing fragmentation✓ Correct
- B.A collection of physical memory hardware modules
- C.A memory leak caused by unreleased dynamically allocated resources
- D.A type of processor cache that stores frequently accessed data values
Explanation
A memory pool pre-allocates a large block and serves smaller allocation requests from it, reducing fragmentation and overhead.
Report an error in this question
Memory Management ConceptsMedium
Q20. What is the RAII pattern?
- A.A design pattern for building user interfaces
- B.A type of garbage collection used in managed languages
- C.Tying resource lifetime to object lifetime via destructors✓ Correct
- D.A memory allocation algorithm for dynamic memory pools
Explanation
RAII ties resource management to object lifetime: resources are acquired in constructors and released in destructors.
Report an error in this question
Memory Management ConceptsHard
Q21. What is the mark-and-sweep garbage collection algorithm?
- A.Marking files for deletion from the disk system
- B.A disk cleanup algorithm for removing temporary files
- C.A memory allocation method for new object creation
- D.A GC that marks reachable objects then frees unmarked✓ Correct
Explanation
Mark-and-sweep traverses from root references to mark reachable objects, then frees all unmarked objects.
Report an error in this question
Memory Management ConceptsHard
Q22. What is escape analysis in JVM?
- A.Compiler analysis determining if object references escape scope✓ Correct
- B.Network traffic analysis for monitoring data flow patterns
- C.Analyzing program exit codes and termination conditions
- D.Exception analysis for tracking error propagation in code
Explanation
Escape analysis determines if an object is only used within a method; if so, it can be allocated on the stack instead of the heap.
Report an error in this question
Memory Management ConceptsHard
Q23. What is a slab allocator?
- A.A garbage collector that runs periodically in background
- B.A simple wrapper around the standard malloc function call
- C.A disk allocator that manages file system block assignments
- D.A mechanism pre-allocating and caching object-sized blocks✓ Correct
Explanation
A slab allocator pre-allocates memory in slabs of object-sized chunks, reducing fragmentation for frequently created/destroyed objects.
Report an error in this question
Memory Management ConceptsHard
Q24. What is a generational garbage collector?
- A.A manual memory manager without automatic collection
- B.A garbage collector for old legacy programs only
- C.A GC dividing objects by age, collecting young often✓ Correct
- D.A reference counting garbage collection implementation
Explanation
Generational GC exploits the observation that most objects die young, collecting the young generation more frequently for efficiency.
Report an error in this question
Memory Management ConceptsHard
Q25. What is memory-mapped files and how do they work?
- A.Files mapped into virtual address space for memory I/O✓ Correct
- B.Files that have been encrypted for secure data storage
- C.Files that are stored only in volatile RAM memory
- D.Files that have been compressed to save disk space used
Explanation
Memory-mapped files map file contents into the process's virtual address space, enabling efficient I/O by reading/writing memory addresses.
Report an error in this question
Memory Management ConceptsHard
Q26. What is the difference between unique_ptr, shared_ptr, and weak_ptr in C++?
- A.unique_ptr is exclusive; shared_ptr shares; weak_ptr observes only✓ Correct
- B.They are all the same smart pointer type with no differences
- C.shared_ptr cannot be copied or assigned to another shared_ptr var
- D.unique_ptr is always slower than the other two smart pointer types
Explanation
unique_ptr has sole ownership. shared_ptr allows multiple owners via reference counting. weak_ptr observes without preventing deallocation.
Report an error in this question
Memory Management ConceptsHard
Q27. What is the ABA problem in lock-free memory management?
- A.When a location changes A to B to A, making CAS incorrectly succeed✓ Correct
- B.A problem related to the alphabet ordering of values
- C.A variant of buffer overflow caused by writing past array boundaries
- D.A type of memory leak caused by circular reference chains in objects
Explanation
The ABA problem occurs when a value changes A->B->A; CAS sees the original value and succeeds incorrectly.
Report an error in this question
Memory Management ConceptsHard
Q28. What is a write barrier in garbage collection?
- A.A mechanism intercepting pointer writes for GC invariants✓ Correct
- B.A memory protection scheme against buffer overflows
- C.A disk write cache for improving I/O performance
- D.A network firewall for filtering traffic
Explanation
A write barrier intercepts pointer writes to maintain GC data structures, such as recording cross-generation references.
Report an error in this question
Memory Management ConceptsHard
Q29. What is address space layout randomization (ASLR)?
- A.Randomizing process memory addresses to prevent attacks✓ Correct
- B.A memory allocation strategy for dynamic array growth
- C.An addressing mode for accessing hardware registers
- D.A sorting algorithm for ordering memory addresses
Explanation
ASLR randomizes positions of stack, heap, and libraries in a process's address space, making it harder for attackers to predict memory locations.
Report an error in this question
Memory Management ConceptsHard
Q30. What is Copy-on-Write (COW)?
- A.Sharing memory until a write triggers actual copying✓ Correct
- B.Copying files manually between directories on disk
- C.A garbage collection algorithm for reclaiming memory
- D.An error handling technique for runtime exceptions
Explanation
COW defers copying memory until a write occurs; multiple references share the same memory, and a copy is made only when modification happens.
Report an error in this question