logo

CuriousTab

CuriousTab

Discussion


Home C++ Programming OOPS Concepts See What Others Are Saying!
  • Question
  • What will happen if a class is not having any name?


  • Options
  • A. It cannot have a destructor.
  • B. It cannot have a constructor.
  • C. It is not allowed.
  • D. Both A and B.

  • Correct Answer
  • Both A and B. 


  • More questions

    • 1. Which of the following correctly describes overloading of functions?

    • Options
    • A. Virtual polymorphism
    • B. Transient polymorphism
    • C. Ad-hoc polymorphism
    • D. Pseudo polymorphism
    • Discuss
    • 2. Which of the following are available only in the class hierarchy chain?

    • Options
    • A. Public data members
    • B. Private data members
    • C. Protected data members
    • D. Member functions
    • Discuss
    • 3. 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
    • 4. 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
    • 5. 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
    • 6. 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
    • 7. 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
    • 8. 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
    • 9. 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
    • 10. 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


    Comments

    There are no comments.

Enter a new Comment