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

Constructors and Destructors - C++ Programming Questions and Answers
Home / C++ Programming / Constructors and Destructors :: Programs

C++ Programming :: Constructors and Destructors

  1. p>What will be the output of the following program?

    #include<iostream.h> 
    class FresherGate
    {
        int x; 
        public:
        FresherGate(int xx, float yy)
        {
            cout<< char(yy);
        } 
    }; 
    int main()
    {
        FresherGate *p = new FresherGate(35, 99.50f);
        return 0; 
    }

  2. A.

    99

    B.

    ASCII value of 99

    C.

    Garbage value

    D.

    99.50

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. Which of the following statement is correct about the program given below?

    #include 
     class Freshergate
    {     public:    
          Freshergate()   
      {        
          cout"Fresher";   
      }    
     ~Freshergate()    
      {       
          cout"GATE";    
      } 
    }; 
    int main() 
    {    
     Freshergate objGATE;    
       return 0;  
    }
    

  4. A.

    The program will print the output Fresher.

    B.

    The program will print the output GATE.

    C.

    The program will print the output FresherGATE

    D.

    The program will report compile time error.

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. Which of the following statement is correct about the program given below?

     #include 
     class GATE
     {    
         int x;   
       public:     
         GATE();   
        ~GATE();      
         void Show() const;
     };
     GATE:GATE()
     {   
        x = 25; 
     }
     void GATE::Show() const 
     {    
        coutint main() 
     {    
          GATE objB;   
          objB.Show();    
          return 0;  
     }
    

  6. A.

    The program will print the output 25.

    B.

    The program will print the output Garbage-value.

    C.

    The program will report compile time error.

    D.

    The program will report runtime error.

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. Which of the following statement is correct about the program given below?

       #include
       class GATE
       {    
            int x;    
      public:     
            GATE();     
            void Show() const;       
           ~GATE(){}
     }; 
     GATE::GATE()
     {   
         x = 5; 
     }
     void GATE::Show() const 
     { 
         coutint main()
     {     
         GATE objB;  
         objB.Show();   
         return 0;  
     }
    

  8. A.

    The program will print the output 5.

    B.

    The program will print the output Garbage-value.

    C.

    The program will report compile time error.

    D.

    The program will report runtime error.

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. #include 
    int val = 0; 
    class Freshergate
    {
        public: 
        Freshergate()
        {
            cout
    
  10. A.

    1234

    B.

    4321

    C.

    12344321

    D.

    12341234

    E.

    43211234

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. Which of the following constructor is used in the program given below?

     #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;
     }
    
    

  12. A.

    Copy constructor

    B.

    Simple constructor

    C.

    Non-parameterized constructor

    D.

    Default constructor

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. What will be the output of the following program?

     #include
      class Freshergate
      {    
          public:  
          GATEBase()    
          {      
             cout"Base OK. ";    
          } 
      };
      class GATEDerived: public GATEBase 
      { 
          public: 
          GATEDerived()    
         {         
            cout"Derived OK. ";   
         }   
         ~BixDerived()     
         {      
              cout"Derived DEL. ";
          }
     };
     int main()
     {    
         GATEBase    objB;  
         GATEDerived objD;      
         objD.~GATEDerived(); 
         return 0; 
    }
    

     

  14. A.

    Base OK. Derived OK. Derived DEL.

    B.

    Base OK. Base OK. Derived OK. Derived DEL.

    C.

    Base OK. Derived OK. Derived DEL. Derived DEL.

    D.

    Base OK. Base OK. Derived OK. Derived DEL. Derived DEL.

    E.

    The program will report compile time error.

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. What will be the output of the following program?

     #include 
      class Freshergate
      {    
         int x, y;     
         public:     
         Freshergate(int xx)    
         {        
             x = ++xx;     
         }     
        ~Freshergate()     
         {        
             cout1 " ";     
         }
         void Display()     
         {        
             cout1 " ";  
         }  
      };
      int main() 
      {     
           Freshergate objGate(5);   
           objGate.Display();    
           int *p = (int*) &objGate;   
           *p = 40;     
            objGate.Display();    
            return 0; 
      }
    

     

  16. A.

    6 6 4

    B.

    6 6 5

    C.

    5 40 38

    D.

    6 40 38

    E.

    6 40 39

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. Which of the following statement is correct about the program given below?

     #include 
      class Freshergate
      {   
         int x;    
         public:   
         FresherGate(short ss)  
         {       
            cout"Short" int xx) 
         {     
             cout"Int" (char ch)    
         {        
             cout"Char" cout"Final";  
         } 
     }; 
     int main() 
     {    
         FresherGate *ptr = new FresherGate('B');    
         return 0;
     }
    

  18. A.

    The program will print the output Short .

    B.

    The program will print the output Int .

    C.

    The program will print the output Char .

    D.

    The program will print the output Final .

    E.

    None of the above

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. Which of the following statement is correct about the program given below?

      #include 
       class FresherGate
       {
           int x;    
           public:    
           FresherGate(short ss)    
      {        
         cout"Short" int xx)     
      {         
         cout"Int" float ff)     
      {
          cout"Float" cout"Final"; 
      }
    }; 
    int main() 
    {   
         FresherGate *ptr = new FresherGate('B');     
         return 0; 
    }
    

  20. A.

    The program will print the output Short .

    B.

    The program will print the output Int .

    C.

    The program will print the output Float .

    D.

    The program will print the output Final .

    E.

    None of the above

    View Answer

    Workspace

    Discuss Discuss in Forum