adplus-dvertising
frame-decoration

Question

What is the output of the following program?
class Test
{
 private: static int x;
 public: static void fun()
 {
  cout << ++x << “ ”;
 }
};
int Test :: x =20;
void main()
{
 Test x;
 x.fun();
 x.fun();
}

a.

20 22

b.

20 21

c.

21 22

d.

22 23

Answer: (c).21 22

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of the following program?