| Snaprecruit.com

| Snaprecruit.com

Interview question based on skill :

Take as many assements as you can to improve your validate your skill rating

Total Questions: 20

1. When is the destructor of a global object called?

Correct Answer is : Just before end of program

2. How the constructors and destructors can be differentiated?

Correct Answer is : Destructors are preceded with a tilde (~) symbol, and constructor doesn’t

3. Destructors doesn’t accept parameters.

Correct Answer is : TRUE

4. Destructors can be ________

Correct Answer is : Virtual

5. Global destructors execute in ___________ order after main function is terminated

Correct Answer is : Reverse

6. When is it advised to have user defined destructor?

Correct Answer is : When class contains some pointer to memory allocated in class

7. Which among the following is correct for destructors concept?

Correct Answer is : There can be only one destructor in a class

8. Which class destructor will be called first, when following code go out of scope? class A{ }; class B{ }; class C: public B{ }; A a; B b; C c;

Correct Answer is : ~C()

9. When an object is passed to a function, its copy is made in the function and then:

Correct Answer is : The destructor of the copy is called when function is returned

10. What happens when an object is passed by reference?

Correct Answer is : Destructor is not called

11. What is downcasting?

Correct Answer is : Casting supertype to subtype

12. Which among the following is a mandatory condition for downcasting?

Correct Answer is : It must be done explicitly

13. Downcasting is _______________________

Correct Answer is : Never safe

14. Downcasting ____________________

Correct Answer is : Can result in unexpected results

15. What should be used for safe downcast?

Correct Answer is : Dynamic cast

16. What does dynamic_cast return after successful type casting?

Correct Answer is : Address of object which is converted

17. If dynamic_cast fails, which value is returned?

Correct Answer is : null pointer

18. Which is the proper syntax of dynamic_cast?

Correct Answer is : dynamic_cast(object)

19. Which is the exception handler for the exceptions of downcasting?

Correct Answer is : ClassCastException

20. How to prevent the ClassCastExceptions?

Correct Answer is : By using instanceof