C++ MCQs with answers Page - 18

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 followings is/are not false about friend function ?

1. It can be called / invoked with class object.
2. It has objects as arguments.
3. It can have built-in types as arguments.
4. It must declared only in public part of a class.
5. It does not have this pointer as an argument.

  • (A) Only 2,4
  • (B) Only 1,2,5
  • (C) Only 2,3,5
  • (D) All of these

A

Admin • 833.24K Points
Coach

Q. Predict the output:

Code:
int x = 786;
cout << setfill(‘*’) << setw(6) << x;
  • (A) 786***
  • (B) **786
  • (C) ***786
  • (D) ******

A

Admin • 833.24K Points
Coach

Q. Default return type of functions in CPP is ____ .

  • (A) void
  • (B) long
  • (C) char
  • (D) Int

A

Admin • 833.24K Points
Coach

Q. During a class inheritance in CPP, if the visibility mode or mode of derivation is not provided, then by default visibility mode is ___________.

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

A

Admin • 833.24K Points
Coach

Q. The derivation of Child class from Base class is indicated by ____ symbol.

  • (A) ::
  • (B) :
  • (C) ;
  • (D) |

A

Admin • 833.24K Points
Coach

Q. If we have object from fstream class, then what is the default mode of opening the file?

  • (A) ios::in|ios::out
  • (B) ios::in|ios::out|ios::trunc
  • (C) ios::in|ios::trunc
  • (D) Default mode depends on compiler

A

Admin • 833.24K Points
Coach

Q. __________ is return type of is_open() function.

  • (A) int
  • (B) bool
  • (C) float
  • (D) char *

A

Admin • 833.24K Points
Coach

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

Code:
#include<stdio.h>
int main() 
{ 
   display();
}  
int display() 
{ 
   printf("Hello World!"); 
   return 0;  
}
  • (A) Error in C and C++
  • (B) Warning in C and C++
  • (C) Error in C++ but warning in C
  • (D) Error in C but warning in C++

A

Admin • 833.24K Points
Coach

Q. Which of the following types is not present in C but present in C++?

  • (A) void
  • (B) bool
  • (C) float
  • (D) int

A

Admin • 833.24K Points
Coach

Q. What is the size of a boolean variable in C++?

  • (A) 1 bit
  • (B) 1 byte
  • (C) 4 bytes
  • (D) 2 bytes

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