Namespaces

1

Which keyword is used to access the variable in namespace?

A. using
B. dynamic
C. const
D. static

2

What is the output of this program?

1.
    #include 
2.
    using namespace std;
3.
    namespace extra
4.
    {
5.
        int i;
6.
    }
7.
    void i()
8.
    {
9.
        using namespace extra;
10.
        int i;
11.
        i = 9;
12.
        cout << i;
13.
    }
14.
    int main()
15.
    {
16.
        enum  letter { i, j};
17.
        class i { letter j; };
18.
        ::i();
19.
        return 0;
20.
    }
A. 9
B. 10
C. compile time error
D. none of the mentioned

3

What is the output of this program?

1.
    #include 
2.
    using namespace std
3.
    namespace space
4.
    {
5.
        int x = 10;
6.
    }
7.
    namespace space
8.
    {
9.
        int y = 15;
10.
    }
11.
    int main(int argc, char * argv[])
12.
    {
13.
        space::x = space::y =5;
14.
        cout << space::x << space::y;
15.
    }
A. 1015
B. 1510
C. 55
D. compile time error

4

What is the output of this program?

1.
    #include 
2.
    using namespace std;
3.
    namespace Box1
4.
    {
5.
        int a = 4;
6.
    }
7.
    namespace Box2
8.
    {
9.
        int a = 13;
10.
    }
11.
    int main ()
12.
    {
13.
        int a = 16;
14.
        Box1::a;
15.
        Box2::a;
16.
        cout << a;
17.
        return 0;
18.
    }
A. 4
B. 13
C. 16
D. compile time error

5

What is the output of these program?

1.
    #include 
2.
    using namespace std;
3.
    namespace first
4.
    {
5.
        int x = 5;
6.
        int y = 10;
7.
    }
8.
    namespace second
9.
    {
10.
        double x = 3.1416;
11.
        double y = 2.7183;
12.
    }
13.
    int main ()
14.
    {
15.
        using first::x;
16.
        using second::y;
17.
        bool a, b;
18.
        a = x > y;
19.
        b = first::y < second::x;
20.
        cout << a << b;
21.
        return 0;
22.
    }
A. 11
B. 01
C. 00
D. 10