logo

CuriousTab

CuriousTab

Discussion


Home C++ Programming Functions See What Others Are Saying!
  • Question
  • What is correct about the following program?
    #include<iostream.h> 
    class Base
    {
        int x, y, z; 
        public: 
        Base()
        {
            x = y = z = 0;
        }
        Base(int xx, int yy = 'A', int zz = 'B')
        {
            x = xx;
            y = x + yy;
            z = x + y;
        }
        void Display(void)
        {
            cout<< x << " " << y << " " << z << endl;
        }
    };
    class Derived : public Base
    {
        int x, y; 
        public:
        Derived(int xx = 65, int yy = 66) : Base(xx, yy)
        {
            y = xx; 
            x = yy;
        }
        void Display(void)
        {
            cout<< x << " " << y << " ";
            Display(); 
        }
    };
    int main()
    {
        Derived objD;
        objD.Display();
        return 0; 
    }


  • Options
  • A. The program will report compilation error.
  • B. The program will run successfully giving the output 66 65.
  • C. The program will run successfully giving the output 65 66.
  • D. The program will run successfully giving the output 66 65 65 131 196.
  • E. The program will produce the output 66 65 infinite number of times (or till stack memory overflow).

  • Correct Answer
  • The program will run successfully giving the output 65 66. 


  • More questions

    • 1. How can we make a class abstract?

    • Options
    • A. By making all member functions constant.
    • B. By making at least one member function as pure virtual function.
    • C. By declaring it abstract using the static keyword.
    • D. By declaring it abstract using the virtual keyword.
    • Discuss
    • 2. Copy constructor must receive its arguments by __________ .

    • Options
    • A. either pass-by-value or pass-by-reference
    • B. only pass-by-value
    • C. only pass-by-reference
    • D. only pass by address
    • Discuss
    • 3. 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.
    • Discuss
    • 4. cout is a/an __________ .

    • Options
    • A. operator
    • B. function
    • C. object
    • D. macro
    • Discuss
    • 5. What is the technical word for the function ~CuriousTab() defined in the following program?
      #include<iostream.h> 
      class CuriousTab
      {
          int x, y; 
          public:
          CuriousTab(int xx = 10, int yy = 20 )
          {
              x = xx; 
              y = yy;
          }
          void Display()
          {
              cout<< x << " " << y << endl;
          } 
          ~CuriousTab()
          { } 
      };
      int main()
      {
          CuriousTab objCuriousTab; 
          objCuriousTab.Display(); 
          return 0;
      }

    • Options
    • A. Constructor
    • B. Destructor
    • C. Default Destructor
    • D. Function Template
    • Discuss
    • 6. Which of the following statements is correct?

      1. Once a reference variable has been defined to refer to a particular variable it can refer to any other variable.
      2. A reference is not a constant pointer.

    • Options
    • A. Only 1 is correct.
    • B. Only 2 is correct.
    • C. Both 1 and 2 are correct.
    • D. Both 1 and 2 are incorrect.
    • Discuss
    • 7. Which of the following function / types of function cannot have default parameters?

    • Options
    • A. Member function of class
    • B. main()
    • C. Member function of structure
    • D. Both B and C
    • Discuss
    • 8. How "Late binding" is implemented in C++?

    • Options
    • A. Using C++ tables
    • B. Using Virtual tables
    • C. Using Indexed virtual tables
    • D. Using polymorphic tables
    • Discuss
    • 9. Which of the following is not the member of class?

    • Options
    • A. Static function
    • B. Friend function
    • C. Const function
    • D. Virtual function
    • Discuss
    • 10. What happens when we try to compile the class definition in following code snippet?
      class Birds {};
      class Peacock : protected Birds {};

    • Options
    • A. It will not compile because class body of Birds is not defined.
    • B. It will not compile because class body of Peacock is not defined.
    • C. It will not compile because a class cannot be protectedly inherited from other class.
    • D. It will compile succesfully.
    • Discuss


    Comments

    There are no comments.

Enter a new Comment