Question 81

What is the output of the program if character 4 is supplied as input?
#include <iostream> using namespace std; int main () {
int c;
cin >> c;
try
{
switch (c)
{
case 1:
throw 20;
case 2:
throw 5.2f;
case 3:
throw 'a';
default:
cout<<"No exception";
}
}
catch (int e)
{ cout << "int exception. Exception Nr. " << e; }
catch (float e)
{ cout << "float exception. Exception Nr. " << e; }
catch (...)
{ cout << "An exception occurred."; }
return 0;
}
  • Question 82

    What is the output of the program?
    #include <iostream>
    using namespace std;
    class Base {
    static int age;
    public:
    Base () {};
    ~Base () {};
    void setAge(int a=10) {age = a;}
    void Print() { cout << age;}
    };
    int Base::age=0;
    int main () {
    Base a,*b;
    b = new Base();
    a.setAge();
    b?>setAge(20);
    a.Print();
    b?>Print();
    return 0;
    }
  • Question 83

    What happens when you attempt to compile and run the following code?
    #include <iostream>
    using namespace std;
    class A {
    public:
    void Print(){ cout<<"A"; }
    };
    class B:public A {
    public:
    virtual void Print(){ cout<< "B"; }
    };
    class C:public B {
    public:
    void Print(){ cout<< "C"; }
    };
    int main()
    {
    A ob1;
    B ob2;
    C ob3;
    A *obj;
    obj = &ob1;
    obj>Print();
    obj = &ob2;
    obj>Print();
    obj = &ob3;
    obj>Print();
    }
  • Question 84

    Which of the following statements are correct?
  • Question 85

    What happens when you attempt to compile and run the following code?
    #include <iostream>
    using namespace std;
    int main()
    {
    int i = 0;
    do {
    i++;
    if (i==3)
    break;
    cout<<i;
    }
    while(i < 5);
    return 0;
    }