logo

CuriousTab

CuriousTab

Discussion


Home C++ Programming Functions Comments

  • Question
  • Which of the following statement is correct about the program given below?
    #include<iostream.h> 
    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 << gSum; 
        }
    };
    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 << gSum;
        }
    };
    class Derived : public BaseOne, BaseTwo
    {
        void Show()
        {
            cout << gSum;
        } 
    }; 
    int main()
    {
        Derived objDev;
        objDev.BaseTwo::Display(10, 20, 'Z');
        return 0; 
    }


  • Options
  • 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.

  • Correct Answer
  • The program will report compile-time error. 


  • Functions problems


    Search Results


    • 1. Which of the following statement is correct about the program given below?
      #include<iostream.h> 
      class CuriousTab
      { 
          public:
          void CuriousTab(int x = 15)
          {
              x = x/2; 
              if(x > 0)
                  CuriousTab(); 
              else
                  cout<< x % 2; 
          } 
      };
      int main()
      {
          CuriousTab objIB;
          objIB.CuriousTab();
          return 0; 
      }

    • Options
    • A. The program will display 1.
    • B. The program will display 2.
    • C. The program will display 15.
    • D. The program will go into an infinite loop.
    • E. The program will report error on compilation.
    • Discuss
    • 2. What will be the output of the following program?
      #include<iostream.h>
      #include<string.h> 
      class CuriousTabString
      {
          char x[50]; 
          char y[50]; 
          char z[50]; 
          public:
          CuriousTabString()
          { }
          CuriousTabString(char* xx)
          {
              strcpy(x, xx); 
              strcpy(y, xx);
          }
          CuriousTabString(char *xx, char *yy = " C++", char *zz = " Programming!")
          {
              strcpy(z, xx); 
              strcat(z, yy); 
              strcat(z, zz);
          } 
          void Display(void)
          {
          cout<< z << endl;
          } 
      }; 
      int main()
      {
          CuriousTabString objStr("Learn", " Java");
          objStr.Display();
          return 0; 
      }

    • Options
    • A. Java Programming!
    • B. C++ Programming!
    • C. Learn C++ Programming!
    • D. Learn Java Programming!
    • E. Learn Java C++ Programming!
    • Discuss
    • 3. Which of the following statement is correct about the program given below?
      #include<iostream.h> 
      class CuriousTab
      {
          int x; 
          float y; 
          public:
          CuriousTab(int x)
          {
              x = x;
          }
          CuriousTab(int p = 0, int q = 10)
          {
              x = p += 2; 
              y = q * 1.0f;
          }
          void SetValue(int &y, float z)
          {
              x = y;
              y = (int)z;
          }
          void Display(void)
          {
              cout<< x;
          }
      };
      int main()
      {
          int val = 12; 
          CuriousTab objCuriousTab(val); 
          CuriousTab objTmp();
          objCuriousTab.SetValue(val, 3.14f); 
          objCuriousTab.Display(); 
          return 0; 
      }

    • Options
    • A. The program will print the output 2.
    • B. The program will print the output 12.
    • C. The program will report run time error.
    • D. The program will not compile successfully.
    • Discuss
    • 4. Which of the following statement is correct about the program given below?
      #include<iostream.h> 
      class CuriousTab
      {
          int x; 
          float y; 
          public:
          void CuriousTabFunction(int = 0, float = 0.00f, char = 'A');
          void CuriousTabFunction(float, int = 10.00, char = 'Z');
          void CuriousTabFunction(char, char, char);
      };
      int main()
      {
          CuriousTab objCuriousTab;
          objCuriousTab.CuriousTabFunction(10 * 1.0, int(56.0)); 
          return 0;
      }
      void CuriousTab::CuriousTabFunction(int xx, float yy, char zz)
      {
          x = xx + int(yy);
          cout<< "x = " << x << endl;
      }
      void CuriousTab::CuriousTabFunction(float xx, int yy, char zz)
      {
          x = zz + zz;
          y = xx + yy;
          cout<< " x = " << x << endl;
      }
      void CuriousTab::CuriousTabFunction(char xx, char yy, char zz)
      {
          x = xx + yy + zz; 
          y = float(xx * 2); 
          cout<< " x = " << x << endl;
      }

    • Options
    • A. The program will print the output x = 65.
    • B. The program will print the output x = 66.
    • C. The program will print the output x = 130.
    • D. The program will print the output x = 180.
    • E. The program will not compile successfully.
    • Discuss
    • 5. What will be the output of the following program?
      #include<iostream.h> 
      class Base
      {
          int x, y; 
          public:
          Base() 
          {
              x = y = 0; 
          } 
          Base(int xx)
          {
              x = xx;
          }
          Base(int p, int q = 10)
          {
              x = p + q;
              y = q; 
          } 
          void Display(void)
          {
              cout<< x << " " << y << endl;
          } 
      }objDefault(1, 1);
      
      class Derived: public Base
      {
          Base obj; 
          public:
          Derived(int xx, int yy): Base(xx, xx + 1)
          { }
          Derived(Base objB = objDefault)
          { } 
      }; 
      int main()
      {
          Derived objD(5, 3);
          Derived *ptrD = new Derived(objD);
          ptrD->Display();
          delete ptrD;
          return 0; 
      }

    • Options
    • A. 3 2
    • B. 8 3
    • C. 11 6
    • D. 11 10
    • E. The program will not compile successfully.
    • Discuss
    • 6. What will be the output of the following program?
      #include<iostream.h> 
      struct CuriousTabArray
      {
          int arr[5]; 
          public:
          void CuriousTabFunction();
          void Display();
      };
      void CuriousTabArray::CuriousTabFunction()
      {
          static int i = 0, j = 4; 
          i++;
          j--;
          if(j > 0)
              CuriousTabFunction(); 
          int tmp = arr[i]; 
          arr[i]  = arr[j]; 
          arr[j]  = tmp; 
          i--;
          j++;
      }
      void CuriousTabArray::Display()
      {
          for(int i = 0; i < 5; i++)
              cout<< arr[i] << " ";
      } 
      int main()
      {
          CuriousTabArray objArr = {{5, 6, 3, 9, 0}};
          objArr.CuriousTabFunction();
          objArr.Display();
          return 0; 
      }

    • Options
    • A. 5 6 3 9 0
    • B. 0 9 3 6 5
    • C. 0 5 6 3 9
    • D. 0 6 3 9 5
    • E. None of these
    • Discuss
    • 7. What will be the output of the following program?
      #include<iostream.h> 
      struct CuriousTab
      {
          int arr[5]; 
          public:
          void CuriousTabFunction(void);
          void Display(void);
      };
      void CuriousTab::Display(void)
      {
          for(int i = 0; i < 5; i++) 
              cout<< arr[i] << " " ;
      }
      void CuriousTab::CuriousTabFunction(void)
      {
          static int i = 0, j = 4; 
          int tmp = arr[i]; 
          arr[i]  = arr[j]; 
          arr[j]  = tmp   ; 
          i++;
          j--;
          if(j != i) CuriousTabFunction();
      }
      int main()
      {
          CuriousTab objCuriousTab = {{ 5, 6, 3, 9, 0 }};
          objCuriousTab.CuriousTabFunction();
          objCuriousTab.Display();
          return 0; 
      }

    • Options
    • A. 0 9 3 6 5
    • B. 9 3 6 5 0
    • C. 5 6 3 9 0
    • D. 5 9 3 6 0
    • Discuss
    • 8. What is correct about the following program?
      #include<iostream.h> 
      class Base
      {
          int x, y, z; 
          public: 
          Base()
          {
              x = y = z = 0;
          }
          Base(int xx, int yy = 'A', int zz = 'B')
          {
              x = xx;
              y = x + yy;
              z = x + y;
          }
          void Display(void)
          {
              cout<< x << " " << y << " " << z << endl;
          }
      };
      class Derived : public Base
      {
          int x, y; 
          public:
          Derived(int xx = 65, int yy = 66) : Base(xx, yy)
          {
              y = xx; 
              x = yy;
          }
          void Display(void)
          {
              cout<< x << " " << y << " ";
              Display(); 
          }
      };
      int main()
      {
          Derived objD;
          objD.Display();
          return 0; 
      }

    • Options
    • A. The program will report compilation error.
    • B. The program will run successfully giving the output 66 65.
    • C. The program will run successfully giving the output 65 66.
    • D. The program will run successfully giving the output 66 65 65 131 196.
    • E. The program will produce the output 66 65 infinite number of times (or till stack memory overflow).
    • Discuss
    • 9. Which of the following statement is correct about the program given below?
      #include<iostream.h> 
      class CuriousTabSample
      {
          private:
          int AdditionOne(int x, int y = 1) 
          {
              return x * y;
          }
           
          public:
          int AdditionTwo(int x, int y = 1)
          {
              return x / y;
          } 
      }; 
      int main()
      {
          CuriousTabSample objCuriousTab;
          cout<<objCuriousTab.AdditionOne(4, 8)<<" "; 
          cout<<objCuriousTab.AdditionTwo(8, 8); 
          return 0;
      }

    • Options
    • A. The program will print the output 32 0.
    • B. The program will print the output 32 garbage-value.
    • C. The program will print the output 32 1.
    • D. The program will report compile time error.
    • Discuss
    • 10. Which of the following statement is correct about the program given below?
      #include<iostream.h> 
      class CuriousTab
      {
          static int x; 
          public:
          static void SetData(int xx)
          {
              this->x = xx; 
          }
          static void Display() 
          {
              cout<< x ;
          }
      };
      int CuriousTab::x = 0; 
      int main()
      {
          CuriousTab::SetData(22);
          CuriousTab::Display();
          return 0; 
      }

    • Options
    • 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.
    • Discuss


    Comments

    There are no comments.

Enter a new Comment