C++ MCQ Questions and Answers – Part 4
Multiple choice questions and answers (MCQs) on C++ to prepare for exams, tests, and certifications. These questions are taken from a real written exam and some parts are taken from an interview. So you will find questions on basic techniques such as Variables, Operators, Conditional Statement, Functions, and more. This quiz will easily prepare anyone to pass their online test.
1. What happens if the line below is executed in C and C++?
int *ptr = malloc(20);
A Error in C and C++
B Warning in C and C++
C Error in C++ and success in C
D Error in C and success in C++
2. What is a dynamic binding?
A The process of binding the current code to a procedure call at runtime.
B The process of linking the actual code to a procedure call during compilation.
C Process of linking the current code to a procedure call at any time.
D All the answers are true
[st_adsense]
3. What is a static binding?
A The process of binding the current code to a procedure call at runtime.
B The process of linking the actual code to a procedure call during compilation.
C Process of linking the current code to a procedure call at any time.
D All the answers are true
4. What happens if the line below is executed in C and C++?
const int x;
A Error in C and C++
B Warning in C and C++
C Error in C++ and success in C
D Error in C and success in C++
5. What is the output of the following C++ code?
#include <iostream> using namespace std; int main() { cout << sizeof('a') << endl; cout << sizeof(char); return 0; }
A 1 4
B 1 1
C 4 1
D Error
[st_adsense]
6. Which of the following is the scope resolution operator?
A ~
B ::
C *
D .
7. What is the output of the following C++ code?
#include<iostream> using namespace std; int arr[50]; int main() { cout << arr[49] << endl; }
A Random value
B 49
C 0
D Error
8. Which of the following is accessed by a member function of a class?
A The object of this class
B Public part of the class
C Private part of the class
D All members of the class
[st_adsense]
9. What is the size of a character in C and C++?
A 4 et 1
B 1 et 4
C 1 et 1
D 4 et 4
10. What happens if the line below is executed in C and C++?
#include <stdio.h> int main(void) { int new = 10; printf("%d", new); }
A Error in C and C++
B Warning in C and C++
C Error in C++ and success in C
D Error in C and success in C++
[st_adsense]