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 AnswerANSWER: 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 Answer3. 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 Answer4. 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 AnswerANSWER: 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 Answer6. Can we allocate memory for the objects dynamically in CPP ?
a. Yes
b. No
View Answer / Hide Answer