C++ MCQs with answers Page - 158

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. What is the purpose of the 'friend' function in C++?

  • (A) To allow access to private and protected members of a class
  • (B) To create multiple objects of a class
  • (C) To inherit a class
  • (D) To define a global function

A

Admin • 833.24K Points
Coach

Q. Which operator is used to access a pointer's value in C++?

  • (A) &
  • (B) *
  • (C) ->
  • (D) ::

A

Admin • 833.24K Points
Coach

Q. Which of the following is true about function overloading in C++?

  • (A) Functions must have different names
  • (B) Functions must have different return types
  • (C) Functions must have different parameter lists
  • (D) Functions must be defined in different files

A

Admin • 833.24K Points
Coach

Q. Which of the following is not a valid access specifier in C++?

  • (A) private
  • (B) protected
  • (C) public
  • (D) global

A

Admin • 833.24K Points
Coach

Q. Which of the following statements about recursion in C++ is true?

  • (A) A function cannot call itself
  • (B) Recursion always results in an infinite loop
  • (C) Recursive functions must have a base condition
  • (D) Recursion is not allowed in C++

A

Admin • 833.24K Points
Coach

Q. Which of the following is true about C++ structures?

  • (A) They cannot have member functions
  • (B) They support inheritance
  • (C) They can have both data members and member functions
  • (D) They cannot be used to define objects

A

Admin • 833.24K Points
Coach

Q. Which of the following operators cannot be overloaded in C++?

  • (A) +
  • (B) =
  • (C) ::
  • (D) []

A

Admin • 833.24K Points
Coach

Q. Which of the following correctly declares a pointer in C++?

  • (A) int ptr;
  • (B) int *ptr;
  • (C) pointer<int> ptr;
  • (D) int ptr[];

A

Admin • 833.24K Points
Coach

Q. What is the default return type of the 'main()' function in C++?

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

A

Admin • 833.24K Points
Coach

Q. Which of the following statements is true about C++ classes?

  • (A) A class cannot have private members.
  • (B) A class can have both data members and member functions.
  • (C) A class must always have a constructor.
  • (D) A class cannot be instantiated.

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