C++ Programming Multiple Choice Questions & Answers (MCQs) on “C++ Concepts – 1”.
1. Which of the following is not a fundamental type is not present in C but present in C++?
a) int
b) float
c) bool
d) void
Answer: c
Clarification: Boolean type is not present as a fundamental type in C. int type is used as boolean in C whereas in C++ bool is defined as a fundamental type for handling boolean outputs.
2. What is the size of a boolean variable in C++?
a) 1 bit
b) 1 byte
c) 4 bytes
d) 2 bytes
Answer: a
Clarification: Boolean uses only 1 bit as it stores only truth values which can be true(1) or false(0).
3. Which of the following is C++ equivalent for scanf()?
a) cin
b) cout
c) print
d) input
Answer: a
Clarification: C++ uses cin to read input form uses. However C++ also uses scanf().
4. Which of the following is C++ equivalent for printf()?
a) cin
b) cout
c) print
d) input
Answer: b
Clarification: C++ uses cout to print output to console. However C++ also uses printf().
5. Which of the following is the correct difference between cin and scanf()?
a) both are the same
b) cin is a stream object whereas scanf() is a function
c) scanf() is a stream object whereas cin is a function
d) cin is used for printing whereas scanf() is used for reading input
Answer: b
Clarification: cin is a stream object available in C++ whereas scanf() is a function available in both C and C++. both are used for reading input from users.
6. Which of the following is an exit-controlled loop?
a) for
b) while
c) do-while
d) all of the mentioned
Answer: c
Clarification: do-while is called exit controlled loop because in do-while termination condition is checked when we have executed the body of the loop i.e. we are exiting the body and then checking the condition, therefore, it is called exit controlled loop.
7. Which of the following is an entry-controlled loop?
a) for
b) while
c) do-while
d) both while and for
Answer: d
Clarification: Both while and for loops are called entry controlled loop because in both of them the termination condition is checked before we enter the body of the loop hence they are called entry controlled loop.
8. In which part of the for loop termination condition is checked?
for(I;II;III)
{IV}
a) I
b) II
c) III
d) IV
Answer: b
Clarification: In II part the termination condition of the for loop is checked.
9. What is dynamic binding?
a) The process of linking the actual code with a procedural call during run-time
b) The process of linking the actual code with a procedural call during compile-time
c) The process of linking the actual code with a procedural call at any-time
d) All of the mentioned
Answer: a
Clarification: Binding of calls and variables with actual code at run-time is called dynamic binding. For example in the concept of polymorphism types are decided are defined during the execution of code which leads to the different function calls depending upon the types used this is called dynamic binding. As the function call is decided during the run-time therefore dynamic binding happens at run-time.
10. What is static binding?
a) The process of linking the actual code with a procedural call during run-time
b) The process of linking the actual code with a procedural call during compile-time
c) The process of linking the actual code with a procedural call at any-time
d) All of the mentioned
