Hey Guys , Welcome to CSE Study247, This page provides you with C++ Programming MCQs SET-2 which is useful for Semester and competitive exams.
Q.1 do while loop is called as ?
-
A)
Entry control
-
B)
Exit control
-
C)
Per tested
-
D)
None
Discuss itExplanation
A do-while loop is an exit-controlled loop because it executes the body first and then tests the condition at the end.
Q.2 Which of the following is logical AND Operator?
Discuss itExplanation
In C++, the double ampersand (&&) is the logical AND operator used to combine two boolean expressions.
Q.3 A pure virtual function is a virtual function that?
-
A)
returns nothing
-
B)
has no body
-
C)
is used in base class
-
D)
None
Discuss itExplanation
A pure virtual function is declared in a base class with '= 0' and has no implementation (no body) in that class.
” d=”None” correct=”c” ans=”The square brackets [ ] are the subscript operator, primarily used to access elements of an array.”]
Q.5 A pointer is?
-
A)
address of a variable
-
B)
a variable for storing address
-
C)
Indication of the variable to be accessed next
-
D)
None
Discuss itExplanation
A pointer is a special variable that stores the memory address of another variable rather than a direct value.
Q.6 Which of the following is the address of operator?
Discuss itExplanation
The single ampersand (&) is the address-of operator, used to retrieve the memory address of a variable.
Q.7 Which looping is best used when we know the number of iterations?
-
A)
for loop
-
B)
do while loop
-
C)
while loop
-
D)
None
Discuss itExplanation
A for loop is ideal when the exact number of iterations is known in advance, as it handles initialization, condition, and increment in one line.
Q.8 Which of the following is the scope resolution operator?
Discuss itExplanation
The double colon (::) is the scope resolution operator, used to access global variables or define class members outside the class declaration.
Q.9 A relational operator:
-
A)
Assigns operand to another
-
B)
Compares two operands
-
C)
logically combines two operators
-
D)
None
Discuss itExplanation
Relational operators (like <, >, ==) are used to compare two values and return a boolean result based on their relationship.
Q.10 The library function exit() causes an exit from:
-
A)
Program in which it occurs
-
B)
Function in which it occurs
-
C)
loop in which it occurs
-
D)
None
Discuss itExplanation
The exit() function immediately terminates the entire program and returns control to the operating system.
Q.11 goto is a:
-
A)
variable
-
B)
label
-
C)
operator
-
D)
Function
Discuss itExplanation
The goto statement is a jump statement that transfers control to a location identified by a specific label.
Q.12 What is the other name used for functions inside a class?
-
A)
Member Variables
-
B)
Member Function
-
C)
Class Function
-
D)
None
Discuss itExplanation
Functions that are declared or defined inside a class are officially referred to as Member Functions.
Q.13 if else statement can be replaced by which operator?
-
A)
Bitwise operator
-
B)
Conditional operator
-
C)
logical operator
-
D)
None
Discuss itExplanation
The conditional operator (?:), also known as the ternary operator, can be used as a shorthand for simple if-else statements.
Q.14 Which of the following cannot be a friend?
-
A)
Function
-
B)
Class
-
C)
Object
-
D)
Operator Function
Discuss itExplanation
In C++, functions and classes can be declared as friends to access private members, but a specific instance (object) cannot.
Q.15 How many types of polymorphism are there in C++?
Discuss itExplanation
There are two main types of polymorphism in C++: Compile-time (static) and Run-time (dynamic) polymorphism.
Q.16 How compile time polymorphism is implemented in C++?
-
A)
using inheritance
-
B)
using Templates
-
C)
using virtual function
-
D)
None
Discuss itExplanation
Compile-time polymorphism is achieved using function/operator overloading and templates.
Q.17 Which members are inherited but not accessible in any case?
-
A)
Private
-
B)
Protected
-
C)
Both A & B
-
D)
None
Discuss itExplanation
Private members of a base class are inherited by the derived class, but they are not directly accessible by that derived class.
”Q.18
-
A)
”cout”
-
B)
”cin”
-
C)
”print”
-
D)
”None”
Q.19 C++ uses:
-
A)
Top-Down approach
-
B)
Bottom-up approach
-
C)
Left-left
-
D)
Right-Right
Discuss itExplanation
C++ is an Object-Oriented Programming language and follows a bottom-up design approach for program development.
Q.20 Which of the following class allows to declare only one object of it?
-
A)
Abstract class
-
B)
Virtual class
-
C)
Singleton class
-
D)
None
Discuss itExplanation
A Singleton class is a design pattern that restricts the instantiation of a class to a single object.