C-Plus-Plus QuestionsBy Kritika Papne / March 21, 2023 0 votes, 0 avg 244 123456789101112131415 C-Plus-Plus Questions 1 / 15 1. Observer the given C++ program carefully and choose the correct output from the given options: #include #include using namespace std; int main() { cout<::value; // case A cout<::value; // case B cout<::value; // case c return 0; } A. 11O B. OO1 C. O1O D. none of the above 2 / 15 2. what will be the output of the following C++ code snippet? #include using namespace std; class X { public: X() { cout<<"X"; } ~X() { cout<<"~X"; } }; class Y : public X { public: Y() { cout<<"Y"; } ~Y() { cout<<"~Y"; } }; int main() { Y obj; return 0; } A. XY~X~Y B. XY~Y~X C. X~XY~Y D. X~X~YY 3 / 15 3. What will be the output of the following C++ code? #include using namespace std; template int arrMin(T arr[], int n) { int m = max; for (int i = 0; i < n; i++) if (arr[i] < m) m = arr[i]; return m; } int main() { int arr1[] = {10, 20, 15, 12}; int n1 = sizeof(arr1)/sizeof(arr1[0]); char arr2[] = {1, 2, 3}; int n2 = sizeof(arr2)/sizeof(arr2[0]); cout << arrMin(arr1, n1) << endl; cout << arrMin(arr2, n2); return 0; } A. 10 1 B. 12 2 C. 10000 256 D. Error 4 / 15 4. What will be the output of the following C++ code? #include using namespace std; int gcd (int a, int b) { int temp; while (b != 0) { temp = a % b; a = b; b = temp; } return(a); } int main () { int x = 15, y = 25; cout << gcd(x, y); return(0); } A. 15 B. 25 C. 375 D. 5 5 / 15 5. What is dangling pointer? A. A pointer pointing to NULL B. Pointer pointing to memory location which has been freed C. Pointer which is pointing to new location D. None of these 6 / 15 6. How can one implement the run-time Polymorphism in the C++ programming language? A. By using the Template B. By using the concepts of inheritance C. By using both the virtual functions and inheritance D. By using only the virtual functions 7 / 15 7. Which part of memory is used for the allocation of local variables declared inside any function. A. Heap B. Address Space C. Stack D. Depends on Compiler 8 / 15 8. Pick the incorrect statement about Character-Array. A. Character-Array can be terminated by a null character(‘ ’) B. Character-Array has a static size C. Character-Array has a dynamic size D. Character-Array has a threat of array-decay 9 / 15 9. What will be the output of the following C++ code snippet? #include #include using namespace std; int main () { int array[] = {0, 2, 4, 6, 7, 5, 3}; int n, result = 0; for (n = 0; n < 8; n++) { result += array[n]; } cout << result; return 0; } A. 21 B. 27 C. 26 D. 25 10 / 15 10. dentify the correct definition of ‘*’ operator in pointer. A. Address of operator B. value of address operator C. multiplication operator D. all of the above 11 / 15 11. Which of the following statements is correct about the formal parameters in C++? A. Parameters with which functions are called B. Parameters which are used in the definition of the function C. Variables other than passed parameters in a function D. Variables that are never used in the function 12 / 15 12. What is the output of the given program? #include < stdio.h > using namespace std; int main() { int array[] = {10, 20, 30}; cout << -2[array]; return 0; } A. -30 B. -15 C. garbage value D. compiler error 13 / 15 13. What will be the output of the following C++ code? #include #include using namespace std; int main() { cout<::type>::value; cout<::type>::value; return 0; } A. 11 B. 12 C. 21 D. 22 14 / 15 14. Consider the following given program and choose the most appropriate output from the given options: #include using namespace std; class A{ public: A(){ cout<<"Constructor calledn"; } ~A(){ cout<<"Destructor calledn"; } }; int main(int argc, char const *argv[]) { A *a = new A[5]; delete[] a; return 0; } A. Segmentation Failure B. Error C. The Constructor will be invoked five times, and after that destructor will be invoked only once. D. The Constructor will be invoked five times, and after that destructor will also be invoked five times. 15 / 15 15. The correct statement for a function that takes pointer to a float, a pointer to a pointer to a char and returns a pointer to a pointer to a integer is ____________ A. int **fun(float**, char**) B. int *fun(float*, char*) C. int **fun(float*, char**) D. int ***fun(*float, **char) Your score isThe average score is 32% LinkedIn Facebook VKontakte 0% Restart quiz By WordPress Quiz plugin Written by Shubhranshu Shekhar, who has trained 20000+ students in coding. Kritika Papne