C-Plus-Plus QuestionsBy Kritika Papne / March 21, 2023 0 votes, 0 avg 233 123456789101112131415 C-Plus-Plus Questions 1 / 15 1. By which of the following can the if-else statement be replaced? A. bitwise operator B. logical operator C. conditional operator D. arithmetic operator 2 / 15 2. 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 3 / 15 3. 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 4 / 15 4. What is the output of this C++ program in the “test.txt” file? #include using namespace std; int main () { long pos; ofstream outfile; outfile.open ("test.txt"); outfile.write ("This is an apple",16); pos = outfile.tellp(); outfile.seekp (pos - 7); outfile.write (" sam", 4); outfile.close(); return 0; } A. This is an apple B. apple C. sample D. This is a sample 5 / 15 5. What will be the output of the following C++ code? #include using namespace std; void square (int *x, int *y) { *x = (*x) * --(*y); } int main ( ) { int number = 30; square(&number, &number); cout << number; return 0; } A. 30 B. Error C. Segmentation fault D. 870 6 / 15 6. 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 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. What will be the output of the following C++ code? #include using namespace std; int main() { int a = 5; float b; cout << sizeof(++a + b); cout << a; return 0; } A. 2 5 B. 4 5 C. 4 6 D. 2 6 9 / 15 9. Which of the following constructors are provided by the C++ compiler if not defined in a class? A. Copy constructor B. Default constructor C. Assignment constructor D. All of the mentioned 10 / 15 10. 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 11 / 15 11. Which of the following is not a type of inheritance? A. Multiple B. Multilevel C. Distributed D. Heirarchical 12 / 15 12. 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 13 / 15 13. Which of the following options correctly explains the concept of Polymorphism? A. int func(float); float func(int, int, char); B. int func(int); int func(int); C. int func(int, int); float func1(float, float); D. None of the above 14 / 15 14. Find the output of below program. int main() { for(int i=1;i<=2;i++) { for(int j=i;j<=2;j++) cout< A. 1@2@ B. 1@2@1@ C. 1@1@2@ D. 1@2@2@ 15 / 15 15. Which of the following is used for comments in C++? A. /* comment */ B. // comment */ C. // comment D. both // comment or /* comment */ 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