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. Header files often have the file extension _____
a. .H
b. .HE
c. .HEA
d. .HEAD
View Answer Report Discuss Too Difficult!
Answer: (a)..H

2. What will happen when introduce the interface of classes in a run-time polymorphic hierarchy?
a. Separation of interface from implementation
b. Merging of interface from implementation
c. Separation of interface from debugging
d. None of the mentioned
View Answer Report Discuss Too Difficult!
Answer: (a).Separation of interface from implementation

3. Which classes are called as mixin?
a. Represent a secondary design
b. Classes express functionality which represent responsibilities
c. Standard logging stream
d. None of the mentioned
View Answer Report Discuss Too Difficult!
Answer: (b).Classes express functionality which represent responsibilities

4. What is the use of clog?
a. Standard logging stream
b. Error stream
c. Input stream
d. None of the mentioned
View Answer Report Discuss Too Difficult!
Answer: (a).Standard logging stream

5. What is the output of this program?
    #include <iostream>
    #include <sstream>
    using namespace std;
    int main()
    {
        stringstream mys(ios :: in | ios :: out);
        std :: string dat("The double value is : 74.79 .");
        mys.str(dat);
        mys.seekg(-7, ios :: end);
        double val;
        mys >> val;
        val = val*val;
        mys.seekp(-7,ios::end);
        mys << val;
        std :: string new_val = mys.str();
        cout << new_val;
        return 0;
    }
a. f
b. Error
c. Runtime error
d. None of the mentioned
View Answer Report Discuss Too Difficult!
Answer: 5593.54

6. What is the output of this program?
    #include <iostream>
    using namespace std;
    class Base
    {
        public:
            Base(){}
            ~Base(){}
            protected:
            private: 
    };
    class Derived:public Base
    {
        public:
            Derived(){}
            Derived(){}
            private:
            protected:
    };
    int main()
    {
        cout << "The program exceuted" << endl;
    }
a. The program executed
b. Error
c. Runtime error
d. None of the mentioned
View Answer Report Discuss Too Difficult!
Answer: (b).Error

7. What is the output of this program?
    #include <iostream>
    using namespace std;
    class MyException
    {
        public:
        MyException(int value) : mValue(value)
        {
        }
        int mValue;
    };
    class MyDerivedException : public MyException
    {
        public:
            MyDerivedException(int value, int anotherValue) : MyException(value),    mAnotherValue(anotherValue)
            {
            }
            int mValue;
            int mAnotherValue;
    };
    void doSomething()
    {
        throw MyDerivedException(10,20);
    }
    int main()
    {
        try
        {
            doSomething();
        }
        catch (MyDerivedException &exception)
        {
            cout << "\nCaught Derived Class Exception\n";
        }
        catch (MyException &exception)
        {
            cout << "\nCaught Base Class Exception\n";
        }
        return 0;
    }
a. Caught Base Class Exception
b. Caught Derived Class Exception
c. Caught Base & Derived Class Exception
d. None of the mentioned
View Answer Report Discuss Too Difficult!
Answer: (b).Caught Derived Class Exception

8. What is the output of this program?
    #include <iostream>
    #include <string>
    using namespace std;
    int main() 
    {
        string s = "a long string";
        s.insert(s.size() / 2, " * ");
        cout << s << endl;
        return 0;
    }
a. a long* string
b. a long st*ring
c. Depends on compiler
d. None of the mentioned
View Answer Report Discuss Too Difficult!
Answer: (c).Depends on compiler

9. How many types of guarantees are there in exception class can have?
a. 1
b. 2
c. 3
d. 4
View Answer Report Discuss Too Difficult!
Answer: (c).3

10. Which operator is used to create the user-defined streams in c++?
a. >>
b. <<
c. &
d. Both >> & <<
View Answer Report Discuss Too Difficult!
Answer: (d).Both >> & <<

Page 1 of 15