Garbage collection MCQsBy: Prof. Dr. Fazal Rehman | Last updated: May 14, 2025 35 Score: 0 Attempted: 0/35 Subscribe 1. : What is garbage collection? (A) The process of cleaning up unused memory (B) A method to allocate memory (C) A way to optimize CPU usage (D) A technique for data encryption 2. : Which of the following languages primarily uses garbage collection? (A) C (B) C++ (C) Java (D) Assembly 3. : What is the main purpose of garbage collection? (A) To speed up the program execution (B) To free up memory automatically (C) To enhance CPU performance (D) To improve code readability 4. : Which of the following is NOT a type of garbage collection? (A) Mark-and-sweep (B) Reference counting (C) Memory pooling (D) Generational garbage collection 5. : In the mark-and-sweep algorithm, what is the first step? (A) Sweep the memory (B) Mark reachable objects (C) Free memory (D) Allocate new memory 6. : What does reference counting do? (A) Tracks the number of references to an object (B) Counts the number of objects in memory (C) Allocates memory for new objects (D) Marks objects for deletion 7. : What happens when an object’s reference count reaches zero? (A) The object is retained in memory (B) The object is marked for garbage collection (C) The object is immediately deleted (D) The program crashes 8. : Which garbage collection method involves dividing memory into generations? (A) Mark-and-sweep (B) Generational garbage collection (C) Reference counting (D) Tracing garbage collection 9. : In garbage collection, what does the term “root set” refer to? (A) The list of objects to be collected (B) The references that are accessible directly (C) The memory allocated for new objects (D) The total memory usage of a program 10. : Which of the following can cause memory leaks? (A) Properly implemented garbage collection (B) Circular references in objects (C) Manual memory management (D) Generational garbage collection 11. : What is a common drawback of garbage collection? (A) Increased performance (B) Automatic memory management (C) Non-deterministic timing of collection (D) Reduces memory consumption 12. : What does “stop-the-world” mean in the context of garbage collection? (A) The program crashes (B) All application threads are paused (C) The garbage collector runs in parallel (D) No memory is allocated 13. : What is the role of a garbage collector in a programming language? (A) To compile code (B) To manage memory allocation and deallocation (C) To optimize CPU usage (D) To execute user-defined functions 14. : Which of the following is a characteristic of the mark-and-sweep algorithm? (A) It is non-intrusive (B) It uses reference counting (C) It can lead to fragmentation (D) It requires constant memory 15. : How does a tracing garbage collector work? (A) It counts object references (B) It marks and sweeps objects (C) It identifies unreachable objects by traversing reachable ones (D) It allocates memory for new objects 16. : What is a potential advantage of using garbage collection? (A) Manual memory management (B) Reduced programmer workload (C) Increased application complexity (D) Guaranteed performance 17. : Which algorithm is primarily used in languages like C# for garbage collection? (A) Mark-and-sweep (B) Reference counting (C) Generational garbage collection (D) Stop-and-copy 18. : What is the main limitation of reference counting? (A) It is too complex to implement (B) It cannot handle cyclic references (C) It requires a lot of memory (D) It is slower than mark-and-sweep 19. : Which of the following is a sign of a memory leak? (A) Consistent memory usage (B) Increasing memory usage over time (C) Decreased performance (D) Program crashing 20. : What is the purpose of garbage collection in Java? (A) To manage CPU resources (B) To optimize I/O operations (C) To reclaim memory automatically (D) To improve execution speed 21. : What does the term “finalization” mean in garbage collection? (A) The process of permanently deleting an object (B) The action taken before an object is collected (C) The allocation of memory for a new object (D) The marking of reachable objects 22. : Which of the following can improve the efficiency of garbage collection? (A) Increasing object lifetime (B) Reducing object creation (C) Frequent collection cycles (D) Allocating more memory 23. : What is “heap fragmentation”? (A) A condition where free memory is scattered (B) The process of merging free memory blocks (C) Memory allocated for temporary objects (D) A type of memory leak 24. : In what scenario is garbage collection typically invoked? (A) When the program is running smoothly (B) When memory usage exceeds a certain threshold (C) At the beginning of program execution (D) Every time a variable is created 25. : What is the main challenge with automatic garbage collection? (A) It is too fast (B) It can introduce latency during program execution (C) It uses too much memory (D) It simplifies memory management 26. : How can developers help minimize garbage collection overhead? (A) Use more global variables (B) Create fewer temporary objects (C) Use static variables (D) Increase the size of the heap 27. : Which method is NOT a part of garbage collection in Java? (A) System.gc() (B) Runtime.getRuntime().gc() (C) free() (D) finalize() 28. : What happens if garbage collection is disabled in a language that relies on it? (A) The program will not compile (B) The program will crash immediately (C) Memory leaks will occur (D) The performance will improve 29. : What is the role of a “garbage collector” in a virtual machine? (A) To execute bytecode (B) To allocate memory (C) To manage memory cleanup (D) To compile source code 30. : Which technique does not rely on a garbage collector? (A) Manual memory management (B) Mark-and-sweep (C) Reference counting (D) Generational garbage collection 31. : Which garbage collection algorithm can lead to pauses in application execution? (A) Concurrent garbage collection (B) Incremental garbage collection (C) Stop-the-world garbage collection (D) Lazy garbage collection 32. : What is “concurrent garbage collection”? (A) Collection that happens during program execution (B) Collection that runs after program execution (C) Collection that requires all threads to stop (D) Collection that is only performed on the heap 33. : What is a significant benefit of generational garbage collection? (A) It minimizes memory fragmentation (B) It avoids all memory leaks (C) It assumes most objects die young (D) It eliminates the need for manual memory management 34. : In which scenario is manual garbage collection preferable? (A) When performance is critical (B) When working with low-level system programming (C) In high-level programming languages (D) When memory allocation is infrequent 35. : What does “tracing” in garbage collection refer to? (A) Counting references (B) Identifying reachable objects (C) Tracking memory allocation (D) Freeing unused memory Data Structures MCQs Basic Concepts Introduction to Data Structures Abstract Data Types (ADT) MCQs Complexity Analysis MCQs Time complexity MCQs Space complexity MCQs Big O, Big Ω, Big Θ notations MCQs Linear Data Structures MCQs Arrays MCQs One-dimensional arrays MCQs Multi-dimensional arrays MCQs Operations: traversal, insertion, deletion MCQs Linked Lists MCQs Singly linked list MCQs Doubly linked list MCQs Circular linked list MCQs Stacks MCQs Stack operations (push, pop, peek) MCQs Applications of stacks (expression evaluation, recursion) MCQs Queues MCQs Queue operations (enqueue, dequeue, front, rear) MCQs Types: Simple queue, circular queue, priority queue, deque MCQs Non-Linear Data Structures MCQs Trees MCQs Binary trees MCQs Binary Search Trees (BST) MCQs AVL Trees MCQs B-trees and B+ trees MCQs Tree traversal methods (in-order, pre-order, post-order) MCQs Heaps MCQs Min-heap MCQs Max-heap MCQs Heap operations (insertion, deletion, heapify) MCQs Applications of heaps (priority queues, heap sort) MCQs Graphs MCQs Graph representation (adjacency matrix, adjacency list) MCQs Graph traversal algorithms (DFS, BFS) MCQs Shortest path algorithms (Dijkstra’s, Bellman-Ford) MCQs Minimum Spanning Tree (Kruskal’s, Prim’s) MCQs Hashing MCQs MCQs Hash Tables Hash functions MCQs Collision resolution techniques (chaining, open addressing) MCQs Applications of hashing MCQs Sorting and Searching Algorithms MCQs Sorting Algorithms MCQs Bubble sort MCQs Selection sort MCQs Insertion sort MCQs Merge sort MCQs Quick sort MCQs Heap sort MCQs Searching Algorithms MCQs Linear search MCQs Binary search MCQs Interpolation search MCQs Miscellaneous Memory Management in data structures MCQs Dynamic memory allocation MCQs Garbage collection MCQs String Manipulation Algorithms MCQs Pattern matching (KMP, Rabin-Karp) MCQs String hashing MCQs Data Structures MCQs 1 Data Structures MCQs 2 Data Structures MCQs 3 Data Structures MCQs 4 Data Structures MCQs 5 Stacks Solved MCQs Queues MCQs pointer mcqs Array MCQs Related Posts:Dynamic memory allocation and garbage collection(MCQs)MCQs Collection for All Subjects Data collection and analysis in GIS MCQsData collection and analysis in the field MCQsPast Papers Collection Developmentnetworking MCQs, storage solutions, cloud computing MCQs, data center technologies MCQs.