C++ Quiz C++ Quiz 1 / 20What is the difference between struct and class in C++? "struct" members are public by default, while "class" members are private by default. "struct" members are private by default, while "class" members are public by default. There is no difference. "struct" cannot have member functions, while "class" can. 2 / 20Which of the following is the correct way to declare a pointer to an integer in C++? int p; int* p; int& p; int p*; 3 / 20What is the output of the following code?int a = 5;int b = 10;std::cout << (a + b) << std::endl;click on extem for view full code 15 510 5 10 4 / 20Which of the following operators cannot be overloaded in C++? + * = :: 5 / 20What is a correct way to allocate memory dynamically for an array of 10 integers? int* array = new int(10); int* array = new int[10]; int* array = malloc(10 * sizeof(int)); int array[10]; 6 / 20Which of the following is not a valid C++ data type? int float bool real 7 / 20What does the keyword virtual signify in a method declaration? The method can be called without an object. The method can be overridden in derived classes. The method is a static method. The method is abstract. 8 / 20What is the use of the friend keyword in C++? To define a method that can be called without an object. To allow a function or another class to access private or protected members of the class. To declare a global function. To create a function template. 9 / 20int x = 5;int& ref = x;ref = 10;std::cout << x << std::endl;Click on Extem for view full code 5 10 0 Error 10 / 20Which of the following is the correct syntax to define a template class? template class MyClass {} template class MyClass {} template class MyClass {} template MyClass {} 11 / 20What does RAII stand for in C++? Resource Acquisition Is Initialization Resource Allocation Is Initialization Resource Acquisition Is Implementation Resource Allocation Is Implementation 12 / 20Which of the following is not a valid C++11 feature? Lambda expressions Range-based for loops nullptr Import statements 13 / 20What is the purpose of the std::move function in C++11? To perform a deep copy of an object. To convert an l-value to an r-value reference. To copy an object. To swap two objects. 14 / 20What is a lambda expression in C++? An anonymous function object. A preprocessor directive. A type of template. A pointer to a function. 15 / 20What is the output of the following code?#include <iostream>void func(int a, int b = 20) { std::cout << a << " " << b << std::endl;}int main() { func(10); return 0;}Click on Extem for view full code 10 10 10 20 20 10 Error 16 / 20Which of the following is true about constructors in C++? Constructors cannot be overloaded. Constructors must have a return type. Constructors are called automatically when an object is created. Constructors can only be defined in the public section of a class. 17 / 20Which of the following is a correct statement about destructors in C++? Destructors can be overloaded. Destructors must have a return type. Destructors are called automatically when an object goes out of scope. Destructors can take arguments. 18 / 20What does the override keyword indicate in C++11? That a function is a pure virtual function. That a function is intended to override a base class function. That a function is static. That a function is inline. 19 / 20What is the difference between delete and delete[]? "delete" is used for single objects, delete[] is used for arrays. "delete" is used for arrays, delete[] is used for single objects. "delete" calls destructors, delete[] does not. There is no difference. 20 / 20Which of the following is a valid C++11 range-based for loop? for (int i : array) {} for (int i = 0; i < n; ++i) {} for (int i in array) {} for each (int i in array) {} Your score isThe average score is 55% 0% Restart quiz