InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
Which of the following functions allocates multiple blocks of memory, each block of the same size?(a) malloc()(b) realloc()(c) calloc()(d) free()I had been asked this question in a job interview.My question is from DMA Functions, Memory Leak, Dangling Pointers in section Dynamic Memory Allocation in C of C |
|
Answer» Correct option is (c) calloc() |
|
| 2. |
In the function malloc(), each byte of allocated space is initialized to zero.(a) True(b) FalseI got this question by my school teacher while I was bunking the class.This intriguing question comes from DMA Functions, Memory Leak, Dangling Pointers topic in portion Dynamic Memory Allocation in C of C |
|
Answer» The correct OPTION is (b) False |
|
| 3. |
Choose the statement which is incorrect with respect to dynamic memory allocation.(a) Memory is allocated in a less structured area of memory, known as heap(b) Used for unpredictable memory requirements(c) Execution of the program is faster than that of static memory allocation(d) Allocated memory can be changed during the run time of the program based on the requirement of the programI have been asked this question during an online exam.This question is from Static vs Dynamic Memory Allocation in section Dynamic Memory Allocation in C of C |
|
Answer» The correct answer is (c) Execution of the PROGRAM is faster than that of STATIC memory ALLOCATION |
|
| 4. |
Garbage collector frees the programmer from worrying about ___________(a) Dangling pointers(b) Creating new objects(c) Memory leak(d) Segmentation errorsThe question was posed to me in an online quiz.Origin of the question is DMA Functions, Memory Leak, Dangling Pointers topic in division Dynamic Memory Allocation in C of C |
|
Answer» The correct answer is (c) MEMORY leak |
|
| 5. |
Which of the following is an example of static memory allocation?(a) Linked list(b) Stack(c) Queue(d) ArrayThis question was posed to me in class test.My doubt stems from Static vs Dynamic Memory Allocation in division Dynamic Memory Allocation in C of C |
|
Answer» Correct ANSWER is (d) Array |
|
| 6. |
Local variables are stored in an area called ___________(a) Heap(b) Permanent storage area(c) Free memory(d) StackThis question was addressed to me in an interview for internship.The above asked question is from Static vs Dynamic Memory Allocation topic in chapter Dynamic Memory Allocation in C of C |
|
Answer» The correct answer is (d) Stack |
|
| 7. |
The incorrect statement with respect to dangling pointers is ___________(a) Pointer pointing to non-existent memory location is called dangling pointer(b) When a dynamically allocated pointer references the original memory after it has been freed, a dangling pointer arises(c) If memory leak occurs, it is mandatory that a dangling pointer arises(d) Dangling pointer may result in segmentation faults and potential security risksThe question was posed to me in homework.I'm obligated to ask this question of DMA Functions, Memory Leak, Dangling Pointers topic in chapter Dynamic Memory Allocation in C of C |
|
Answer» The CORRECT option is (C) If memory leak occurs, it is mandatory that a dangling pointer arises |
|
| 8. |
Array is preferred over linked list for the implementation of ________(a) Radix sort(b) Insertion sort(c) Binary search(d) Polynomial evaluationThe question was posed to me in an online quiz.My question is based upon Static vs Dynamic Memory Allocation in chapter Dynamic Memory Allocation in C of C |
|
Answer» The correct ANSWER is (c) Binary search |
|
| 9. |
The number of arguments taken as input which allocating memory dynamically using malloc() is ___________(a) 0(b) 1(c) 2(d) 3This question was posed to me in an internship interview.The question is from DMA Functions, Memory Leak, Dangling Pointers topic in portion Dynamic Memory Allocation in C of C |
|
Answer» Correct choice is (B) 1 |
|
| 10. |
In the function realloc(), if the new size of the memory block is larger than the old size, then the added memory ___________(a) is initialized to junk values(b) is initialized to zero(c) results in an error(d) is not initializedI got this question in an online quiz.My doubt stems from DMA Functions, Memory Leak, Dangling Pointers topic in portion Dynamic Memory Allocation in C of C |
|
Answer» Correct answer is (d) is not initialized |
|
| 11. |
A condition where in memory is reserved dynamically but not accessible to any of the programs is called _____________(a) Memory leak(b) Dangling pointer(c) Frozen memory(d) Pointer leakI have been asked this question in examination.I'm obligated to ask this question of DMA Functions, Memory Leak, Dangling Pointers topic in chapter Dynamic Memory Allocation in C of C |
|
Answer» The CORRECT option is (a) MEMORY leak |
|
| 12. |
Queue data structure works on the principle of ____________(a) Last In First Out (LIF0)(b) First In Last Out (FILO)(c) First In First Out (FIFO)(d) Last In Last Out (LILO)This question was addressed to me in semester exam.My question is based upon Static vs Dynamic Memory Allocation topic in section Dynamic Memory Allocation in C of C |
|
Answer» Right option is (c) FIRST In First Out (FIFO) |
|
| 13. |
Which of the following is an example for non linear data type?(a) Tree(b) Array(c) Linked list(d) QueueThis question was posed to me in an online interview.This is a very interesting question from Static vs Dynamic Memory Allocation in division Dynamic Memory Allocation in C of C |
|
Answer» Correct option is (a) Tree |
|
| 14. |
Which of the following header files must necessarily be included to use dynamic memory allocation functions?(a) stdlib.h(b) stdio.h(c) memory.h(d) dos.hI had been asked this question in an online interview.The origin of the question is Static vs Dynamic Memory Allocation topic in portion Dynamic Memory Allocation in C of C |
|
Answer» CORRECT answer is (a) stdlib.h Easiest explanation - stdlib.h is a header FILE which stands for the standard library. It consists of the declaration for dynamic memory allocation functions such as MALLOC(), CALLOC(), realloc() and free. |
|
| 15. |
The type of linked list in which the node does not contain any pointer or reference to the previous node is _____________(a) Circularly singly linked list(b) Singly linked list(c) Circular doubly linked list(d) Doubly linked listI have been asked this question in an interview.The doubt is from Static vs Dynamic Memory Allocation in chapter Dynamic Memory Allocation in C of C |
|
Answer» RIGHT choice is (b) Singly LINKED list The BEST I can explain: A singly linked list is one in which each node has two fields, namely DATA field and pointer field. Data field stores the data and the pointer field points to the address of the next node. |
|
| 16. |
The size of both stack and heap remains the same during run time.(a) True(b) FalseThis question was addressed to me by my college director while I was bunking the class.The doubt is from Static vs Dynamic Memory Allocation in portion Dynamic Memory Allocation in C of C |
|
Answer» The correct option is (B) False |
|