C++ MCQs with answers Page - 167

Dear candidates you will find MCQ questions of C++ here. Learn these questions and prepare yourself for coming examinations and interviews. You can check the right answer of any question by clicking on any option or by clicking view answer button.
Share your questions by clicking Add Question

P

Praveen Singh • 36.81K Points
Coach

Q. What is the output of the following code?

int x = 10;
cout << ++x * x++;

  • (A) 110
  • (B) 121
  • (C) 120
  • (D) Undefined behavior

R

Ram Sharma • 193.86K Points
Coach

Q. Which of the following is the correct syntax for defining a pure virtual function in C++?

  • (A) virtual void show() = 0;
  • (B) void show() = 0;
  • (C) virtual void show();
  • (D) abstract void show();

S

Shiva Ram • 30.44K Points
Instructor I

Q. Which of the following correctly describes a friend function in C++?

  • (A) A function that is a member of two different classes
  • (B) A function that can access private members of a class
  • (C) A function defined in multiple classes
  • (D) A function that can only be used with objects

R

Ram Sharma • 193.86K Points
Coach

Q. Which header file is required to use the std::vector container in C++?

  • (A) <vector>
  • (B) <array>
  • (C) <list>
  • (D) <set>

A

Admin • 36.96K Points
Coach

Q. Which of the following statements about constructors in C++ is false?

  • (A) A constructor has the same name as the class.
  • (B) A constructor does not have a return type.
  • (C) A constructor can be private.
  • (D) A constructor must be explicitly called when creating an object.

V

Vijay Sangwan • 28.62K Points
Instructor II

Q. Which keyword is used to declare a constant variable in C++?

  • (A) define
  • (B) const
  • (C) static
  • (D) constant

R

Rakesh Kumar • 28.44K Points
Instructor II

Q. What is the default access specifier for class members in C++?

  • (A) public
  • (B) private
  • (C) protected
  • (D) None of the above

G

Gopal Sharma • 38.32K Points
Coach

Q. Which function is used to release dynamically allocated memory in C++?

  • (A) free()
  • (B) delete
  • (C) release()
  • (D) dispose()

P

Praveen Singh • 36.81K Points
Coach

Q. Which operator is used to resolve ambiguity in multiple inheritance?

  • (A) ::
  • (B) ->
  • (C) .*
  • (D) None of the above

R

Ram Sharma • 193.86K Points
Coach

Q. Which of the following is an example of function overloading in C++?

  • (A) Using multiple functions with the same name but different parameters
  • (B) Using a function with the same name in a derived class
  • (C) Using a function inside a loop
  • (D) Defining a function inside a structure

Loding content...

Download our easy to use, user friendly Android App from Play Store. And learn MCQs with one click.

Image

Login

Forgot username? click here

Forgot password? Click here

Don't have account? Register here.