Solved Multiple Choice Questions On C++ Set-4

This set of multiple choice questions on principles of object oriented programming in C++ includes MCQ questions on input and output operator, variables, statements, C++ objects, class, inheritance and polymorphism. It also includes objective questions about header files listed in C++ standard library and their uses.

1. In C++ ………………… operator is used for Dynamic memory allocation.
A) Scope resolution
B) Conditional
C) New
D) Membership access

2. Operators such as …………………. cannot be overloaded.
A) +
B) ++
C) : :
D) = =

3. The …………………. objects have values that can be tested for various error conditions.
A) osstream
B) ofstream
C) stream
D) ifstream

4. Which function return the current position of the get or put pointer in bytes.
A) tellg( )
B) tellp( )
C) tell( )
D) Both A and B

5. The first index number in an array starts with ………………………. and the index number of an array of size n will be …………
A) 0, n-1
B) 1, n-1
C) 0, n
D) 1, n

6. To overload an operator ………………… keyword must be used along with the operator to be overloaded.
A) Over
B) Overload
C) Void
D) Operator


7. What is the output of the program

#include<iostream.h>
void main()
{
int n=1;
cout<<endl<<“The numbers are;”<<endl;
do
{
cout <<n<<“t”;
n++;
} while (n<=100);
cout <<endl;
}

A) Print natural numbers 0 to 99
B) Print natural numbers 1 to 99
C) Print natural numbers 0 to 100
D) Print natural numbers 1 to 100

8. Everything defined at the program scope level (ie. outside functions and classes) is said to be ……………
A) local scope
B) regional scope
C) global scope
D) static scope

9. Because the lifetime of a local variable is limited and determined automatically, these variables are also called ……………………….
A) automator
B) automatic
C) dynamic
D) static

10. ……………. allows that a section of a program is compiled only if the defined constant that is specified as the parameter has been defined, independently of its value.
A) #ifdef
B) #if
C) #define
D) #ifd

11. Which of the following is/are  the header files listed in C++ standard library.
i) <ctype.h>   ii) <float.h>   iii) <date.h>   iv) <limits.h>
A) i, ii and iii only
B) i, ii and iv only
C) ii, iii and iv only
D) All i, ii, iii and iv

12. The C++ header file …………….. contains macros and information for adding diagnostics that aid program debugging.
A) <cctype>
B) <cassert>
C) <cfloat>
D) <cstdio>

13. …………… is the header file that contains functions prototypes and types for manipulating the time and date.
A) <ctype.h>
B) <float.h>
C) <time.h>
D) <date.h>

14. The C++ header file ……………….. contains function prototypes for the standard input and standard output functions.
A) <iomanip>
B) <fstream>
C) <iostream>
D) <cstdio>

15. ……………. is the header file listed in C++ standard library that contains function prototypes for the stream manipulators that enable formatting of streams of data.
A) <iomanip>
B) <fstream>
C) <iostream>
D) <cstdio>

Answers

1. C) New
2. C) : :
3. D) ifstream
4. B) tellp( )
5. A) 0, n-1
6. D) Operator
7. D) Print natural numbers 1 to 100
8. C) global scope
9. B) automatic
10. A) #ifdef
11. B) i, ii and iv only
12. B) <cassert>
13. C) <time.h>
14. C) <iostream>
15. A) <iomanip>

Read Next:Solved MCQ of Programming In C++ set-5

Read More:C and C++ MCQ Question