05th
May
C++  MCQ

C++ MCQ

  • Admin
  • 05th May, 2021
  • 700 Followers

C++ MCQ With Answers

Following are mostly asked C++ MCQ test that are designed for professionals like you to crack you interviews. You can take this C++ online test before appearing to you real interview. This C++ quiz there are around 30+ multiple choice questions on C++ with four options.

1) Which operator has highest precedence in * / % ?

  • A. /
  • B. *
  • C. %
  • D. all have same precedence

2) How to access and edit data in data file handling using structures

  • A. read()
  • B. write()
  • C. both A and B
  • D. without read()

3) Can we overload functions in C++?

  • A. Yes
  • B. No
  • C. Compilation Error
  • D. Runtime Error

4) Which of the followings is/are automatically added to every class, if we do not write our own.

  • A. Copy Constructor
  • B. Assignment Operator
  • C. A constructor without any parameter
  • D. All are Correct

5) Implicit return type of a class constructor is:

  • A. not of class type itsel
  • B. class type itself
  • C. a destructor of class type
  • D. a destructor not of class type
Download Free : C++ MCQ PDF

6) Choose the respective delete operator usage for the expression 'ptr=new int[100]'.

  • A. []delete ptr;
  • B. delete[] ptr;
  • C. delete ptr[];
  • D. delete ptr;

7) How many number of arguments can a destructor of a class receives?

  • A. 0
  • B. 1
  • C. 2
  • D. None of the above.

8) Which of the following is FALSE about references in C++

  • A. References cannot be NULL
  • B. A reference must be initialized when declared
  • C. Once a reference is created, it cannot be later made to reference another object; it cannot be reset.
  • D. References cannot refer to constant value

9) Which of the following is not correct for virtual function in C++ ?

  • A. Must be declared in public section of class.
  • B. Virtual function can be static.
  • C. Virtual function should be accessed using pointers.
  • D. Virtual function is defined in base class.

10) Which of the following cannot be passed to a function in C++ ?

  • A. Constant
  • B. Structure
  • C. Array
  • D. Header file

11) The associativity of which of the following operators is Left to Right, in C++ ?

  • A. Unary Operator
  • B. Logical not
  • C. Array element access
  • D. addressof

12) How many elements does a floating point number is composed of?

  • A. 1
  • B. 2
  • C. 3
  • D. 4

13) How many types of sequence operations are provided by the C++ algorithm STL?

  • A. 1
  • B. 2
  • C. 3
  • D. 4

14) Can destructors be virtual in C++?

  • A. Yes
  • B. No

15) How many kinds of classes are there in c++?

  • A. 1
  • B. 2
  • C. 3
  • D. 4

16) How can we restrict dynamic allocation of objects of a class using new?

  • A. By overloading new operator
  • B. By making an empty private new operator.
  • C. By making an empty private new and new[] operators
  • D. By overloading new operator and new[] operators

17) What id the syntax for catching any type of exceptions

  • A. catch(Exception e)
  • B. catch(...)
  • C. catch(Exception ALL)
  • D. catch(ALL)

18) Which of the following is true about this pointer?

  • A. It is passed as a hidden argument to all function calls
  • B. It is passed as a hidden argument to all non-static function calls
  • C. It is passed as a hidden argument to all static functions
  • D. None of the above

19) Which of the following in Object Oriented Programming is supported by Function overloading and default arguments features of C++.

  • A. Inheritance
  • B. Polymorphism
  • C. Encapsulation
  • D. None of the above

20) Which of the following is true?

  • A. Static methods cannot be overloaded.
  • B. Static data members can only be accessed by static methods.
  • C. Non-static data members can be accessed by static methods.
  • D. Static methods can only access static members (data and methods)

21) How many types of linkages are there in C++?

  • A. 1
  • B. 2
  • C. 3
  • D. 4

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

  • A. Virtual function
  • B. Operator function
  • C. Const function
  • D. Static function

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

24) In C++, const qualifier can be applied to 1) Member functions of a class 2) Function arguments 3) To a class data member which is declared as static 4) Reference variables

  • A. Only 1, 2 and 3
  • B. Only 1, 2 and 4
  • C. Only 1, 3 and 4
  • D. All

25) How to create a dynamic array of pointers (to integers) of size 10 using new in C++?

  • A. int *arr = new int *[10];
  • B. int **arr = new int *[10];
  • C. int *arr = new int [10];
  • D. Not Possible

26) Which of the following is true about virtual functions in C++.

  • A. Virtual functions are functions that can be overridden in derived class with the same signature.
  • B. Virtual functions enable run-time polymorphism in a inheritance hierarchy.
  • C. If a function is 'virtual' in the base class, the most-derived class's implementation of the function is called according to the actual type of the object referred to, regardless of the declared type of the pointer or reference.
  • D. All are Correct

27) Which of the following provides the best description of an entity type?

  • A. A specific concrete object with a defined set of processes (e.g. Jatin with diabetes)
  • B. A value given to a particular attribute (e.g. height - 230 cm)
  • C. A thing that we wish to collect data about zero or more, possibly real world examples of it may exist
  • D. A template for a group of things with the same set of characteristics that may exist in the real world

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

  • A. protected
  • B. public
  • C. private
  • D. friend

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

30) Which of the following provides a reuse mechanism?

  • A. Abstraction
  • B. Inheritance
  • C. Dynamic binding
  • D. Encapsulation

31) Which of the following operators cannot be overloaded?

  • A. []
  • B. ->
  • C. ?:
  • D. *

1 comment(s) :

Leave A Comment :

Valid name is required.

Valid name is required.

Valid email id is required.

Related MCQ/Quiz

01st
May
Hibernate MCQ
01st
May
Asp.Net Mcq
01st
May
Azure MCQ
01st
Jun
Devops  Mcq