Home / C++ Programming / Constructors and Destructors :: General Questions

C++ Programming :: Constructors and Destructors

  1. What is the technical word for the function ~FresherGate() defined in the following program?

      #include
       class FresherGate 
       {   
          int x, y;   
          public:     
          FresherGate(int xx = 10, int yy = 20 )    
          {       
              x = xx;        
              y  = yy;    
         }  
         void Display() 
        {      
            cout" " int main() 
     {
         FresherGate objGate;  
         objGate.Display();    
         return 0; 
     }
    

     

  2. A.

    Constructor

    B.

    Destructor

    C.

    Default Destructor

    D.

    Function Template

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. Copy constructor must receive its arguments by __________ .

  4. A.
    either pass-by-value or pass-by-reference
    B.
    only pass-by-value
    C.
    only pass-by-reference
    D.
    only pass by address

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. A function with the same name as the class, but preceded with a tilde character (~) is called __________ of that class.

  6. A.
    constructor
    B.
    destructor
    C.
    function
    D.
    object

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. A union that has no constructor can be initialized with another union of __________ type.

  8. A.
    different
    B.
    same
    C.
    virtual
    D.
    class

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. Which of the following gets called when an object goes out of scope?

  10. A.
    constructor
    B.
    destructor
    C.
    main
    D.
    virtual function

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. Which of the following statement is correct?

  12. A.
    Destructor destroys only integer data members of the object.
    B.
    Destructor destroys only float data members of the object.
    C.
    Destructor destroys only pointer data members of the object.
    D.
    Destructor destroys the complete object.

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. __________ used to make a copy of one class object from another class object of the same class type.

  14. A.
    constructor
    B.
    copy constructor
    C.
    destructor
    D.
    default constructor

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. Constructors __________ to allow different approaches of object construction.

  16. A.
    cannot overloaded
    B.
    can be overloaded
    C.
    can be called
    D.
    can be nested

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. Which of the following statement is correct?

  18. A.
    A destructor has the same name as the class in which it is present.
    B.
    A destructor has a different name than the class in which it is present.
    C.
    A destructor always returns an integer.
    D.
    A destructor can be overloaded.

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. Which of the following cannot be declared as virtual?

  20. A.
    Constructor
    B.
    Destructor
    C.
    Data Members
    D.
    Both A and C

    View Answer

    Workspace

    Discuss Discuss in Forum