logo

CuriousTab

CuriousTab

Discussion


Home C++ Programming Objects and Classes See What Others Are Saying!
  • Question
  • 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.

  • Correct Answer
  • Class A. 


  • More questions

    • 1. Destructors __________ for automatic objects if the program terminates with a call to function exit or function abort.

    • Options
    • A. are called
    • B. are inherited
    • C. are not called
    • D. are created
    • Discuss
    • 2. Which of the following statement is correct with respect to the use of friend keyword inside a class?

    • Options
    • A. A private data member can be declared as a friend.
    • B. A class may be declared as a friend.
    • C. An object may be declared as a friend.
    • D. We can use friend keyword as a class name.
    • Discuss
    • 3. Which of the following statement is correct?

    • Options
    • A. Class is an instance of object.
    • B. Object is an instance of a class.
    • C. Class is an instance of data type.
    • D. Object is an instance of data type.
    • Discuss
    • 4. Which of the following functions are performed by a constructor?

    • Options
    • A. Construct a new class
    • B. Construct a new object
    • C. Construct a new function
    • D. Initialize objects
    • Discuss
    • 5. Which of the following statement is correct?

    • Options
    • A. A constructor has the same name as the class in which it is present.
    • B. A constructor has a different name than the class in which it is present.
    • C. A constructor always returns an integer.
    • D. A constructor cannot be overloaded.
    • Discuss
    • 6. What will be the output of the following program?
      #include<iostream.h> 
      typedef void(*FunPtr)(int);
      int Look(int = 10, int = 20);
      void Note(int); 
      int main()
      {
          FunPtr ptr = Note;
          (*ptr)(30); 
          return 0;
      }
      int Look(int x, int y)
      {
          return(x + y % 20);
      }
      void Note(int x)
      {
          cout<< Look(x) << endl;
      }

    • Options
    • A. 10
    • B. 20
    • C. 30
    • D. 40
    • E. Compilation fails.
    • Discuss
    • 7. Which of the following statement is correct about the program given below?
      #include<iostream.h>
      void Tester(float xx, float yy = 5.0);
      class CuriousTab
      {
          float x; 
          float y; 
          public:
          void Tester(float xx, float yy = 5.0)
          {
              x = xx;
              y = yy;
              cout<< ++x % --y; 
          }
      };
      int main()
      {
          CuriousTab objCuriousTab;
          objCuriousTab.Tester(5.0, 5.0);
          return 0; 
      }

    • Options
    • A. The program will print the output 0.
    • B. The program will print the output 1.
    • C. The program will print the output 2.
    • D. The program will print the output garbage value.
    • E. The program will report compile time error.
    • Discuss
    • 8. Which of the following statement is correct about the program given below?
      #include<iostream.h> 
      long FactFinder(long = 5); 
      int main()
      {
          for(int i = 0; i<= 0; i++)
              cout<< FactFinder() << endl; 
          return 0;
      }
      long FactFinder(long x)
      {
          if(x < 2)
              return 1; 
          long fact = 1; 
          for(long i = 1; i <= x-1; i++)
              fact = fact * i; 
          return fact; 
      }

    • Options
    • A. The program will print the output 1.
    • B. The program will print the output 24.
    • C. The program will print the output 120.
    • D. The program will print the output garbage value.
    • E. The program will report compile time error.
    • Discuss
    • 9. How many types of polymorphisms are supported by C++?

    • Options
    • A. 1
    • B. 2
    • C. 3
    • D. 4
    • Discuss
    • 10. What will be the output of the following program?
      #include<iostream.h> 
      class CuriousTabTest
      {
          public:
          CuriousTabTest(int &x, int &y)
          {
              x++;
              y++;
          } 
      };
      int main()
      {
          int a = 10, b = 20;
          CuriousTabTest objBT(a, b); 
          cout<< a << " " << b; 
          return 0; 
      }

    • Options
    • A. 10 20
    • B. 11 21
    • C. Garbage Garbage
    • D. It will result in a compile time error.
    • Discuss


    Comments

    There are no comments.

Enter a new Comment