logo

CuriousTab

CuriousTab

Functions problems


  • 1. 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
  • 2. 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

First 2 3 4 5 6 7