Solved

What Is the Output of the Following Program?
#Include \quad

Question 28

Multiple Choice

What is the output of the following program?
#include <iostream>
using namespace std;
class TestClass
{
\quad private:
\quad\quad int val;
\quad\quad void showVal()
\quad\quad { cout << val << endl; }
\quad public:
\quad\quad TestClass(int x)
\quad\quad { val = x; }
};
int main()
{
\quad TestClass test(77) ;
\quad test.showVal() ;
\quad return 0;
}


A) The program runs, but with no output.
B) 77
C) 0
D) The program will not compile.

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions