1. Question: Consider the sample code given below and answer the question that follows.
    class Shape
    {
    public:
    virtual void draw() = 0;
    };
    
    class Rectangle: public Shape
    {
    public:
    void draw()
    {
    // Code to draw rectangle
    }
    //Some more member functions.....
    };
    
    class Circle : public Shape
    {
    public:
    void draw()
    {
    // Code to draw circle
    }
    //Some more member functions.....
    };
    
    int main()
    {
    Shape objShape;
    objShape.draw();
    }
    What happens if the above program is compiled and executed?

    A
    Object objShape of Shape class will be created

    B
    A compile time error will be generated because you cannot declare Shape objects

    C
    A compile time error will be generated because you cannot call draw function of class 'Shape'

    D
    A compile time error will be generated because the derived class's draw() function cannot override the base class draw() function

    E
    None

    Note: Not available
    1. Report
  2. Question: Which of the following is NOT a standard sorting algorithm:

    A
    std::sort

    B
    std::qsort

    C
    std::stable_sort

    D
    std::partial_sort

    Note: Not available
    1. Report
  3. Question: Consider the sample code given below and answer the question that follows.
    class Person
    {
        string name;
        int age;
        Person *spouse;
    public:
        Person(string sName);
        Person(string sName, int nAge);
        Person(const Person& p);
    
        Copy(Person *p);
        Copy(const Person &p);
        SetSpouse(Person *s);
    };
    Which one of the following are declarations for a copy constructor?

    A
    Person(string sName);

    B
    Person(string sName, int nAge);

    C
    Copy(Person *p);

    D
    Person(const Person &p);

    E
    Copy(const Person &p)?

    Note: Not available
    1. Report
  4. Question: Consider two classes A and B:
    class A
    {
    
    private:
    
        int x;
        float y;
    
    public:
    
    friend class B;
    };
    
    class B
    {
    };
    Which of the following is true?

    A
    A can access all private data members of B

    B
    B can access all private data members of A

    C
    A cannot access the private members of B

    D
    B cannot access the private members of A

    E
    Both A and B can access each other's private data members

    Note: Not available
    1. Report
  5. Question: Which of the following statements are true for operator overloading in C++?

    A
    The * operator can be overloaded to perform division

    B
    The * operator can be overloaded to perform assignment

    C
    ** can be overloaded to perform "to the power of"

    D
    Operators can be overloaded only in inside classes

    E
    Operators can be overloaded globally

    Note: Not available
    1. Report
  6. Question: Consider the following code:
    class BaseException
    {
       public:
       virtual void Output()
       {
          cout << "Base Exception" << endl;
       }
    };
    
    class DerivedException : public BaseException
    {
       public:
       virtual void Output()
       {
          cout << "Derived Exception" << endl;
       }
    };
    
    void ExceptionTest()
    {
       try
       {
          throw new DerivedException();
       }
       catch (DerivedException ex)
       {
          ex.Output();
       }
       catch (...)
       {
          cout << "Unknown Exception Thrown!" << endl;
       }
    }
    Invoking Exception Test will result in which output?

    A
    Base Exception

    B
    Derived Exception

    C
    Unknown Exception Thrown

    D
    No Output will be generated

    Note: Not available
    1. Report
  7. Question: Which of the following statements are true about C++ vector class?

    A
    vector::empty deletes all elements of the vector

    B
    vector::erase can be used to delete a single element and a range of elements of the vector

    C
    After calling, vector::erase causes some of the iterators referencing the vector to become invalid

    D
    vector::count returns the number of elements in the vector

    E
    vector::size returns the number of elements in the vector

    F
    vector::capacity returns the number of elements in the vector

    Note: Not available
    1. Report
  8. Question: Consider the following code:
    class BaseException
    {
    public:
        virtual void Output()
        {
        cout << "Base Exception" << endl;
        }
    };
    
    class DerivedException : public BaseException
    {
    public:
        virtual void Output()
        {
        cout << "Derived Exception" << endl;
        }
    };
    
    void ExceptionTest()
    {
        try
        {
              throw DerivedException();
        }
        catch (BaseException ex)
        {
              ex.Output();
        }
        catch (...)
        {
              cout << "Unknown Exception Thrown!" << endl;
        }
    }
    Invoking Exception Test will result in which output?

    A
    Base Exception

    B
    Derived Exception

    C
    Unknown Exception Thrown

    D
    No Output will be generated

    Note: Not available
    1. Report
  9. Question: Which of the following statements are true?

    A
    Inline functions should be preferred over macros because inline functions have better performance

    B
    Macro usage should be avoided because they are error prone

    C
    Normal functions should be preferred over macros because normal functions have better performance

    D
    Macro usage should be avoided because macros do not perform type checking

    E
    Inline functions should be preferred over macros because inline functions perform type checking

    Note: Not available
    1. Report
  10. Question: Base class members are made accessible to a derived class and inaccessible to rest of the program by _____.

    A
    public access specifier

    B
    private access specifier

    C
    protected access specifier

    D
    friend access specifier

    Note: Not available
    1. Report
Copyright © 2024. Powered by Intellect Software Ltd