MCQ Bank
Which is not a preprocessor directive of C-language?
- A) #startif
- B) #else
- C) #endif
- D) #if
What will happen if the outer if condition in a nested if statement is false?
- A) The program skips the entire block
- B) It causes a syntax error
- C) The inner if is still checked
- D) Only the else block of the inner if is executed
Macro is defined by ____________ preprocessor directive.
- A) #define
- B) #endif
- C) #if
- D) #else
___________ is a useful statement when at a certain stage you do not want to execute the remaining statements inside the loop and want to go to the first statement of loop.
- A) Break
- B) Goto
- C) Continue
- D) Default
What would be the output of the following statement? c = 13 % 2;
- A) 2
- B) 1
- C) 3
- D) 0
What is the purpose of using && in an if condition?
- A) To combine two conditions where both must be true
- B) To combine two conditions where at least one must be true
- C) To end the if block
- D) To check equality
Which of the following is not true about Destructor?
- A) Destructors don’t return a value.
- B) Destructors cannot be used for memory manipulation.
- C) Destructors take no arguments
- D) Destructors cannot be overloaded.
In function overloading, how does the compiler differentiate between overloaded functions?
- A) By looking at the number and types of parameters
- B) By checking the return type of the function
- C) By looking at the function names
- D) By checking the function visibility (public/private)
A constructor with arguments is known as.
- A) Destructor
- B) Default Constructor
- C) Virtual Constructor
- D) Paramterized Constructor
What will be the output of the following code? void sampleFunction(int = 5,float = 4.1, char = 'A'); int main(){ sampleFunction(50,3.2); } void sampleFunction(int one,float two ,char three) { cout << one << ", " << two << ", " << three; }
- A) 50, 4.1, A
- B) 50, 3.2, A
- C) 5, 3.2, A
- D) 5, 4.1, A
Which of the following is a correct example of function overloading in C++?
- A) int sqrt(int i); double sqrt(double i);
- B) double sqrt(int i); float sqrt(int i);
- C) int sqrt(int i); double sqrt(int i);
- D) int sqrt(int i); int sqrt(double i);
_________ is a user-defined data type.
- A) Pointer
- B) Function
- C) Constructor
- D) Class
In C++, the name of the _________ is the same as that of a class with a preceding tilde (~) sign.
- A) Utility function
- B) Friend function
- C) Constructor
- D) Destructor
In C++, which of the following option is used to declare a class?
- A) Class
- B) CLASS
- C) class
- D) cLAss
In C++, which operator is used to access the data members of the class?
- A) Not
- B) Dot
- C) And
- D) Plus
Which function is automatically called when an object of a class is initiated?
- A) Friend function
- B) Destructor
- C) Utility function
- D) Constructor
Which function is automatically called in C++ if we do not define it in a class?
- A) Default and Parametrized Constructor
- B) Inline function
- C) Parametrized Constructor
- D) Default Constructor
Where to put inline function during the frequent calling inside the program from multiple source files?
- A) Outside the class
- B) Header File
- C) Inside the class
- D) Main()
In C++, which of the following function causes the full definition of the function to be inserted in each place when it gets called?
- A) Built-in function
- B) Library function
- C) Recursive function
- D) Inline function
In C++, the default constructor takes _______.
- A) Only two arguments
- B) More than two arguments
- C) Only one argument
- D) No arguments