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

  • Correct Answer
  • 400 


  • More questions

    • 1. Which of the following concepts means wrapping up of data and functions together?

    • Options
    • A. Abstraction
    • B. Encapsulation
    • C. Inheritance
    • D. Polymorphism
    • Discuss
    • 2. Which of the following statement is correct about the program given below?
      #include<iostream.h> 
      struct Tab
      {
          short n;
      };
      int main()
      {
          Tab b;
          Tab& rb = b;
          b.n = 5;
          cout << b.n << " " << rb.n << " ";
          rb.n = 8;
          cout << b.n << " " << rb.n;
          return 0; 
      }

    • Options
    • A. It will result in a compile time error.
    • B. The program will print the output 5 5 5 8.
    • C. The program will print the output 5 5 8 8.
    • D. The program will print the output 5 5 5 5.
    • Discuss
    • 3. What will be the output of the following program?
      #include<iostream.h>
      long CuriousTabFunction(int x, int y = 5, float z = 5)
      {
          return(++x * ++y + (int)++z);
      }
      int main()
      {
          cout<< CuriousTabFunction(20, 10); 
          return 0;
      }

    • Options
    • A. 237
    • B. 242
    • C. 240
    • D. 35
    • E. The program will report error on compilation.
    • Discuss
    • 4. Which of the following means "The use of an object of one class in definition of another class"?

    • Options
    • A. Encapsulation
    • B. Inheritance
    • C. Composition
    • D. Abstraction
    • Discuss
    • 5. Which of the following statement is correct?

    • Options
    • A. Destructor destroys only integer data members of the object.
    • B. Destructor destroys only float data members of the object.
    • C. Destructor destroys only pointer data members of the object.
    • D. Destructor destroys the complete object.
    • Discuss
    • 6. Which of the following statements are correct?

    • Options
    • A. Constructor is always called explicitly.
    • B. Constructor is called either implicitly or explicitly, whereas destructor is always called implicitly.
    • C. Destructor is always called explicitly.
    • D. Constructor and destructor functions are not called at all as they are always inline.
    • Discuss
    • 7. What will be the output of the following program?
      #include<iostream.h> 
      void MyFunction(int a, int b = 40)
      {
          cout<< " a = "<< a << " b = " << b << endl;
      }
      int main()
      {
          MyFunction(20, 30);
          return 0; 
      }

    • Options
    • A. a = 20 b = 40
    • B. a = 20 b = 30
    • C. a = 20 b = Garbage
    • D. a = Garbage b = 40
    • Discuss
    • 8. Which of the following is correct about function overloading?

    • Options
    • A. The types of arguments are different.
    • B. The order of argument is different.
    • C. The number of argument is same.
    • D. Both A and B.
    • Discuss
    • 9. Which of the following statement is correct about the program given below?
      #include<iostream.h>
      long GetNumber(long int Number)
      {
          return --Number;
      }
      float GetNumber(int Number)
      {
          return ++Number;
      }
      int main()
      {
          int x = 20;
          int y = 30;
          cout<< GetNumber(x) << " ";
          cout<< GetNumber(y) ;
          return 0; 
      }

    • Options
    • A. The program will print the output 19 31.
    • B. The program will print the output 20 30.
    • C. The program will print the output 21 31.
    • D. The program will print the output 21 29.
    • E. Program will report compile time error.
    • Discuss
    • 10. Which of the following statements is correct?

    • Options
    • A. Base class pointer cannot point to derived class.
    • B. Derived class pointer cannot point to base class.
    • C. Pointer to derived class cannot be created.
    • D. Pointer to base class cannot be created.
    • Discuss


    Comments

    There are no comments.

Enter a new Comment