C++ new and delete C++ new and delete Please wait while the activity loads. If this activity does not load, try refreshing your browser. Also, this page requires javascript. Please visit using a browser with javascript enabled. If loading fails, click here to try again Question 1How to create a dynamic array of pointers (to integers) of size 10 using new in C++? Hint: We can create a non-dynamic array using int *arr[10] int *arr = new int *[10]; int **arr = new int *[10]; int *arr = new int [10];Not PossibleC++ new and delete Discuss itQuestion 1-Explanation: Dynamic array of pointer having size 10 using new is created as, int **arr = new int *[10]; So, option (B) is correct.Question 2Which of the following is true about new when compared with malloc. 1) new is an operator, malloc is a function 2) new calls constructor, malloc doesn't 3) new returns appropriate pointer, malloc returns void * and pointer needs to typecast to appropriate type. 1 and 32 and 31 and 2All 1, 2 and 3C++ new and delete Discuss itQuestion 2-Explanation: See malloc() vs newQuestion 3Predict the output? #include <iostream> using namespace std; class Test { int x; Test() { x = 5;} }; int main() { Test *t = new Test; cout << t->x; }Compiler Error5Garbage Value0C++ new and delete Discuss itQuestion 3-Explanation: There is compiler error: Test::Test() is private. new makes call to the constructor. In class Test, constructor is private (note that default access is private in C++). Question 4What happens when delete is used for a NULL pointer? int *ptr = NULL; delete ptr; Compiler ErrorRun-time CrashNo EffectC++ new and delete Discuss itQuestion 4-Explanation: Deleting a null pointer has no effect, so it is not necessary to check for a null pointer before calling delete.Question 5Is it fine to call delete twice for a pointer? #include<iostream> using namespace std; int main() { int *ptr = new int; delete ptr; delete ptr; return 0; }YesNoC++ new and delete Discuss itQuestion 5-Explanation: It is undefined behavior to call delete twice on a pointer. Anything can happen, the program may crash or produce nothing. 1 There are 5 questions to complete. You have completed questions question Your accuracy is Correct Wrong Partial-Credit You have not finished your quiz. If you leave this page, your progress will be lost. Correct Answer You Selected Not Attempted Final Score on Quiz Attempted Questions Correct Attempted Questions Wrong Questions Not Attempted Total Questions on Quiz Question Details Results Date Score Hint Time allowed minutes seconds Time used Answer Choice(s) Selected Question Text Need more practice! Keep trying! Not bad! Good work! Perfect! Last Updated : 28 Sep, 2023 Share your thoughts in the comments Add Your Comment Please Login to comment...