C++ MCQ
C++ MCQ
1.
Which of the following type of class allows only one object of it to be created?
A. Virtual class
B. Abstract class
C. Singleton class
D. Friend class
2.
A. Copy constructor
B. Friend constructor
C. Default constructor
D. Parameterized constructor
3.
A. Static function
B. Friend function
C. Const function
D. Virtual function
5.
Which of the following concepts means determining at runtime what method to invoke?
A. Data hiding
B. Dynamic Typing
C. Dynamic binding
D. Dynamic loading
6.
Which of the following term is used for a function defined inside a class?
A. Member Variable
B. Member function
C. Class function
D. Classic function
7.
Which of the following concept of oops allows compiler to insert arguments in a function call if
it is not specified?
A. Call by value
B. Call by reference
C. Default arguments
D. Call by pointer
8.
A. 1 B. 5
C. 13 D. 0
9.
A. Function
B. Class
C. Object
D. Operator function
10.
Which of the following concepts of OOPS means exposing only necessary information to client?
A. Encapsulation
B. Abstraction
C. Data hiding
D. Data binding
11.
12.
A. operator B. function
C. object D. macro
13.
Which of the following concepts provides facility of using object of one class inside another
class?
A. Encapsulation B. Abstraction
C. Composition D. Inheritance
14.
C. 3 D. 4
15.
A. int B. double
C. string D. Class
16.
Which of the following concepts means adding new components to a program as it runs?
A. Data hiding
B. Dynamic typing
C. Dynamic binding
D. Dynamic loading
17.
18.
B. Transient polymorphism
C. Ad-hoc polymorphism
D. Pseudo polymorphism
19.
A. Top-down B. Bottom-up
C. Right-lef D. Lef-right
20.
D. Both A and B.
21.
B. class data members are public by default while that of structure are private.
D. class data members are private by default while that of structure are public by default.
22.
Which of the following concepts means wrapping up of data and functions together?
A. Abstraction B. Encapsulation
C. Inheritance D. Polymorphism
23.
Which of the following concepts means waiting until runtime to determine which function to
call?
A. Data hiding
B. Dynamic casting
C. Dynamic binding
D. Dynamic loading
24.
25.
A. >>
B. <<
C. +
D. =
26.
A. iostream
B. istream
C. ostream
D. ifstream
27.
A. class
B. member functions
C. constructor
D. destructor
28.
D. Initialize objects
29.
C. A syntax error.
D. A run-time error.
30.
Which one of the following options is correct about the statement given below? The compiler
checks the type of reference in the object and not the type of object.
A. Inheritance B. Polymorphism
C. Abstraction D. Encapsulation
31.
D. Both A and B
32.
A. Virtual function
B. Operator function
C. Const function
D. Static function
33.
D. Both A and B.
34.
Which of the following factors supports the statement that reusability is a desirable feature of a
language?
D. Both A and B.
35.
Which of the following ways are legal to access a class data member using this pointer?
A. this->x
B. this.x
C. *this.x
D. *this-x
36.
A. Operator overloading
B. Function overloading
C. Templates
37.
A. Only I is true.
C. Only II is true.
38.
What happens if the base and derived class contains definition of a function with same
prototype?
D. Base class object will call base class function and derived class object will call derived
class function.
39.
Which of the following are available only in the class hierarchy chain?
D. Member functions
40.
A. Multiple B. Multilevel
C. Distributive D. Hierarchical
41.
A. []
B. ->
C. ?:
D. *
42.
D. Both A and B.
43.
A. It speeds up execution.
D. Both A and C.
44.
Which one of the following is the correct way to declare a pure virtual function?
45.
Which of the following header file includes definition of cin and cout?
A. istream.h
B. ostream.h
C. iomanip.h
D. iostream.h
46.
A. overload
B. operator
C. friend
D. override
7.
C. It is not allowed.
D. Both A and B.
48.
{}
A. Multilevel inheritance
B. Multiple inheritance
C. Hybrid inheritance
D. Hierarchical Inheritance
49.
Which one of the following is correct about the statements given below?
A. Only II is correct.
C. Only I is correct.
50.
A. public
B. private
C. protected
D. friend
51.
52.
53.
54.
A. protected B. public
C. privateD. friend
55.
A. A static member function can access only static data members of a class.
B. A static data member is shared among all the object of the class.
D. Both A and B.
56.
A. Abstraction
B. Inheritance
C. Dynamic binding
D. Encapsulation
57.
a. throws
b. throw
c. threw
d. thrown
2. The code of statements which may cause abnormal termination of the program should be written
under_________ block
a. try
b. catch
c. Finally
d. None of these
a. Try
b. catch
c. throw
d. finally
a. True
b. False
a. Only 1, 4, 5
b. Only 1, 2, 3
c. Only 1, 4
d. Only 1, 2
a. Yes
b. No
7. In nested try blocks, there is no need to specify catch handler for inner try block. Outer catch handler is
sufficient for the program.
a. True
b. False
10. Generic catch handler must be placed at the end of all the catch handlers
a. True
b. False
a. catch(..,)
b. catch(---)
c. catch(…)
d. catch( void x)
12. In nested try blocks, if both inner and outer catch handlers are not able to handle the exception,
then______________
13. Functions called from within a try block may also throw exception
a. True
b. False
14. Irrespective of exception occurrence, catch handler will always get executed.
a. True
b. False
15. Throwing an unhandled exception causes standard library function _______________ to be invoked.
a. stop()
b. aborted()
c. terminate()
d. abandon()
a. True
b. False
a. True
b. False
19. Attempting to throw an exception that is not supported by a function call results in calling
_____________ library function.
a. indeterminate()
b. unutilized()
c. unexpected()
d. unpredicted()
a. int
b. bool
c. char *
d. double
a. Yes
b. No
22. Can we define our exceptions in CPP?
a. Yes
b. No
a. True
b. False
a. virtual function
b. static function
c. friend function
d. const member function
4. Runtime polymorphism is achieved only when a virtual function is accessed through a pointer to the
base class.
a. True
b. False
a. Overloading
b. Overriding
c. Rewriting
d. All of these
7. While redefining a virtual function in the derived class, if its prototype is changed
then___________________
a. Virtual class
b. Sealed class
c. Pure Local class
d. Abstract Class
a. Derived class should provide definition for all the pure virtual functions
b. Derived class also become abstract if fails to implement pure virtual functions
c. Objects of derived class can’t be created if it fails to implement pure virtual functions
d. All of these
11. A virtual function that has no definition within the base class is called____________