Skip to main content

Memory Management

1).What is dynamic memory allocation in C++?

1) Allocating memory during runtime
2) Allocating memory during compile time
3) Using static memory
4) None of the above

2).Which operator is used for dynamic memory allocation?

1) new
2) malloc
3) allocate
4) None of the above

3).Which operator is used to deallocate memory in C++?

1) delete
2) free
3) dispose
4) None of the above

4).What is a memory leak?

1) Memory that is not deallocated
2) Memory allocated at compile time
3) Excessive memory usage
4) None of the above

5).What is a smart pointer?

1) A pointer that automatically manages memory
2) A pointer that points to other pointers
3) A pointer that only works with arrays
4) None of the above

6).What does the new operator return?

1) A pointer to the allocated memory
2) The size of allocated memory
3) The address of the deallocated memory
4) None of the above

7).What is the difference between malloc and new?

1) malloc is procedural, new is object-oriented
2) malloc does not call constructors
3) Both A and B
4) None of the above

8).What happens if delete is used on NULL?

1) No operation is performed
2) It causes a segmentation fault
3) It deallocates NULL
4) None of the above

9).Which smart pointer type prevents cyclic references?

1) weak_ptr
2) shared_ptr
3) unique_ptr
4) None of the above

10).What is the purpose of the delete[] operator?

1) To deallocate memory allocated for arrays
2) To deallocate static memory
3) To deallocate class objects
4) None of the above