A PHP Error was encountered

Severity: Warning

Message: A non-numeric value encountered

Filename: controllers/home.php

Line Number: 222

A PHP Error was encountered

Severity: Warning

Message: A non-numeric value encountered

Filename: controllers/home.php

Line Number: 228

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

C++ Programming :: Objects and Classes

  1. What happens when we try to compile the class definition in following code snippet?

    class Birds {}; class Peacock : protected Birds {};

  2. A.
    It will not compile because class body of Birds is not defined.
    B.
    It will not compile because class body of Peacock is not defined.
    C.
    It will not compile because a class cannot be protectedly inherited from other class.
    D.
    It will compile succesfully.

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. Which of the following statements is incorrect?

  4. A.
    Friend keyword can be used in the class to allow access to another class.
    B.
    Friend keyword can be used for a function in the public section of a class.
    C.
    Friend keyword can be used for a function in the private section of a class.
    D.
    Friend keyword can be used on main().

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. Which of the following statement is correct regarding destructor of base class?

  6. A.
    Destructor of base class should always be static.
    B.
    Destructor of base class should always be virtual.
    C.
    Destructor of base class should not be virtual.
    D.
    Destructor of base class should always be private.

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. Which of the following two entities (reading from Left to Right) can be connected by the dot operator?

  8. A.
    A class member and a class object.
    B.
    A class object and a class.
    C.
    A class and a member of that class.
    D.
    A class object and a member of that class.

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. How can we make a class abstract?

  10. A.
    By making all member functions constant.
    B.
    By making at least one member function as pure virtual function.
    C.
    By declaring it abstract using the static keyword.
    D.
    By declaring it abstract using the virtual keyword.

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. Which of the following statements is correct when a class is inherited publicly?

  12. 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 protected members of derived class.
    D.
    Public members of the base class become public members of derived class.

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. Which of the following statements is correct about the constructors and destructors?

  14. A.
    Destructors can take arguments but constructors cannot.
    B.
    Constructors can take arguments but destructors cannot.
    C.
    Destructors can be overloaded but constructors cannot be overloaded.
    D.
    Constructors and destructors can both return a value.

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. Which of the following access specifies is used in a class definition by default?

  16. A.
    Protected
    B.
    Public
    C.
    Private
    D.
    Friend

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. Which of the following statement is correct with respect to the use of friend keyword inside a class?

  18. A.
    A private data member can be declared as a friend.
    B.
    A class may be declared as a friend.
    C.
    An object may be declared as a friend.
    D.
    We can use friend keyword as a class name.

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. Which of the following keywords is used to control access to a class member?

  20. A.
    Default
    B.
    Break
    C.
    Protected
    D.
    Asm

    View Answer

    Workspace

    Discuss Discuss in Forum