Cpp : Constructors And Destructors 16

11.
What is the output of this program?

#include <iostream>

using namespace std;

class catalyst
{
int x;
public:
catalyst(int xx, float yy)
{
cout<< char(yy);
}
};
int main()
{
//catalyst *p = new catalyst(35, 99.50f);
//or
catalyst a1(35, 99.50f);
return 0;
}

A. 99
B. ASCII value of 99
C. Garbage value
D. 99.5


12.
What is the output of this program?

#include <iostream>

using namespace std;

class catalyst
{
public:
catalyst()
{
cout<< “find”;
}
~catalyst()
{
cout<< “course”;
}
};
int main()
{
catalyst obj;
return 0;
}

A. The program will print the output find.
B. The program will print the output course.
C. The program will print the output findcourse.
D. The program will report compile time error.

13.
What is the output of this program?

#include <iostream>

using namespace std;

class catalyst
{
int x;
public:
catalyst();
~catalyst();
void Show() const;
};
catalyst::catalyst()
{
x = 50;
}

void catalyst::Show() const
{
cout<< x;
}

int main()
{
catalyst obj;
obj.Show();
return 0;
}

A. The program will print the output 50.
B. The program will print the output Garbage-value.
C. The program will report compile time error.
D. The program will report runtime error.

14.
Which of the following statement is correct about the program given below?

#include <iostream>

using namespace std;

class catalyst
{
int p;
public:
catalyst(int xx, char ch)
{
p = xx + int(ch);
cout<< p;
}
~catalyst()
{

}
};
int main()
{
catalyst obj(15, ‘A’);
return 0;
}

A. The program will print the output 80.
B. The program will print the output 112.
C. The program will print the output garbage value.
D. The program will report compile time error.

15.
Which of the following is true about the following program

#include <iostream>

using namespace std;

class catalyst
{
int x;
public:
catalyst(short ss)
{
cout<< “Short” << endl;
}
catalyst(int xx)
{
cout<< “Int” << endl;
}
catalyst(float ff)
{
cout<< “Float” << endl;
}
~catalyst()
{
//cout<< “Final”;
}
};
int main()
{
//catalyst *ptr = new catalyst(‘F’);

catalyst obj(‘F’);
return 0;
}
A. The program will print the output Short .
B. The program will print the output Final .
C. The program will print the output Float .
D. The program will print the output Int.