Top 80+ Solved CPP Programming MCQ Questions Answer

From 1 to 15 of 86

Q. Which of the followings is/are automatically added to every class, if we do not write ourown?

a. Copy Constructor

b. Assignment Operator

c. A constructor without any parameter

d. All of the above

  • d. All of the above

Q. When a copy constructor may be called?

a. When an object of the class is returned by value.

b. When an object of the class is passed (to a function) by value as an argument.

c. When an object is constructed based on another object of the same class

d. All of the above

  • d. All of the above

Q. Constructors have _____ return type.

a. void

b. char

c. int

d. no

  • d. no

Q. Implicit return type of a class constructor is:

a. not of class type itself

b. class type itself

c. a destructor of class type

d. a destructor not of class type

  • b. class type itself

Q. #include<iostream>using namespace std;class Point {public: Point() { cout << "Constructor called"; }};int main(){ Point t1, *t2; return 0;}

a. Compiler Error

b. Constructor called Constructor called

c. Constructor called

d. None of the above

  • c. Constructor called

Q. Which operator is having the highest precedence?

a. postfix

b. unary

c. shift

d. equality

  • d. equality

Q. 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

  • d. References cannot refer to constant value

Q. Which of the following functions must use reference?

a. Assignment operator function

b. Copy Constructor

c. Destructor

d. Parameterized constructor

  • b. Copy Constructor

Q. What is the difference between struct and class in C++?

a. All members of a structure are public and structures don’t have constructors and destructors

b. Members of a class are private by default and members of struct are public by default. When deriving a struct from a class/struct, default access-specifier for a base class/struct is public and when deriving a class, default access specifier is private.

c. All members of a structure are public and structures don’t have virtual functions

d. All of the above

  • b. Members of a class are private by default and members of struct are public by default. When deriving a struct from a class/struct, default access-specifier for a base class/struct is public and when deriving a class, default access specifier is private.

Q. class Test { int x;};int main() { Test t; cout << t.x;return 0;}

a. 0

b. Garbage Value

c. Compiler Error

d. None

  • c. Compiler Error

Q. Which of the following is true?

a. All objects of a class share all data members of class

b. Objects of a class do not share non-static members. Every object has its own copy.

c. Objects of a class do not share codes of non-static methods, they have their own copy

d. None of the above

  • b. Objects of a class do not share non-static members. Every object has its own copy.
Subscribe Now

Get All Updates & News