C++ MCQs with answers Page - 16

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 function is used to write a single character to the console in C++?

  • (A) printf(c)
  • (B) write(c)
  • (C) cout.put(c)
  • (D) cout.putline(c)

A

Admin • 833.24K Points
Coach

Q. The size of an object or type can be determined with which operator?

  • (A) malloc
  • (B) sizeof
  • (C) malloc
  • (D) calloc

A

Admin • 833.24K Points
Coach

Q. Which of the following are true about static member function?

1. They can access non-static data members.
2. They can call only other static member functions.
3. They can access global functions and data.
4. They can have this pointer.
5. They cannot be declared as const or volatile.

  • (A) Only 2
  • (B) Only 2,5
  • (C) Only 2,3,4,5
  • (D) Only 2 , 3 , 5

A

Admin • 833.24K Points
Coach

Q. class X, class Y and class Z are derived from class BASE. This is ______ inheritance.

  • (A) Multiple
  • (B) Multilevel
  • (C) Hierarchical
  • (D) Single

A

Admin • 833.24K Points
Coach

Q. When base class is derived in protected mode, then_____________ .

1. public members of base class become private members of derived class.
2. public members of base class become protected members of derived class.
3. public members of base class become public members of derived class.
4. protected members of base class become protected members of derived class.
5. protected members of base class become private members of derived class.
6. protected members of base class become public members of derived class.

  • (A) Only 1, 5
  • (B) Only 1, 6
  • (C) Only 2, 6
  • (D) Only 2, 4

A

Admin • 833.24K Points
Coach

Q. Streams that will be performing both input and output operations must be declared as class _________ .

  • (A) iostream
  • (B) fstream
  • (C) stdstream
  • (D) Stdiostream

A

Admin • 833.24K Points
Coach

Q. Exception handlers are declared with ____________ keyword.

  • (A) Try
  • (B) catch
  • (C) throw
  • (D) Finally

A

Admin • 833.24K Points
Coach

Q. How many times does the “cout” in line 12 run?

Code:
#include  
using namespace std; 
  
int main() 
{ 
    int n = 10; 
    for (int i = 0; i < n; i++ ) 
    { 
        n++; 
        continue; 
        cout << n; 
    } 
  
    return 1;
}
  • (A) 10
  • (B) 11
  • (C) 1
  • (D) The “cout” never runs.

A

Admin • 833.24K Points
Coach

Q. Which of the following operators is called “Input Flow Operator”?

  • (A) <<
  • (B) >>
  • (C) >
  • (D) <

A

Admin • 833.24K Points
Coach

Q. Which of the following operators is called “Output Flow Operator”?

  • (A) <<
  • (B) >>
  • (C) >
  • (D) <

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