Learn C++ MCQs
Prepare C++ MCQs (Multiple choice Questions) for exam and job interviews.
Which of the following is the correct way to declare a pointer to a constant in C++?
1) const int* p;
2) int* const p;
3) Both 1 and 2
4) None of the above
Answer : const int* p;
What is the output of cout << (1 && 0) << endl;
1) 1
2) 0
3) True
4) False
Answer : Option 2
Which of the following is a standard library in C++?
1) iostream
2) iostream.h
3) stdio.h
4) None of the above
Answer : iostream
What will be the output of cout << (true | false) << endl;
1) 1
2) 0
3) true
4) false
Answer : 1
Which of the following is a built-in data type in C++?
1) string
2) int
3) vector
4) list
Answer : int
What is the output of cout << (10 - 3 * 2) << endl;
1) 4
2) 2
3) 8
4) None of the above
Answer : 4
Which of the following can throw an exception in C++?
1) throw
2) try
3) catch
4) None of the above
Answer : throw
What is the output of cout << (5 << 1) << endl;
1) 5
2) 10
3) 2
4) None of the above
Answer : 10
What is the correct way to declare a multi-dimensional array in C++?
1) int arr[3][4];
2) int arr[4][3];
3) Both 1 and 2
4) None of the above
Answer : Both 1 and 2
Which of the following keywords is used to define a template class in C++?
1) template
2) class
3) typename
4) None of the above
Answer : template