logo

CuriousTab

CuriousTab

Discussion


Home C++ Programming OOPS Concepts See What Others Are Saying!
  • Question
  • How many types of polymorphisms are supported by C++?


  • Options
  • A. 1
  • B. 2
  • C. 3
  • D. 4

  • Correct Answer


  • Explanation
    The two main types of polymorphism are run-time (implemented as inheritance and virtual functions), and compile-time (implemented as templates).

  • More questions

    • 1. 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
    • 2. 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
    • 3. 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
    • 4. 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
    • 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, 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
    • 6. 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
    • 7. 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
    • 8. Which of the following statement is correct?

    • Options
    • A. A reference is declared using * operator.
    • B. Once a reference variable has been defined to refer to a particular variable it can refer to any other variable.
    • C. A reference must always be initialized within classes.
    • D. A variable can have multiple references.
    • Discuss
    • 9. 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
    • 10. Which of the following statement is correct about the program given below?
      #include<iostream.h> 
      class CuriousTabBase
      {
          int x, y; 
          public:
          CuriousTabBase(int xx = 10, int yy = 10)
          {
              x = xx;
              y = yy;
          }
          void Show()
          {
              cout<< x * y << endl;
          }
      };
      class CuriousTabDerived : public CuriousTabBase
      {
          private:
              CuriousTabBase objBase; 
          public:
          CuriousTabDerived(int xx, int yy) : CuriousTabBase(xx, yy), objBase(yy, yy)
          {
              objBase.Show();
          }
      };
      int main()
      {
          CuriousTabDerived objDev(10, 20);
          return 0; 
      }

    • Options
    • A. The program will print the output 100.
    • B. The program will print the output 200.
    • C. The program will print the output 400.
    • D. The program will print the output Garbage-value.
    • E. The program will report compile time error.
    • Discuss


    Comments

    There are no comments.

Enter a new Comment