A directory of Objective Type Questions covering all the Computer Science subjects. Here you can access and discuss Multiple choice questions and answers for various compitative exams and interviews.

1. Which operator is used to signify the namespace?
a. conditional operator
b. ternary operator
c. scope operator
d. none of the mentioned
View Answer Report Discuss Too Difficult!
Answer: (c).scope operator

2. Identify the correct statement.
a. Namespace is used to group class, objects and functions
b. Namespace is used to mark the beginning of the program
c. Namespace is used to seperate the class, objects
d. None of the mentioned
View Answer Report Discuss Too Difficult!
Answer: (a).Namespace is used to group class, objects and functions

3. What is the use of Namespace?
a. To encapsulate the data
b. To structure a program into logical units
c. Encapsulate the data & structure a program into logical units
d. None of the mentioned
View Answer Report Discuss Too Difficult!
Answer: (b).To structure a program into logical units

4. What is the general syntax for accessing the namespace variable?
a. namespaceid::operator
b. namespace,operator
c. namespace#operator
d. none of the mentioned
View Answer Report Discuss Too Difficult!
Answer: (a).namespaceid::operator

5. What is the output of this program?
    #include <iostream>
    using namespace std;
    namespace first
    {
        int var = 5;
    }
    namespace second
    {
        double var = 3.1416;
    }
    int main ()
    {
        int a;
        a = first::var + second::var;
        cout << a;
        return 0;
   }
a. 8.31416
b. 8
c. 9
d. compile time error
View Answer Report Discuss Too Difficult!
Answer: (b).8

6. What is the output of these program?
    #include <iostream>
    using namespace std;
    namespace first
    {
        int x = 5;
        int y = 10;
    }
    namespace second
    {
        double x = 3.1416;
        double y = 2.7183;
    }
    int main ()
    {
        using first::x;
        using second::y;
        bool a, b;
        a = x > y;
        b = first::y < second::x;
        cout << a << b;
        return 0;
    }
a. 11
b. 01
c. 00
d. 10
View Answer Report Discuss Too Difficult!
Answer: (d).10

7. What is the output of this program?
    #include <iostream>
    using namespace std;
    namespace Box1
    {
        int a = 4;
    }
    namespace Box2
    {
        int a = 13;
    }
    int main ()
    {
        int a = 16;
        Box1::a;
        Box2::a;
        cout << a;
        return 0;
    }
a. 4
b. 13
c. 16
d. compile time error
View Answer Report Discuss Too Difficult!
Answer: (c).16

8. What is the output of this program?
    #include <iostream>
    using namespace std
    namespace space
    {
        int x = 10;
    }
    namespace space
    {
        int y = 15;
    }
    int main(int argc, char * argv[])
    {
        space::x = space::y =5;
        cout << space::x << space::y;
    }
a. 1015
b. 1510
c. 55
d. compile time error
View Answer Report Discuss Too Difficult!
Answer: (c).55

9. What is the output of this program?
    #include <iostream>
    using namespace std;
    namespace extra
    {
        int i;
    }
    void i()
    {
        using namespace extra;
        int i;
        i = 9;
        cout << i;
    }
    int main()
    {
        enum  letter { i, j};
        class i { letter j; };
        ::i();
        return 0;
    }
a. 9
b. 10
c. compile time error
d. none of the mentioned
View Answer Report Discuss Too Difficult!
Answer: (a).9

10. Which keyword is used to access the variable in namespace?
a. using
b. dynamic
c. const
d. static
View Answer Report Discuss Too Difficult!
Answer: (a).using

Page 1 of 2