Home / C++ Programming / Functions - C++ :: Programs

C++ Programming :: Functions - C++

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

    
     #include 
     static double gDouble;
     static float  gFloat; 
     static double gChar; 
     static double gSum = 0; 
     class BaseOne 
     {   
        public:   
        void Display(double x = 0.0, float y = 0.0, char z = 'A')   
        {        
             gDouble = x;       
             gFloat  = y;      
             gChar   = int(z);      
             gSum    = gDouble + gFloat + gChar;      
             cout class BaseTwo 
     {    
          public:   
          void Display(int x = 1, float y = 0.0, char z = 'A')   
          {       
               gDouble = x;       
               gFloat  = y;      
               gChar   = int(z);     
               gSum    = gDouble + gFloat + gChar;      
               cout class Derived : public BaseOne, BaseTwo 
     {   
         void Show()   
         {       
            cout int main()
     {   
        Derived objDev;   
        objDev.BaseTwo::Display(10, 20, 'Z');  
        return 0;
     }
    

  2. A.

    The program will print the output 0.

    B.

    The program will print the output 120.

    C.

    The program will report run-time error.

    D.

    The program will report compile-time error.

    E.

    The program will print the output garbage value.

    View Answer

    Workspace

    Discuss Discuss in Forum


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

      #include 
       class Base 
       {     
           public:  
           int S, A, M;    
           Base(int x, int y)    
           {       
              S = y - y;       
              A = x + x;     
              M = x * x;     
           }    
           Base(int, int y = 'A', int z = 'B')     
           {        
              S = y;   
              A = y + 1 - 1;    
              M = z - 1;   
       }  
       void Display(void)    
       {      
           cout" " " " class Derived : public Base
     {  
        int x, y, z;    
        public:    
        Derived(int xx = 65, int yy = 66, int zz = 67): Base(x)    
        {        
            x = xx;          
            y = yy;       
            z = zz;   
        } 
        void Display(int n)  
        {      
             if(n)     
                Base::Display();   
             else       
                cout" " " " nt main()
      {    
          Derived objDev;   
          objDev.Display(-1);    
          return 0;
      }
    

  4. A.

    65 65 65

    B.

    65 66 67

    C.

    A A A

    D.

    A B C

    E.

    The program will report compile time error.

    View Answer

    Workspace

    Discuss Discuss in Forum