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 :: Programs

C++ Programming :: Objects and Classes

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

      #include
      class Bix
      {    
            public:    
             int x; 
     };
     int main() 
     {    
         Bix *p = new Bix();   
         
        (*p).x = 10;    
        cout" " x " " ;     
       
        p->x = 20;   
        cout" " x ;    
       
       return 0; 
    }
    

  2. A.

    10 10 20 20

    B.

    Garbage garbage 20 20

    C.

    10 10 Garbage garbage

    D.

    Garbage garbage Garbage garbage

    View Answer

    Workspace

    Discuss Discuss in Forum


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

     #include 
      class Freshergate
      {  
           static int x;     
           public:    
           static void SetData(int xx)    
           {
             x = xx;      
          }
          void Display()  
          {      
             cout
          }
     int Freshergate::x = 0; 
     int main() 
     {    
         Freshergate::SetData(33);   
         Freshergate::Display();     
         return 0; 
     }
    

  4. A.

    The program will print the output 0.

    B.

    The program will print the output 33.

    C.

    The program will print the output Garbage.

    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 Freshergate 
       {    
           static int x;  
           public:    
           static void SetData(int xx)    
           {         
              x = xx;      
           }     
           static void Display()   
           {      
                cout
           }
       };     
        int Freshergate::x = 0; 
        int main()
        {
           Freshergate::SetData(44); 
           Freshergate::Display();   
           return 0; 
        }
    

  6. A.

    The program will print the output 0.

    B.

    The program will print the output 44.

    C.

    The program will print the output Garbage.

    D.

    The program will report compile time error.

    View Answer

    Workspace

    Discuss Discuss in Forum


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

       #include
       class BixTeam 
       {     
           int x, y;    
           public:     
           BixTeam(int xx)   
           {       
                 x = ++xx;    
           }   
           void Display()   
           {       
                cout" ";  
          } 
      }; 
      int main() 
     {    
          BixTeam objBT(45);   
          objBT.Display();    
          int *p = (int*)&objBT;    
          *p = 23;     
          objBT.Display();     
          return 0; 
     }
    

  8. A.

    45 22

    B.

    46 22

    C.

    45 23

    D.

    46 23

    View Answer

    Workspace

    Discuss Discuss in Forum


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

      #include
      class Freshergate
      {    
           static int x;  
           public:    
           static void SetData(int xx)     
           {       
               this->x = xx;     
           }   
           static void Display()     
           {      
               cout
           }
       int Freshergate::x = 0;
       int main()
       {    
            Freshergate:SetData(22);  
            Freshergate::Display();    
            return 0;  
       }
    
    

  10. A.

    The program will print the output 0.

    B.

    The program will print the output 22.

    C.

    The program will print the output Garbage.

    D.

    The program will report compile time error.

    View Answer

    Workspace

    Discuss Discuss in Forum


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

     #include
     #include 
     class Freshergate
     {
         int val;    
         public:   
         void SetValue(char *str1, char *str2)  
         {         
             val = strcspn(str1, str2);   
         }     
         void ShowValue()    
         {    
             coutint main() 
      };  
      int main()
      }    
          Freshergate objgate;  
          objgate.SetValue((char*)"Fresher", (char*)"Gate");          
          objgate.ShowValue();  
          return 0; 
      }
    

  12. A.

    2

    B.

    3

    C.

    5

    D.

    8

    View Answer

    Workspace

    Discuss Discuss in Forum


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

    #include<iostream.h> #include<string.h>  class IndiaBix {     public:     void GetData(char *s, int x, int y )     {         int i = 0;         for (i = x-1; y>0; i++)         {             cout<< s[i];             y--;          }      } };  int main() {     IndiaBix objBix;     objBix.GetData((char*)"Welcome!", 1, 3);     return 0;  }

  14. A.
    The program will print the output me!.
    B.
    The program will print the output Wel.
    C.
    The program will print the output !em.
    D.
    The program will print the output Welcome!.
    E.
    The program will result in a compile time error.

    View Answer

    Workspace

    Discuss Discuss in Forum


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

     #include 
     class GateData 
     {  
         int x, y, z;  
         public:    
         GateData(int xx, int yy, int zz)         
         {       
              x = ++xx;  
              y = ++yy;    
              z = ++zz;   
        }     
        void Show()   
        {        
           cout   
        } 
     }; 
     int main()
     {
         GateData objData(1, 2, 3);         
         objData.Show();  
         return 0;  
    }
    

  16. A.

    The program will print the output 1 2 3.

    B.

    The program will print the output 2 3 4 .

    C.

    The program will print the output 4 5 6.

    D.

    The program will report compile time error.

    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;     
        float y;  
        public:    
        void Function()   
       {       
           x = 4;       
           y = 2.50; delete this;     
       }   
       void Display()  
       {      
          cout" " int main() 
    {   
       Freshergate *pgate =newFreshergate();        
       pBix->Function();   
       pBix->Function();    
       pBix->Display();   
       return 0;  }

     

  18. A.

    The program will print the output 4 2.5.

    B.

    The program will print the output 4.

    C.

    The program will report runtime error.

    D.

    The program will report compile time error.

    View Answer

    Workspace

    Discuss Discuss in Forum


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

     #include 
     class Freshergate
     {    
        static int count;  
        public:  
        static void First(void)    
       {        
            count = 10;    
       }    
       static void Second(int x)     
      {           
        count = count + x;    
      }    
      static void Display(void)   
      {    
         cout
      }
    ];
     int Freshergate::count = 0;  
     int main() 
     {    
       Freshergate :: First();   
       Freshergate :: Second(5);        
       Freshergate :: Display();  
       return 0;  
    }
    

  20. A.

    0  

    B.

    5

    C.

    10

    D.

    15

    E.

    The program will report compile time error.

    View Answer

    Workspace

    Discuss Discuss in Forum