Tuesday, March 4, 2014

8. CONSTRUCTORS AND DE STRUCTORS

1. Which of the following gets executed, when an instance of a class comes into scope?

(a) Overloading (b) Destructor (c) Constructor

2. Which of the following initializes the class object?

(a) friend function (b) member function (c) inline function

3. When a class object goes out of scope, a special function that gets executed is

(a) Destructor (b) Destroy (c) End

4. The constructor and the destruct or have the same name as the

(a) Function (b) Object (c) Variable

5. Which are special functions of classes?


(d) Encapsulation
(d) constructor function
(d) Constructor
(d) Class

(a) Encapsulation (b) Both Constructors and Destructors


(c) Constructors (d) Destructors






6. Which of the following functions return nothing?






(a) Destructor (b) Both Constructors and Destructors






(c) Pointer (d) Constructor
























7. The constructor add( ) is called as


(a) New (b) Non-parameterized (c) Parameterized (d) Copy


8. Which is a function that removes the memory of an object?


(a) Destructor (b) Scope (c) Pointer (d) Constructor


9. The destructor is prefixed with the symbol


(a) ~ (b) & (c) :: (d) ?:


10. Which is executed at the time of program termination?


(a) Polymorphism (b) Class (c) Constructor (d) Destructor


11. Which of the following are not associated with any data type?


(a) Constructor and destructor (b) Functions


(c) Destructors (d) Constructors


12. The memory space is allocated to an object using


(a) Instance (b) Constructor (c) Destructor (d) Overloading


13. The constructor without any parameter is called as


(a) Parameterized constructor (b) Copy constructor


(c) Default constructor (d) Standard constructor


14. The constructor defined by the computers in the absence of user defined constructor


(a) Parameterized (b) Default (c) Destructor (d) Copy


15. The constructor add( add &a ) is called as ----------- constructor.


(a) Parameterized (b) Default (c) Copy (d) Non-parameterized


16. The constructor add( int s1, int s2) is called as ----------- constructor.


(a) Copy (b) Parameterized (c) Non-parameterized (d) Default


17. Which is executed automatically when the control reaches the end of the class scope?


(a) Destructor (b) Constructor (c) Function (d) Overloading


18. When an object is passed by reference to constructor, the constructor that is executed is


(a) Parameterized (b) Non-parameterized (c) Default (d) Copy


19. Which of the following cannot be overloaded?


(a) Constructor (b) Operator (c) Destructor (d) Function


20. How many destructors are present in a class?


(a) any number (b) 2 (c) 3 (d) 1


21. Which of the following cannot have arguments?


(a) Function overloading (b) Operator overloading (c) Constructor (d) Destructor


22 Constructor should be declared under the scope


(a) private (b) pointer (c) public (d) protected


23. Which of the following is not true?






(a) Constructors can have parameters


(c) Constructors cannot be overloaded


24. Read the following C++ snippet:


class simple


{


private :


int x;


public:


simple(int y)


{


x=y;


}


~simple ()


{


}};


What is the name of the constructor?


(a) simple (b) public














(b) Destructors cannot be overloaded


(d) Constructors is executed automatically


































































(c)private (d) ~simple

























25. Read the following C++ snippet:
class simple


{


private :
int x;


public:


simple (int y)
{


x=y;
}


~simple ()
{


}


};


What type of constructor is used in this snippet?


(a) Parameterized (b) Copy (c) Non-parameterized (d) Data hiding


26. Which of the following is true?


(a) A destructor can have arguments (b) Constructor returns int type


(c) Constructor can have arguments (d) A destructor has a return type


27. Which of the following constructors is executed when a member function returns an object?


(a) Complier generated constructor (b) Default constructor


(c) Non-parameterized constructor (d) Copy constructor


28. Read the following snippet:
class simple


{


private :
int x;


public:


simple (int y)
(x=y);


};


void main()
{


simple s(6);
}


How many objects are created?





(a) 7 (b) 1 (c) 0 (d) 6

No comments:

Post a Comment