Home / C++ Programming / Objects and Classes :: General Questions

C++ Programming :: Objects and Classes

  1. Which of the following can access private data members or member functions of a class?

  2. A.
    Any function in the program.
    B.
    All global functions in the program.
    C.
    Any member function of that class.
    D.
    Only public member functions of that class.

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. Which of the following type of data member can be shared by all instances of its class?

  4. A.
    Public
    B.
    Inherited
    C.
    Static
    D.
    Friend

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. Which of the following also known as an instance of a class?

  6. A.
    Friend Functions
    B.
    Object
    C.
    Member Functions
    D.
    Member Variables

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. Constructor is executed when _____.

  8. A.
    an object is created
    B.
    an object is used
    C.
    a class is declared
    D.
    an object goes out of scope.

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. Which of the following statements about virtual base classes is correct?

  10. A.
    It is used to provide multiple inheritance.
    B.
    It is used to avoid multiple copies of base class in derived class.
    C.
    It is used to allow multiple copies of base class in a derived class.
    D.
    It allows private members of the base class to be inherited in the derived class.

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. How many objects can be created from an abstract class?

  12. A.
    Zero
    B.
    One
    C.
    Two
    D.
    As many as we want

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. What does the class definitions in following code represent?

    class Bike {     Engine objEng; }; class Engine {     float CC; };

  14. A.
    kind of relationship
    B.
    has a relationship
    C.
    Inheritance
    D.
    Both A and B

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. Which of the following statements is correct when a class is inherited privately?

  16. A.
    Public members of the base class become protected members of derived class.
    B.
    Public members of the base class become private members of derived class.
    C.
    Private members of the base class become private members of derived class.
    D.
    Public members of the base class become public members of derived class.

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. Which of the following statements is correct?

  18. A.
    Data items in a class must be private.
    B.
    Both data and functions can be either private or public.
    C.
    Member functions of a class must be private.
    D.
    Constructor of a class cannot be private.

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. What does a class hierarchy depict?

  20. A.
    It shows the relationships between the classes in the form of an organization chart.
    B.
    It describes "has a" relationships.
    C.
    It describes "kind of" relationships.
    D.
    It shows the same relationship as a family tree.

    View Answer

    Workspace

    Discuss Discuss in Forum