Here Are 50 Quizzes / Multiple-Choice Questions Related To
C++
With Correct Answers
1. What is the correct syntax for including the C++ Standard Input/Output library?
a) #include <iostream>
b) #include "iostream"
c) using namespace std;
d) import iostream;
**Answer: a**
2. What is the extension for C++ source code files?
a) .cc
b) .cpp
c) .cxx
d) .h
**Answer: b**
3. In C++, which keyword is used to define a class?
a) struct
, b) class
c) type
d) def
**Answer: b**
4. What is the purpose of the "new" keyword in C++?
a) To create a new instance of a class
b) To allocate memory for a new object
c) To define a new function
d) To include a new header file
**Answer: b**
5. Which operator is used for dynamic_cast in C++?
a) >>
b) ::
c) ->
d) /
**Answer: c**
, 6. Which type of inheritance specifies that a class can have only one parent class?
a) Single Inheritance
b) Multiple Inheritance
c) Hierarchical Inheritance
d) Multilevel Inheritance
**Answer: a**
7. What does the "const" keyword indicate in C++?
a) The variable is initialized at declaration
b) The variable's value cannot be changed after initialization
c) The variable is constant and cannot be used in calculations
d) The variable is used for type casting
**Answer: b**
8. What is the output of the following code?
int x = 5;
cout << (x++) + (++x);
a) 10
b) 11
c) 12
C++
With Correct Answers
1. What is the correct syntax for including the C++ Standard Input/Output library?
a) #include <iostream>
b) #include "iostream"
c) using namespace std;
d) import iostream;
**Answer: a**
2. What is the extension for C++ source code files?
a) .cc
b) .cpp
c) .cxx
d) .h
**Answer: b**
3. In C++, which keyword is used to define a class?
a) struct
, b) class
c) type
d) def
**Answer: b**
4. What is the purpose of the "new" keyword in C++?
a) To create a new instance of a class
b) To allocate memory for a new object
c) To define a new function
d) To include a new header file
**Answer: b**
5. Which operator is used for dynamic_cast in C++?
a) >>
b) ::
c) ->
d) /
**Answer: c**
, 6. Which type of inheritance specifies that a class can have only one parent class?
a) Single Inheritance
b) Multiple Inheritance
c) Hierarchical Inheritance
d) Multilevel Inheritance
**Answer: a**
7. What does the "const" keyword indicate in C++?
a) The variable is initialized at declaration
b) The variable's value cannot be changed after initialization
c) The variable is constant and cannot be used in calculations
d) The variable is used for type casting
**Answer: b**
8. What is the output of the following code?
int x = 5;
cout << (x++) + (++x);
a) 10
b) 11
c) 12