0% found this document useful (0 votes)
450 views24 pages

C++ MCQ

The document contains a set of 51 multiple choice questions related to C++ concepts such as classes, objects, inheritance, polymorphism, encapsulation, and other OOP concepts. The questions cover topics like class types, constructors, pointers, inheritance types, operator overloading, virtual functions, and more. The questions are designed to test the reader's understanding of fundamental and advanced C++ programming concepts through objective type questions with multiple choice answers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
450 views24 pages

C++ MCQ

The document contains a set of 51 multiple choice questions related to C++ concepts such as classes, objects, inheritance, polymorphism, encapsulation, and other OOP concepts. The questions cover topics like class types, constructors, pointers, inheritance types, operator overloading, virtual functions, and more. The questions are designed to test the reader's understanding of fundamental and advanced C++ programming concepts through objective type questions with multiple choice answers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 24

C++ Objective Type Questions

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.

Which of the following is not a type of constructor?

A. Copy constructor

B. Friend constructor

C. Default constructor

D. Parameterized constructor

3.

Which of the following statements is correct?

A. Base class pointer cannot point to derived class.

B. Derived class pointer cannot point to base class.

C. Pointer to derived class cannot be created.

D. Pointer to base class cannot be created.


4.

Which of the following is not the member of class?

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.

How many instances of an abstract class can be created?

A. 1 B. 5

C. 13 D. 0

9.

Which of the following cannot be friend?

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.

Why reference is not same as a pointer?

A. A reference can never be null.

B. A reference once established cannot be changed.

C. Reference doesn't need an explicit dereferencing mechanism.

D. All of the above.

12.

cout is a/an __________ .

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.

How many types of polymorphisms are supported by C++?


A. 1 B. 2

C. 3 D. 4

15.

Which of the following is an abstract data type?

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.

Which of the following statement is correct?

A. A constructor is called at the time of declaration of an object.

B. A constructor is called at the time of use of an object.

C. A constructor is called at the time of declaration of a class.

D. A constructor is called at the time of use of a class.

18.

Which of the following correctly describes overloading of functions?


A. Virtual polymorphism

B. Transient polymorphism

C. Ad-hoc polymorphism

D. Pseudo polymorphism

19.

Which of the following approach is adapted by C++?

A. Top-down B. Bottom-up

C. Right-lef D. Lef-right

20.

Which of the following is correct about function overloading?

A. The types of arguments are different.

B. The order of argument is different.

C. The number of argument is same.

D. Both A and B.

21.

Which of the following is correct about class and structure?

A. class can have member functions while structure cannot.

B. class data members are public by default while that of structure are private.

C. Pointer to structure or classes cannot be declared.

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.

How "Late binding" is implemented in C++?

A. Using C++ tables

B. Using Virtual tables

C. Using Indexed virtual tables

D. Using polymorphic tables

View Answer C++ Compiler Report Discuss in Forum

25.

Which of the following operator is overloaded for object cout?

A. >>
B. <<

C. +

D. =

26.

Which of the following is the correct class of the object cout?

A. iostream

B. istream

C. ostream

D. ifstream

27.

Which of the following cannot be used with the keyword virtual?

A. class

B. member functions

C. constructor

D. destructor

28.

Which of the following functions are performed by a constructor?

A. Construct a new class

B. Construct a new object

C. Construct a new function

D. Initialize objects
29.

Which of the following problem causes an exception?

A. Missing semicolon in statement in main().

B. A problem in calling function.

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.

Which of the following is the correct way of declaring a function as constant?

A. const int ShowData(void) { /* statements */ }

B. int const ShowData(void) { /* statements */ }

C. int ShowData(void) const { /* statements */ }

D. Both A and B

32.

Which of the following concepts is used to implement late binding?

A. Virtual function
B. Operator function

C. Const function

D. Static function

33.

Which of the following statement is correct?

A. C++ allows static type checking.

B. C++ allows dynamic type checking.

C. C++ allows static member function be of type const.

D. Both A and B.

34.

Which of the following factors supports the statement that reusability is a desirable feature of a
language?

A. It decreases the testing time.

B. It lowers the maintenance cost.

C. It reduces the compilation time.

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.

Which of the following is a mechanism of static polymorphism?

A. Operator overloading

B. Function overloading

C. Templates

D. All of the above

37.

Which of the following is correct about the statements given below?

All operators can be overloaded in C++.

We can change the basic meaning of an operator in C++.

A. Only I is true.

B. Both I and II are false.

C. Only II is true.

D. Both I and II are true.

38.

What happens if the base and derived class contains definition of a function with same
prototype?

A. Compiler reports an error on compilation.

B. Only base class function will get called irrespective of object.


C. Only derived class function will get called irrespective of object.

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?

A. Public data members

B. Private data members

C. Protected data members

D. Member functions

40.

Which of the following is not a type of inheritance?

A. Multiple B. Multilevel

C. Distributive D. Hierarchical

41.

Which of the following operators cannot be overloaded?

A. []

B. ->

C. ?:
D. *

42.

In which of the following a virtual call is resolved at the time of compilation?

A. From inside the destructor.

B. From inside the constructor.

C. From inside the main().

D. Both A and B.

43.

Which of the following statements regarding inline functions is correct?

A. It speeds up execution.

B. It slows down execution.

C. It increases the code size.

D. Both A and C.

44.

Which one of the following is the correct way to declare a pure virtual function?

