C++ MCQs with answers Page - 23

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. Default values for a function are specified when ____ .

  • (A) function is declared
  • (B) function is defined
  • (C) Both a and b
  • (D) None of these

A

Admin • 833.24K Points
Coach

Q. Predict the output:

Code:
float x= 3.1496;
cout << setpricision(2) << x;
  • (A) 3.15
  • (B) 3.14
  • (C) 3.00
  • (D) None of these

A

Admin • 833.24K Points
Coach

Q. In case of binary operator overloading with member function, which of following statement should be taken into consideration?

  • (A) Left hand operand must be object.
  • (B) Right hand operand must be object.
  • (C) Both the operands must be objects.
  • (D) All of these should be considered.

A

Admin • 833.24K Points
Coach

Q. Which of the following statements is correct?

  • (A) The keyword “struct” is required in C and C++ while declaring a structure object.
  • (B) The keyword “struct” is not required in C but required in C++ when declaring a structure object.
  • (C) The keyword “struct” is not required in C++ but required in C when declaring a structure object.
  • (D) The keyword “struct” is not required in C and C++ when declaring a structure object

A

Admin • 833.24K Points
Coach

Q. Which of the following statements is correct?

  • (A) A structure can have a member function in C and in C++.
  • (B) A structure cannot have a member function in C++ but it is possible in C.
  • (C) A structure cannot have a member function in C and C++.
  • (D) A structure cannot have a member function in C, but it is possible in C++.

A

Admin • 833.24K Points
Coach

Q. What happens if the following program is run in C and C++?

Code:
#include <stdio.h> 
void main() 
{ 
  printf("Hello World"); 
}
  • (A) Error in C++ and success in C
  • (B) Warning in C and C++
  • (C) Error in C and C++
  • (D) Error in C and success in C++

A

Admin • 833.24K Points
Coach

Q. Which of the following statements correctly declares an array?

  • (A) int [10]arr;
  • (B) arr{10};
  • (C) int arr[10];
  • (D) int arr;

A

Admin • 833.24K Points
Coach

Q. What is the index of the last element of an array with 5 elements?

  • (A) 4
  • (B) 5
  • (C) 0
  • (D) Defined by the porgrammer

A

Admin • 833.24K Points
Coach

Q. What is the correct definition of an array?

  • (A) An array is a set of elements of the same type stored in non-contiguous memory locations
  • (B) An array is a set of elements of the same type stored in contiguous memory locations
  • (C) An array is a set of elements
  • (D) None of the above

A

Admin • 833.24K Points
Coach

Q. Which of the following statements is correct about this pointer in C++?

  • (A) this pointer is passed as a hidden argument in all non-static functions of a class
  • (B) this pointer is passed as a hidden argument in all functions of a class.
  • (C) this pointer is passed as a hidden argument in all static functions of a class.
  • (D) None of the above

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