logo

CuriousTab

CuriousTab

Discussion


Home C++ Programming Constructors and Destructors See What Others Are Saying!
  • Question
  • Which of the following statement is correct about the program given below?
    #include<iostream.h> 
    class CuriousTab
    {
        int x; 
        public:
        CuriousTab(short ss)
        {
            cout<< "Short" << endl;
        }
        CuriousTab(int xx)
        {
            cout<< "Int" << endl;
        }
        CuriousTab(char ch)
        {
            cout<< "Char" << endl;
        }
        ~CuriousTab() 
        {
            cout<< "Final";
        }
    };
    int main()
    {
        CuriousTab *ptr = new CuriousTab('B');
        return 0; 
    }


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

  • Correct Answer
  • The program will print the output Char


  • More questions

    • 1. To ensure that every object in the array receives a destructor call, always delete memory allocated as an array with operator __________ .

    • Options
    • A. destructor
    • B. delete
    • C. delete[]
    • D. kill[]
    • E. free[]
    • Discuss
    • 2. Which one of the following options is correct?

    • Options
    • A. Friend function can access public data members of the class.
    • B. Friend function can access protected data members of the class.
    • C. Friend function can access private data members of the class.
    • D. All of the above.
    • Discuss
    • 3. Which inheritance type is used in the class given below?
      class A : public X, public Y
      {}

    • Options
    • A. Multilevel inheritance
    • B. Multiple inheritance
    • C. Hybrid inheritance
    • D. Hierarchical Inheritance
    • Discuss
    • 4. Which of the following statement is correct about the program given below?
      #include<iostream.h> 
      class CuriousTab
      {
          int x; 
          public:
          CuriousTab(short ss)
          {
              cout<< "Short" << endl;
          }
          CuriousTab(int xx)
          {
              cout<< "Int" << endl;
          }
          CuriousTab(char ch)
          {
              cout<< "Char" << endl;
          }
          ~CuriousTab() 
          {
              cout<< "Final";
          }
      };
      int main()
      {
          CuriousTab *ptr = new CuriousTab('B');
          return 0; 
      }

    • Options
    • 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
    • Discuss
    • 5. Which of the following statement is correct about the program given below?
      #include<iostream.h> 
      class CuriousTab
      {
          int x, y; 
          public:
          CuriousTab(int xx = 0, int yy = 0)
          {
              x = xx; 
              y = yy;
          }
          void Display()
          {
              cout<< x << " " << y;
          }
          CuriousTab operator +(CuriousTab z)
          {
              CuriousTab objTemp;
              objTemp.x = x + z.x;
              objTemp.y = y + z.y;
              return objTemp; 
          }
      };
      int main()
      {
          CuriousTab objCuriousTab1(90, 80); 
          CuriousTab objCuriousTab2(10, 20); 
          CuriousTab objSum; 
          CuriousTab &objRef = objSum; 
          objRef = objCuriousTab1 + objCuriousTab2; 
          objRef.Display(); 
          return 0; 
      }

    • Options
    • A. It will result in a runtime error.
    • B. It will result in a compile time error.
    • C. The program will print the output 9 4.
    • D. The program will print the output 100 100.
    • Discuss
    • 6. What will be the out of the following program?
      #include<iostream.h> 
      class CuriousTabBase
      {
          protected:
          int x, y; 
          public:
          CuriousTabBase(int xx = 0, int yy = 0)
          {
              x = xx;
              y = yy; 
          } 
          void Show()
          {
              cout<< x * this->y << endl;
          }
      };
      class CuriousTabDerived
      {
          private:
              CuriousTabBase objBase; 
          public:
          CuriousTabDerived(int xx, int yy) : objBase(xx, yy)
          {
              objBase.Show();
          } 
          ~CuriousTabDerived()
          { }
      };
      int main()
      {
          CuriousTabDerived objDev(10, 20); 
          return 0;
      }

    • Options
    • A. 0
    • B. 100
    • C. 200
    • D. 400
    • E. The program will report compile time error.
    • Discuss
    • 7. What will be the output of the following program?
      #include<iostream.h> 
      class Number
      {
          int Num; 
          public:
          Number(int x = 0)
          {
              Num = x;
          }
          void Display(void)
          {
              cout<< Num;
          }
          void Modify(); 
      };
      void Number::Modify()
      {
          int Dec;
          Dec = Num % 13; 
          Num = Num / 13; 
          
               if(Num  > 0 ) Modify()   ; 
               if(Dec == 10) cout<< "A" ; 
          else if(Dec == 11) cout<< "B" ; 
          else if(Dec == 12) cout<< "C" ; 
          else if(Dec == 13) cout<< "D" ;
          else               cout<< Dec ;
      }
      int main()
      {
          Number objNum(130);
          objNum.Modify();
          return 0; 
      }

    • Options
    • A. 130
    • B. A0
    • C. B0
    • D. 90
    • Discuss
    • 8. Which of the following statement is correct about the program given below?
      #include<iostream.h> 
      class CuriousTab
      {
          int x, y; 
          public:
          CuriousTab(int &xx, int &yy)
          {
              x = xx;
              y = yy;
              Display();
          }
          void Display()
          {
              cout<< x << " " << y;
          }
      };
      int main()
      {
          int x1 = 10; 
          int &p = x1;
          int y1 = 20; 
          int &q = y1; 
          CuriousTab objCuriousTab(p, q); 
          return 0; 
      }

    • Options
    • A. It will result in a compile time error.
    • B. The program will print the output 10 20.
    • C. The program will print two garbage values.
    • D. The program will print the address of variable x1 and y1.
    • Discuss
    • 9. What will be the output of the following program?
      #include<iostream.h> 
      class Base
      {
          public:
          char S, A, M; 
          Base(char x, char y)
          {
              S = y - y;
              A = x + x; 
              M = x * x;
          }
          Base(char, char y = 'A', char z = 'B')
          {
              S = y;
              A = y + 1 - 1; 
              M = z - 1;
          }
          void Display(void)
          {
              cout<< S << " " << A << " " << M << endl;
          }
      };
      class Derived : public Base
      {
          char x, y, z; 
          public:
          Derived(char xx = 65, char yy = 66, char zz = 65): Base(x)
          {
              x = xx; 
              y = yy;
              z = zz;
          }
          void Display(int n)
          {
              if(n)
                  Base::Display(); 
              else
                  cout<< x << " " << y << " " << z << endl; 
          }
      };
      int main()
      {
          Derived objDev; 
          objDev.Display(0-1); 
          return 0;
      }

    • Options
    • A. A A A
    • B. A B A
    • C. A B C
    • D. Garbage Garbage Garbage
    • E. The program will report compile time error.
    • Discuss
    • 10. 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.
    • Discuss


    Comments

    There are no comments.

Enter a new Comment