A. virtual void Display(void){0};

B. virtual void Display = 0;

C. virtual void Display(void) = 0;


D. void Display(void) = 0;

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.

Which of the following keyword is used to overload an operator?

A. overload

B. operator

C. friend

D. override

7.

What will happen if a class is not having any name?

A. It cannot have a destructor.

B. It cannot have a constructor.

C. It is not allowed.

D. Both A and B.
48.

Which inheritance type is used in the class given below?

class A : public X, public Y

{}

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?

All function calls are resolved at compile-time in Procedure Oriented Programming.

All function calls are resolved at compile-time in OOPS.

A. Only II is correct.

B. Both I and II are correct.

C. Only I is correct.

D. Both I and II are incorrect.

50.

Which of the following is an invalid visibility label while inheriting a class?

A. public

B. private

C. protected
D. friend

51.

Which one of the following options is correct?

A. Friend function can access public data members of the class.

B. Friend function can access protected data members of the class.

C. Friend function can access private data members of the class.

D. All of the above.

52.

Which of the following statements is correct in C++?

A. Classes cannot have data as protected members.

B. Structures can have functions as members.

C. Class members are public by default.

D. Structure members are private by default.

53.

Which of the following is used to make an abstract class?

A. Declaring it abstract using static keyword.

B. Declaring it abstract using virtual keyword.

C. Making at least one member function as virtual function.


D. Making at least one member function as pure virtual function.

54.

Which of the following access specifier is used as a default in a class definition?

A. protected B. public

C. privateD. friend

55.

What is correct about the static data member of a class?

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.

C. A static data member can be accessed directly from main().

D. Both A and B.

56.

Which of the following provides a reuse mechanism?

A. Abstraction

B. Inheritance

C. Dynamic binding
D. Encapsulation

57.

Which of the following statement is correct?

A. Class is an instance of object.

B. Object is an instance of a class.

C. Class is an instance of data type.

D. Object is an instance of data type.

1. An exception is thrown using _____________ keyword in CPP.

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

3. Exception handlers are declared with ____________ keyword

a. Try
b. catch
c. throw
d. finally

4. Catch handler can have multiple parameters.

a. True
b. False

5. Which of the following statements are true about Catch handler ?

1. It must be placed immediately after try block T


2. It can have multiple parameters
3. There must be only one catch handler for every try block
4. There can be multiple catch handler for a try block T
5. Generic catch handler can be placed anywhere after try block.

a. Only 1, 4, 5
b. Only 1, 2, 3
c. Only 1, 4
d. Only 1, 2

6. A try block can be nested under another try block –

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

8. In nested try block, if inner catch handler gets executed, then______________

a. Program execution stops immediately


b. Outer catch handler will also get executed
c. Compiler will jump to the outer catch handler and then executes remaining executable statements of
main()
d. Compiler will execute remaining executable statements of outer try block and then the main()

9. If inner catch handler is not able to handle the exception then__________

a. Compiler will look for outer try handler


b. Program terminates abnormally
c. Compiler will check for appropriate catch handler of outer try block
d. None of these

10. Generic catch handler must be placed at the end of all the catch handlers

a. True
b. False

11. Generic catch handler is represented by ______________

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______________

a. Compiler executes only executable statements of main()


b. Compiler issues compile time errors about it
c. Program will be executed without any interrupt
d. Program will be terminated abnormally

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()

16. An exception can be of only built-In type.

a. True
b. False

17. We can prevent a function from throwing any exceptions.

a. True
b. False

18. How can we restrict a function to throw certain exceptions?

a. Defining multiple try and catch block inside a function


b. Defining generic function within try block
c. Defining function with throw clause
d. It is not possible in CPP to restrict a function

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()

20. Return type of uncaught_exception() is________________

a. int
b. bool
c. char *
d. double

21. Can we write throw clause inside catch handler?

a. Yes
b. No
22. Can we define our exceptions in CPP?

a. Yes
b. No

1. We can create objects of the abstract class.

a. True
b. False

2. Run time polymorphism can be achieved with______

a. Virtual Base class


b. Container class
c. Virtual function
d. Both a and c
3. ________________ is a member function that is declared within a base class and redefined by derived
class.

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

5. When a virtual function is redefined by the derived class, it is called___________

a. Overloading
b. Overriding
c. Rewriting
d. All of these

6. Which of the followings are true about Virtual functions?

a. They must be non-static member function of the class


b. They cannot be friends
c. Constructor Functions cannot be virtual
d. All of these

7. While redefining a virtual function in the derived class, if its prototype is changed
then___________________

a. It will be overloaded by the compiler


b. Its virtual nature will be lost
c. both a and b
d. Compiler will generate “Prototype mismatch error”

8. If a class contains pure virtual function, then it is termed as_____________________

a. Virtual class
b. Sealed class
c. Pure Local class
d. Abstract Class

9. Syntax for Pure Virtual Function is______________

a. virtual void show()==0


b. void virtual show()==0
c. virtual void show()=0
d. void virtual show()=0

10. If abstract class is inherited by derived class, then_______________

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____________

a. Pure virtual function


b. Pure static function
c. Pure Const function
d. Friend function

12. Find the wrong statement/s about Abstract Class.

a. We can’t create its objects


b. We can’t create pointers to an abstract class
c. It contains at least one pure virtual function
d. We can create references to an abstract class

You might also like