C++ MCQs with answers Page - 82

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 of the following operators should be preferred to overload as a global function rather than a member method?

  • (A) Insertion Operator <<
  • (B) Comparison Operator
  • (C) Prefix++
  • (D) Postfix ++

A

Admin • 833.24K Points
Coach

Q. How C++ compiler does differ between overloaded postfix and prefix operators?

  • (A) By making prefix ++ as a global function and postfix as a member function.
  • (B) A prefix ++ has a dummy parameter
  • (C) A postfix ++ has a dummy parameter
  • (D) C++ doesn’t allow both operators to be overloaded in a class

A

Admin • 833.24K Points
Coach

Q. Which of the following operator functions cannot be global?

  • (A) delete
  • (B) new
  • (C) Conversion Operator
  • (D) All of the above

A

Admin • 833.24K Points
Coach

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

A

Admin • 833.24K Points
Coach

Q. What is the use of this pointer?

  • (A) When local variable’s name is same as member’s name, we can access member using this pointer.
  • (B) To return reference to the calling object
  • (C) Can be used for chained function calls on an object
  • (D) All of the above

A

Admin • 833.24K Points
Coach

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

A

Admin • 833.24K Points
Coach

Q. Output of the program?

Code:
#include<iostream>
using namespace std;
int fun(int x = 0, int y = 0, int z)
{ return (x + y + z); }
int main()
{
cout << fun(10);
return 0;
}
  • (A) 0
  • (B) 10
  • (C) 20
  • (D) Compiler Error

A

Admin • 833.24K Points
Coach

Q. Output of following program?

Code:
#include <iostream>
using namespace std;
int fun(int=0, int = 0);
int main()
{
cout << fun(5);
return 0;
}
int fun(int x, int y)
{
return (x+y);
}
  • (A) 0
  • (B) 5
  • (C) 10
  • (D) Compiler Error

A

Admin • 833.24K Points
Coach

Q. Which of the following is true?

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

A

Admin • 833.24K Points
Coach

Q. If a function is friend of a class, which one of the following is wrong?

  • (A) It can have access to all members of the class, even private ones.
  • (B) Friend functions are members of a class.
  • (C) Friend functions are not members of a class, they are associated with it.
  • (D) A function can only be declared a friend by a class itself.