logo

CuriousTab

CuriousTab

Discussion


Home C++ Programming Constructors and Destructors See What Others Are Saying!
  • Question
  • __________ 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

  • Correct Answer
  • copy constructor 


  • More questions

    • 1. 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
    • 2. 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
    • 3. 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
    • 4. 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
    • 5. 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
    • 6. Which of the following statement is correct about the references?

    • Options
    • A. A reference must always be initialized within functions.
    • B. A reference must always be initialized outside all functions.
    • C. A reference must always be initialized.
    • D. Both A and C.
    • Discuss
    • 7. Which of the following statements is correct?

      1. Pointer to a reference and reference to a pointer both are valid.
      2. When we use reference, we are actually referring to a referent.

    • 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
    • 8. Which one of the following options is correct about the statement given below? The compiler checks the type of reference in the object and not the type of object.

    • Options
    • A. Inheritance
    • B. Polymorphism
    • C. Abstraction
    • D. Encapsulation
    • Discuss
    • 9. What will be the output of the following program?
      #include<iostream.h> 
      class Tab
      {
          int x, y; 
          public:
          void show(void);
          void main(void);
      };
      void Tab::show(void)
      { 
          Tab b;
          b.x = 2;
          b.y = 4;
          cout<< x << " " << y;
      }
      void Tab::main(void)
      {
          Tab b;
          b.x = 6; 
          b.y = 8;
          b.show();
      }
      int main(int argc, char *argv[])
      {
          Tab run;
          run.main();
          return 0; 
      }

    • Options
    • A. 2 4
    • B. 6 8
    • C. The program will report error on Compilation.
    • D. The program will report error on Linking.
    • E. The program will report error on Run-time.
    • Discuss
    • 10. A reference is declared using the _____ symbol.

    • Options
    • A. &&
    • B. &
    • C. ||
    • D. !
    • Discuss


    Comments

    There are no comments.

Enter a new Comment