MCQ Bank
In the syntax of the overloaded operator function given below: Complex operator + (Complex &); What is operator?
- A)
- B)
- C)
- D)
Default constructor takes _________.
- A) one parameter
- B) two parameters
- C) character type parameter
- D) no parameters
which operator can be overloaded?
- A)
- B)
- C)
- D)
What is the main difference between a struct and a class in C++?
- A) Struct members are public by default; class members are private.
- B) Structs can’t have functions.
- C) There is no difference.
- D) Classes don’t allow data grouping.
Complex codd (complex c1, complex c2); Which statement is true for above code?
- A)
- B)
- C)
- D)
Constructor is itself a __________ of C++ and ___________.
- A) object, can not be initialized
- B) class , can be overloaded
- C) function , cannot be overloaded
- D) function, can be overloaded
Which of the following is assignment operator?
- A)
- B)
- C)
- D)
What can the resultant number when you AND two numbers 12 & 8 bit-wise using & operator?
- A) 8
- B) 6
- C) 12
- D) 4
which option will be correct in order to free the space of memory allocated to a buffer (buf)?
- A)
- B)
- C)
- D)
How is a destructor named in C++?
- A) _ClassName()
- B) ClassName~()
- C) destroyClassName()
- D) ~ClassName()
How many objects are initialized for the class? Date myDates[10];
- A)
- B)
- C)
- D)
For converting a void type pointer ptr into integer type, the correct syntax is:
- A) *int ptr
- B) (int *) ptr
- C) int * ptr
- D) ptr * int
which statement about pointer is not true?
- A)
- B)
- C)
- D)
Why is it a good practice to write macro names in capital letters?
- A) It avoids runtime errors
- B) It is required by the compiler
- C) It helps distinguish macros from functions and variables
- D) It speeds up macro execution
Representing logical depiction of the solution to the problem is known as a ________
- A)
- B)
- C)
- D)
Look at the program code and identify the error. #include<iostream> using namespace std; #define PI 3.1415926; main() { int radius = 5; cout << "Area of circle with radius " << radius << " = " << PI * radius * radius; }
- A) It will be compiled and returns nothing
- B) Error exists in line number 2. Semi colon is not allowed with define directive
- C) It will be compiled successfully and will not generate error
- D) The value of PI cannot be defined in the beginning
Which statement about manipulators is not true?
- A)
- B)
- C)
- D)
A file opened with the help of ______________ can be used for both input and output.
- A) iostream
- B) fstream
- C) ifstream
- D) ofstream
which of the following structure is correct for WHILE loop?
- A)
- B)
- C)
- D)
Which header file is required to use file I/O operations?
- A) <ostream>
- B) <fstream>
- C) <iostream>
- D) <ifstream>