logo

CuriousTab

CuriousTab

Discussion


Home C++ Programming References 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, y; 
        public:
        void SetValue(int &xx, int &yy)
        {
            x =  xx++;
            y =  yy; 
            cout<< xx << " " << yy;
        }
    };
    int main()
    {
        int x = 10;
        int &y = x;
        CuriousTab objCuriousTab;
        objCuriousTab.SetValue(x , y);
        return 0; 
    }


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

  • Correct Answer
  • The program will print the output 11 11. 


  • More questions

    • 1. Which of the following function / type of function cannot be overloaded?

    • Options
    • A. Member function
    • B. Static function
    • C. Virtual function
    • D. Both B and C
    • Discuss
    • 2. Which of the following statement is correct?

    • Options
    • A. The default value for an argument cannot be function call.
    • B. C++ allows the redefinition of a default parameter.
    • C. Both A and B.
    • D. C++ does not allow the redefinition of a default parameter.
    • Discuss
    • 3. __________ used to make a copy of one class object from another class object of the same class type.

    • Options
    • A. constructor
    • B. copy constructor
    • C. destructor
    • D. default constructor
    • Discuss
    • 4. 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
    • 5. 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
    • 6. Which of the following gets called when an object goes out of scope?

    • Options
    • A. constructor
    • B. destructor
    • C. main
    • D. virtual function
    • Discuss
    • 7. 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
    • 8. 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
    • 9. 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
    • 10. 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


    Comments

    There are no comments.

Enter a new Comment