Multiple choice

What is the output of C++ program given below?

#include<iostream> using namespace std; class A { public: A() { cout<<"Constructor of A"<<endl; } void Test(); }; void A::Test() { cout<<"This is Test"<<endl; } int main() { A a; a.Test();
}

  1. This is Test

  2. This is Test Constructor of A

  3. Constructor of A This is Test

  4. Error in the program

  5. None of the above

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

A a;    //creates object for class A, which calls default constructor Hence Constructor of A gets displayed first.a.Test();        //Now we call Test() using class object which prints message inside Test(). i.e This is Test As it matches with output given in this option , Hence true.