Memory Management - placement practice test

Memory Management - placement practice test


1. During dynamic memory allocation in CPP, new operator returns__________ value if memory allocation is unsuccessful.

a. False
b. NULL
c. Zero
d. None of these
View Answer / Hide Answer

ANSWER: b. NULL




2. Which of the following operator is used to release the dynamically allocated memory in CPP?

a. remove
b. free
c. delete
d. both b and c
View Answer / Hide Answer

ANSWER: c. delete




3. Which of the following is/are valid ways to allocate memory for an integer by dynamic memory allocation in CPP?

a. int *p = new int(100);
b. int *p; p = new int; *p = 100;
c. int *p = NULL; p = new int; *p=100;
d. Only 1,2
e. All of these
View Answer / Hide Answer

ANSWER: e. All of these




4. Which of the following is not a false statement about new operator?

a. It can’t be overloaded
b. It returns garbage value when memory allocation fails
c. It automatically computes the size of the data object
d. All of these
View Answer / Hide Answer

ANSWER: c. It automatically computes the size of the data object




5. In CPP, dynamic memory allocation is done using ______________ operator

a. calloc()
b. malloc()
c. allocate
d. new
View Answer / Hide Answer

ANSWER: d. new




6. Can we allocate memory for the objects dynamically in CPP ?

a. Yes
b. No
View Answer / Hide Answer

ANSWER: a. Yes



Post your comment