250+ TOP MCQs on Void and Answers

This section on C++ language interview questions and answers on “Void”. One shall practice these interview questions to improve their C++ programming skills needed for various interviews (campus interviews, walk-in interviews, company interviews), placements, entrance exams and other competitive exams. These questions can be attempted by anyone focusing on learning C++ programming language. They can be a beginner, fresher, engineering graduate or an experienced IT professional. Our C++ language interview questions come with the detailed explanation of the answers which helps in better understanding of C++ concepts.

Here is a listing of C++ language interview questions on “Void” along with answers, explanations and/or solutions:

1. Which of the following will not return a value?
a) null
b) void
c) empty
d) free
Answer: b
Clarification: Because void represents an empty set of values so nothing will be return.

2. ______________ have the return type void.
a) all functions
b) constructors
c) destructors
d) none of the mentioned
Answer: d
Clarification: Constructor creates an Object and Destructor destroys the object. They are not supposed to return anything, not even void.

3. What does the following statement mean?

a) variable a is of type void
b) a is an object of type void
c) declares a variable with value a
d) flags an error
Answer: d
Clarification: There are no void objects.

4. Choose the incorrect option.
a) void is used when the function does not return a value
b) void is also used when the value of a pointer is null
c) void is used as the base type for pointers to objects of unknown type
d) void is a special fundamental type
Answer: b
Clarification: void fundamental type is used in the cases of a and c.

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

  1.     #include 
  2.     using namespace std;
  3.     int main()
  4.     {
  5.         void a = 10, b = 10;
  6.         int c;
  7.         c = a + b;
  8.         cout << c;
  9.         return 0;
  10.     }

a) 20
b) compile time error
c) runtime error
d) 40
Answer: b
Clarification: void will not accept any values to its type.

Leave a Reply

Your email address will not be published. Required fields are marked *