MCQ Bank
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
C++ offers ____________ levels of data access control inside a class
- A) five
- B) three
- C) four
- D) two
new operator can be used for ______________.
- A) only char and integer data types
- B) only integer data type
- C) integer , float, char and double data types
- D) dot operator
Consider the following code, the printed value will be converted into:
int n=10;
cout<<oct<<n;
- A) Base 8
- B) Base 10
- C) Decimal number system
- D) Base 2
What is meaning of bad bit in I/O operation:
- A) Wrong data
- B) Error in data
- C) Bad data
- D) Lost data
Functions declared with the _________________ specifier in a class member list are called friend functions of that class.
- A) public
- B) friend
- C) private
- D) protected
What will be the output of following statement? cout << setfill(‘0’) << setw(7) << 128 ;
- A) 0000128
- B) 0128128
- C) 1280000
- D) 0012800
Friend function declaration can go ___________________ the class
- A) only outside
- B) anywhere in
- C) in the member function of
- D) only within
If we have a program that writes the output data(numbers) to the disc ,and if we collect the output data and write it on the disc in one write operation instead of writing the numbers one by one. In the above situation the area where we will gather the number is called
- A) Cache
- B) Heap
- C) Buffer
- D) Stack
What will be the output of the following code segment? int n=8; cout<<oct<<n;
- A) 8
- B) 10
- C) 1000
- D) 11