logo

CuriousTab

CuriousTab

Discussion


Home C++ Programming Functions See What Others Are Saying!
  • Question
  • What will be the output of the following program?
    #include<iostream.h> 
    class CuriousTab
    {
        public: 
        int x, y;
        CuriousTab(int xx = 10, int yy = 20)
        {
            x = xx;
            y = yy; 
        }
        void Exchange(int *, int *);
    };
    int main()
    {
        CuriousTab objA(30, 40); 
        CuriousTab objB(50); 
        objA.Exchange(&objA.x, &objB.y); 
        cout<< objA.x << " " << objB.y << endl; 
        return 0;
    }
    void CuriousTab::Exchange(int *x, int *y)
    {
        int t;
        t  = *x;
        *x = *y;
        *y = t ; 
    }


  • Options
  • A. 20 10
  • B. 30 20
  • C. 20 30
  • D. 30 40
  • E. 50 30

  • Correct Answer
  • 20 30 


  • More questions

    • 1. Which of the following statement is correct about the program given below?
      #include<iostream.h> 
      int main()
      {
          int x = 80; 
          int &y = x;
          x++;
          cout << x << " " << --y;
          return 0;
      }

    • Options
    • A. The program will print the output 80 80.
    • B. The program will print the output 81 80.
    • C. The program will print the output 81 81.
    • D. It will result in a compile time error.
    • Discuss
    • 2. What will be the output of the following program?
      #include<iostream.h> 
      class A
      {
          public:
          void CuriousTabFunction(void)
          {
              cout<< "Class A" << endl;
          }
      };
      class B: public A
      {
          public:
          void CuriousTabFunction(void)
          {
              cout<< "Class B" << endl;
          } 
      };
      class C : public B
      {
          public:
          void CuriousTabFunction(void)
          {
              cout<< "Class C" << endl;
          } 
      };
      int main()
      {
          A *ptr;
          B objB;
          ptr = &objB;
          ptr = new C();
          ptr->CuriousTabFunction();
          return 0; 
      }

    • Options
    • A. Class A.
    • B. Class B.
    • C. Class C.
    • D. The program will report compile time error.
    • Discuss
    • 3. Which of the following gets called when an object goes out of scope?

    • Options
    • A. constructor
    • B. destructor
    • C. main
    • D. virtual function
    • Discuss
    • 4. What will be the output of the following program?
      #include<iostream.h> 
      class TestDrive
      {
          int x; 
          public:
          TestDrive(int xx)
          {
              x = xx;
          }
          int DriveIt(void);
      };
      int TestDrive::DriveIt(void)
      {
          static int value = 0;
          int m;
          m = x % 2;
          x = x / 2;
          if((x / 2)) DriveIt(); 
          value = value + m * 10; 
          return value;
      }
      int main()
      {
          TestDrive TD(1234);
          cout<< TD.DriveIt() * 10 << endl;
          return 0; 
      }

    • Options
    • A. 300
    • B. 200
    • C. Garbage value
    • D. 400
    • Discuss
    • 5. A __________ is a constructor that either has no parameters, or if it has parameters, all the parameters have default values.

    • Options
    • A. default constructor
    • B. copy constructor
    • C. Both A and B
    • D. None of these
    • Discuss
    • 6. Constructor is executed when _____.

    • Options
    • A. an object is created
    • B. an object is used
    • C. a class is declared
    • D. an object goes out of scope.
    • Discuss
    • 7. Which of the following is used to make an abstract class?

    • Options
    • A. Declaring it abstract using static keyword.
    • B. Declaring it abstract using virtual keyword.
    • C. Making at least one member function as virtual function.
    • D. Making at least one member function as pure virtual function.
    • Discuss
    • 8. Which of the following statement is correct about the program given below?
      #include<iostream.h> 
      int x, y; 
      class CuriousTabTest
      {
          public:
          CuriousTabTest(int xx = 0, int yy = 0)
          {
              x = xx;
              y = yy;
              Display(); 
          } 
          void Display()
          {
              cout<< x << " " << y << " ";
          }
      };
      int main()
      {
          CuriousTabTest objBT(10, 20); 
          int &rx = x; 
          int &ry = y; 
          ry = x;
          rx = y;
          cout<< rx--; 
          return 0; 
      }

    • Options
    • A. The program will print the output 0 0 10.
    • B. The program will print the output 10 20 10.
    • C. The program will print the output 10 20 9.
    • D. It will result in a compile time error.
    • Discuss
    • 9. What will be the output of the following program?
      #include<iostream.h>
      double CuriousTabFunction(double, double, double = 0, double = 0, double = 0);
      int main()
      {
          double d = 2.3;
          cout<< CuriousTabFunction(d, 7) << " ";
          cout<< CuriousTabFunction(d, 7, 6) << endl;
          return 0; 
      }
      double CuriousTabFunction(double x, double p, double q, double r, double s)
      {
          return p +(q +(r + s * x)* x) * x;
      }

    • Options
    • A. 7 20
    • B. 7 19.8
    • C. 7 Garbage
    • D. 7 20.8
    • Discuss
    • 10. Which of the following statement is correct about the program given below?
      #include<iostream.h> 
      int main()
      {
          int x = 10;
          int &y = x;
          x++;
          cout<< x << " " << y++;
          return 0; 
      }
      

    • Options
    • A. The program will print the output 11 12.
    • B. The program will print the output 12 11.
    • C. The program will print the output 12 13.
    • D. It will result in a compile time error.
    • Discuss


    Comments

    There are no comments.

Enter a new Comment