C++ MCQs with answers Page - 83

Here, you will find a collection of MCQ questions on C++. Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

A

Admin • 833.24K Points
Coach

Q. Which one of the following is correct, when a class grants friend status to another class?

  • (A) The member functions of the class generating friendship can access the members of the friend class.
  • (B) All member functions of the class granted friendship have unrestricted access to the members of the class granting the friendship.
  • (C) Class friendship is reciprocal to each other.
  • (D) There is no such concept.

A

Admin • 833.24K Points
Coach

Q. 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) 1, 2, 3 and 4

A

Admin • 833.24K Points
Coach

Q. Which of the following is true about new when compared with malloc:
1) new is an operator, malloc is a function
2) new calls constructor, malloc doesn’t
3) new returns appropriate pointer, malloc returns void * and pointer needs to typecast to appropriate type.

  • (A) 1 and 2
  • (B) 2 and 3
  • (C) 1 and 3
  • (D) 1, 2 and 3

A

Admin • 833.24K Points
Coach

Q. Predict the output?

Code:
#include <iostream>
using namespace std;
class Test
{
int x;
Test()
{
x = 5;
} };
int main()
{
Test *t = new Test;
cout << t->x;
}
  • (A) 0
  • (B) 5
  • (C) Garbage Value
  • (D) Compiler Error

A

Admin • 833.24K Points
Coach

Q. When the inheritance is private, the private methods in base class are__________ in the derived class (in C++).

  • (A) public
  • (B) protected
  • (C) accessible
  • (D) inaccessible

A

Admin • 833.24K Points
Coach

Q. Which of the following is true about pure virtual functions?
1) Their implementation is not provided in a class where they are declared.
2) If a class has a pure virtual function, then the class becomes abstract
class and an instance of this class cannot be created.

  • (A) Only 1
  • (B) Only 2
  • (C) Both 1 and 2
  • (D) Neither 1 nor 2

A

Admin • 833.24K Points
Coach

Q. What is the size of wchar_t in C++?

  • (A) 2
  • (B) 4
  • (C) 2 or 4
  • (D) Based on the number of bits in the system

A

Admin • 833.24K Points
Coach

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

  • (A) A constructor without any parameter
  • (B) Copy Constructor
  • (C) Assignment Operator
  • (D) All of the above

A

Admin • 833.24K Points
Coach

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

A

Admin • 833.24K Points
Coach

Q. Constructors have _____ return type.

  • (A) no
  • (B) int
  • (C) char
  • (D) void

Add MCQ in this Category

If you want to share an MCQ question in this category, it's a great idea! It will be helpful for many other students using this website.

Share Your MCQ