C++ MCQs with answers Page - 22

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. When a class is defined inside any function or block, it is called ___________ .

  • (A) Nested class
  • (B) Block class
  • (C) Local class
  • (D) It is not possible

A

Admin • 833.24K Points
Coach

Q. Identify the incorrect option.

  • (A) enumerator values start from 0 by default
  • (B) enumerators are same as macros
  • (C) enumerators are constants
  • (D) enumerators are user-defined types

A

Admin • 833.24K Points
Coach

Q. What is the output of this program?

Code:
#include 
    using namespace std;
    int main()
    {
        void num0 = 15, num1 = 16;
        int num2;
        num2 = num0 + num1;
        cout << num2;
        return 0;
    }
  • (A) 31
  • (B) Runtime Error
  • (C) Compile time Error
  • (D) All of above

A

Admin • 833.24K Points
Coach

Q. Which of the followings are false statements about Local class?

1. A local class type name can only be used in the enclosing function
2. All the methods of Local classes must be defined inside the class only
3. A Local class can contain static data members.
4. A Local class may contain static functions.
5. Non-static variables of the enclosing function are not accessible inside local classes.
6. Local classes cannot access global types, variables and functions.

  • (A) Only 3, 6
  • (B) Only 1,3
  • (C) Only 2 , 4 , 6
  • (D) None of these

A

Admin • 833.24K Points
Coach

Q. Choose the incorrect option

  • (A) void is used as the base type for pointers to objects of unknown type
  • (B) void is a special fundamental type
  • (C) void is used when the function does not return a value
  • (D) void is also used when the value of a pointer is null

A

Admin • 833.24K Points
Coach

Q. What does the following statement mean?

Code:
void a;
  • (A) flags an error
  • (B) declares a variable with value a
  • (C) a is an object of type void
  • (D) variable a is of type void

A

Admin • 833.24K Points
Coach

Q. If an argument to a function is declared as const, then _______ .

  • (A) Function can’t modify the argument.
  • (B) function can modify the argument.
  • (C) const argument to a function is not possible.
  • (D) None of these

A

Admin • 833.24K Points
Coach

Q. ___ have the return type void?

  • (A) constructors
  • (B) all functions
  • (C) destructors
  • (D) None of these

A

Admin • 833.24K Points
Coach

Q. Return type of uncaught_exception() is ________________ .

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

A

Admin • 833.24K Points
Coach

Q. Which of the following will not return a value?

  • (A) void
  • (B) free
  • (C) null
  • (D) empty

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