Class Hierarchies Introduction

1

What does the cerr represent?

A. Standard error stream
B. Standard logging stream
C. Input stream
D. Output stream

2

Which operator is used to create the user-defined streams in c++?

A. >>
B. <<
C. &
D. Both a & b

3

How many types of guarantees are there in exception class can have?

A. 1
B. 2
C. 3
D. 4

4

What is the output of this program?

1.
    #include 
2.
    #include 
3.
    using namespace std;
4.
    int main() 
5.
    {
6.
        string s = "a long string";
7.
        s.insert(s.size() / 2, " * ");
8.
        cout << s << endl;
9.
        return 0;
10.
    }
A. a long* string
B. a long st*ring
C. Depends on compiler
D. None of the mentioned

5

What is the output of this program?

1.
    #include 
2.
    using namespace std;
3.
    class MyException
4.
    {
5.
        public:
6.
        MyException(int value) : mValue(value)
7.
        {
8.
        }
9.
        int mValue;
10.
    };
11.
    class MyDerivedException : public MyException
12.
    {
13.
        public:
14.
            MyDerivedException(int value, int anotherValue) : MyException(value),    mAnotherValue(anotherValue)
15.
            {
16.
            }
17.
            int mValue;
18.
            int mAnotherValue;
19.
    };
20.
    void doSomething()
21.
    {
22.
        throw MyDerivedException(10,20);
23.
    }
24.
    int main()
25.
    {
26.
        try
27.
        {
28.
            doSomething();
29.
        }
30.
        catch (MyDerivedException &exception)
31.
        {
32.
            cout << "\nCaught Derived Class Exception\n";
33.
        }
34.
        catch (MyException &exception)
35.
        {
36.
            cout << "\nCaught Base Class Exception\n";
37.
        }
38.
        return 0;
39.
    }
A. Caught Base Class Exception
B. Caught Derived Class Exception
C. Both a & b
D. None of the mentioned