MCQ Bank
The only operator that the compiler overloads for user define data type by default is
- A) Plus (+) operator
- B) Minus (-) operator
- C) Equal (==) operator
- D) Assignment (=) operator
In C++ operators, which of the following operator cannot be overloaded ___________.
- A) -
- B) <<
- C) ?:
- D) +
Which of the following is the correct definition of streams?
- A) It is an unordered sequence of bits
- B) It is an ordered sequence of bytes
- C) It is an ordered sequence of bits
- D) It is an unordered sequence of bytes
What is the sequence of event(s) when allocating memory to an object using new operator?
- A) Only block of memory is allocated for object
- B) Memory is allocated first before calling constructor
- C) Constructor is called first before allocating memory
- D) Only constructor is called for object
date+=1; is equivalent to ______________.
- A) date+1
- B) 1+date
- C) date++
- D) ++date
The friend function of a class can have access _________________.
- A) to the private data members
- B) to the protected data members
- C) to public, private and protected data members
- D) to the public data members only
Which of the following is normally a destination for cin stream?
- A) Mouse
- B) Printer
- C) Keyboard
- D) Variable
The new operator automatically determines the size of memory required to store that object , so it does not need ______________.
- A) dot operator
- B) sizeof operator
- C) free operator
- D) size off operator
Which one of the following is the declaration of overloaded pre-increment operator implemented as member function?
- A) Class-name operator ++(int) ;
- B) Class-name operator ++();
- C) Class-name operator +(int) ;
- D) Class-name operator +() ;
Which of the following functionality can be achieved through overloading?
- A) New operators cannot be defined through operator overloading.
- B) We can change associativity of all operators.
- C) We can change the associativity of some operators.
- D) We can change the precedence of some operators.
If the request of new operator is not fulfilled due to insufficient memory in the heap ____________________.
- A) free operator returns nothing
- B) the operator returns 0
- C) the new operator returns 2
- D) the new operator returns 1
free function is available in _______________ header file.
- A) iostream.h
- B) conio.h
- C) stdlib.h
- D) string.h
The members of a class declared without any keyword are __________ by default
- A) private
- B) protected
- C) constant
- D) public
The statement cin.get (); is used to________.
- A) Read a character from the keyboard
- B) Read a string from keyboard
- C) Read a character from file
- D) Read a String from file
What will be the output of the following code segment?
float pi=32.3996;
cout<<fixed;
cout << setprecision (2) << pi ;
- A) 32.40
- B) 32.39
- C) 32.00
- D) 32.310
When the compiler overloads the assignment (=) operator by default then
- A) Compiler does not allow default assignment operator
- B) Compiler does member wise assignment.
- C) Compiler does not do member wise assignment.
- D) Class members are not assigned properly
Once the _______________ are created, they exist for the life time of the program
- A) non static variables
- B) local variables
- C) automatic variables
- D) global variables
Consider the following code segment. Which of the following will be called while executing code at line 2?
String s1 , s2;
s1 = s2 ;
- A) Default constructor
- B) Parameterized constructor
- C) Copy constructor
- D) Assignment operator
With user data type variables (Objects) self assignment can produce
- A) Run time error
- B) Logical error
- C) Link error
- D) Syntax error
What is the purpose of endl stream manipulator?
- A) flush the stream
- B) terminate a string with NULL
- C) insert a new line
- D) insert a new line and flush the stream