Exercise

1.Which of the followings is/are automatically added to every class, if we do not write our own.

A. Copy Constructor.
B. Assignment Operator
C. A constructor without any parameter
D. All of the above

View Answer


2. Which of the following gets called when an object is being created?

A. Constuctor
B. Virtual Function
C. Destructors
D. Main

View Answer


3.Destructor has a same name as the constructor and it is preceded by?

A. !
B. ?
C. ~
D. $

View Answer


4.Like constructors, can there be more than one destructors in a class?

A. Yes
B. No

View Answer


5.State whether the following statements about the constructor are True or False.
i) constructors should be declared in the private section.
ii) constructors are invoked automatically when the objects are created.

A. True,True
B. True,False
C. False,True
D. False,False

View Answer


6. Which of the following is true about constructors.
i) They cannot be virtual
ii) They cannot be private.
iii) They are automatically called by new operator.

A. All i,ii,iii
B. i & iii
C. ii & iii
D. i & ii

View Answer


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

A. Are called
B. Are not called
C. Are inherited
D. Are created

View Answer


8.Which contructor function is designed to copy object of same class type?

A. Copy constructor
B. Create constructor
C. Object constructor
D. Dynamic constructor

View Answer


9.Can destuctors be private in C++?

A. Yes
B. No

View Answer


10. Allocation of memory to objects at the time of their construction is known as ……………. of objects.

A. Run time construction
B. Dynamic Construction
C. Initial Construction
D. Staic Construction

View Answer


11.We must use initializer list in a constructor when

A. There is a reference variable in class
B. There is a constant variable in class
C. There is an object of another class. And the other class doesn't have default constructor
D. All of the above

View Answer


12.Which of the following implicitly creates a default constructor when the programmer does not explicitly define at least one constructor for a class?

A. Preprocessor
B. Linker
C. Loader
D. compiler

View Answer


13.constructor _______ to allow different approaches of object construction

A. Cannot overloaded
B. Can be overloaded
C. Can be called
D. Can be nested

View Answer


14.When are the Global objects destroyed?

A. When the control comes out of the block in which they are being used
B. When the program terminates
C. When the control comes out of the function in which they are being used.
D. As soon as local objects die

View Answer


15.Whenever const objects try to invoke non-const member functions, the compiler …………………

A. Return zero value
B. Return Null
C. Generate error
D. Return no Value

View Answer


16.When a copy constructor may be called?

A. When an object of the class is returned by value
B. When an object of the class is passed (to a function) by value as an argument.
C. Both A & B
D. None of the above

View Answer


17. If the copy constructor receives its arguments by value, the copy constructor would

A. Call one-argument constructor of the class
B. Work without any problem
C. Call itself recursively
D. Call zero-argument constructor

View Answer


18.which of this can not be declared as virtual

A. Constructor
B. Destructor
C Both A & B
D. None of the above

View Answer


19.For automatic objects, constructors and destructors are called each time the objects

A. Enter and leave scope
B. Inherit parent class
C. Are constructed
D. Are destroyed

View Answer


20.An ………………….. with a constructor or destructor cannot be used as a member or a union

A. Class
B. Object
C. Function.
D. Varible

View Answer




Discussion

* You must be logged in to add comment.

-->