C++ MCQs with answers Page - 21

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. If we have object from ofstream class, then default mode of opening the file is _____ .

  • (A) ios::in|ios::trunc
  • (B) _out_ios__trunk
  • (C) ios::out
  • (D) ios::in

A

Admin • 833.24K Points
Coach

Q. _______________ is a member function that is declared within a base class and redefined by derived class.

  • (A) const member function
  • (B) friend function
  • (C) virtual function
  • (D) static function

A

Admin • 833.24K Points
Coach

Q. Syntax for Pure Virtual Function is ______________ .

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

A

Admin • 833.24K Points
Coach

Q. Logical expressions produce ____________ type results.

  • (A) garbage
  • (B) bool
  • (C) static
  • (D) explicit

A

Admin • 833.24K Points
Coach

Q. We can initialize a value of static variable of a class only when its object is created. No other initialization is permitted.

  • (A) True
  • (B) Flase
  • (C) Either A or B
  • (D) None of the above

A

Admin • 833.24K Points
Coach

Q. When a base class is privately inherited by the derived class, then_____________ .

  • (A) public members of the base class become private members of derived class
  • (B) protected members of the base class become private members of derived class
  • (C) only b
  • (D) both a and b

A

Admin • 833.24K Points
Coach

Q. What is the difference between protected and private access specifiers in inheritance?

  • (A) Both are inheritable but private is accessible in the derived class.
  • (B) private member is not inheritable and not accessible in derived class.
  • (C) protected member is inheritable and also accessible in derived class.
  • (D) Both are inheritable but protected is not accessible in the derived class.

A

Admin • 833.24K Points
Coach

Q. In nested try blocks, if both inner and outer catch handlers are not able to handle the exception, then ______________ .

  • (A) Program will be executed without any interrupt.
  • (B) Program will be terminated abnormally.
  • (C) Compiler issues compile time errors about it.
  • (D) Compiler executes only executable statements of main().

A

Admin • 833.24K Points
Coach

Q. Throwing an unhandled exception causes standard library function then _________ to be invoked.

  • (A) terminate()
  • (B) stop()
  • (C) aborted()
  • (D) Abandon()

A

Admin • 833.24K Points
Coach

Q. In which type do the enumerators are stored by the compiler?

  • (A) integer
  • (B) float
  • (C) string
  • (D) All of these