For the class exforsys defined as below: class exforsys() { }; int main() { exforsys a; } Which of the following is TRUE?

  1. No default constructor is provided by the compiler

  2. The compiler provides the default constructor

  3. The compiler generates error

  4. None of the Above


Correct Option: B
Explanation:

In the given code, a class named "exforsys" is defined. It does not have any member variables or functions.

Now, let's go through each option and determine which one is true:

A. No default constructor is provided by the compiler: This option is incorrect. By default, if no constructor is defined in a class, the compiler provides a default constructor. So, this option is false.

B. The compiler provides the default constructor: This option is correct. When no constructor is defined in a class, the compiler automatically generates a default constructor. So, this option is true.

C. The compiler generates an error: This option is incorrect. Since the class does not have any member variables or functions, there is no reason for the compiler to generate an error. So, this option is false.

D. None of the above: This option is incorrect. As explained earlier, the correct answer is option B. So, this option is false.

Therefore, the correct answer is:

B. The compiler provides the default constructor.

Find more quizzes: