Questions and Answers


  1. Identify the correct statement.











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    By using typedef, we can create a type of pre-existing type only not our own type of data.


  1. What does the data type defined by union will do?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Union is used to define the data types of our choice and it will store the data type in one location make them accessible.



  1. What is the output of this program?
    #include <iostream>
    #include <exception>
    using namespace std;
    class BaseClass
    {
    virtual void dummy() {}
    };
    class DerivedClass: public BaseClass
    {
    int num;
    };
    int main ()
    {
    try
    {
    BaseClass * ptr1 = new DerivedClass;
    BaseClass * ptr2 = new BaseClass;
    DerivedClass * ptr3;
    ptr3 = dynamic_cast(ptr1);
    if (ptr3 == 0)
    cout << "Null pointer on first type-cast" << endl;
    ptr3 = dynamic_cast(ptr2);
    if (ptr3 == 0)
    cout << "Null pointer on second type-cast" << endl;
    }
    catch (exception& excep)
    {
    cout << "Exception: " << excep.what();
    }
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    In this program, We apply the dynamic cast to ptr3. Based on the value in the ptr3, it produces the output.


  1. To which type of class, We can apply RTTI?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    RTTI is available only for classes which are polymorphic, which means they have at least one virtual method.



  1. Which operators are part of RTTI?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    The dynamic_cast<> operation and typeid operator in C++ are part of RTTI.