C++ MCQs with answers Page - 142

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 is used to handle exceptions in C++?

  • (A) try-catch block
  • (B) throw-catch block
  • (C) error-exception block
  • (D) catch-throw block

A

Admin • 833.24K Points
Coach

Q. Which of the following is a valid C++ identifier?

  • (A) 123variable
  • (B) variable_123
  • (C) @variable
  • (D) variable#123

A

Admin • 833.24K Points
Coach

Q. What is the purpose of the 'main' function in C++?

  • (A) It is the entry point for program execution.
  • (B) It is used for error handling.
  • (C) It defines the program's logic.
  • (D) It is used to define global variables.

A

Admin • 833.24K Points
Coach

Q. Which of the following operators is used to access members of a class in C++?

  • (A) .
  • (B) ->
  • (C) ::
  • (D) []

A

Admin • 833.24K Points
Coach

Q. What will be the output of the following C++ code?

int x = 10;
int y = 5;
cout << x / y;

  • (A) 5
  • (B) 2
  • (C) 10
  • (D) None of the above

A

Admin • 833.24K Points
Coach

Q. Which of the following is the correct way to declare a pointer in C++?

  • (A) int* ptr;
  • (B) ptr int*;
  • (C) pointer int*;
  • (D) int ptr*;

A

Admin • 833.24K Points
Coach

Q. What is the size of the 'int' data type in C++?

  • (A) 2 bytes
  • (B) 4 bytes
  • (C) 8 bytes
  • (D) Depends on the compiler

A

Admin • 833.24K Points
Coach

Q. Which of the following is the correct syntax for a constructor in C++?

  • (A) void Constructor() {}
  • (B) Constructor() {}
  • (C) Constructor(void) {}
  • (D) void constructor() {}

A

Admin • 833.24K Points
Coach

Q. What will be the output of the following code?

int a = 5;
cout << ++a;

  • (A) 5
  • (B) 6
  • (C) Error
  • (D) None of the above

A

Admin • 833.24K Points
Coach

Q. Which of the following access specifiers makes a class member accessible only within the class and its friends?

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

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