JOBSEEKERS
Login
Sign Up
Jobseeker
Employer
Staffing Firm
Direct Client
Object Oriented Programming interview questions part 15
Object Oriented Programming interview questions part 15
Back
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?
A. Just before end of program
B. Just after end of program
C. With the end of program
D. Anytime when object is not needed
Show Correct Answer
Correct Answer is :
Just before end of program
2. How the constructors and destructors can be differentiated?
A. Destructor have a return type but constructor doesn’t
B. Destructors can’t be defined by the programmer, but constructors can be defined
C. Destructors are preceded with a tilde (~) symbol, and constructor doesn’t
D. Destructors are same as constructors in syntax
Show Correct Answer
Correct Answer is :
Destructors are preceded with a tilde (~) symbol, and constructor doesn’t
3. Destructors doesn’t accept parameters.
A. TRUE
B. FALSE
C.
D.
Show Correct Answer
Correct Answer is :
TRUE
4. Destructors can be ________
A. Abstract type
B. Virtual
C. Void
D. Any type depending on situation
Show Correct Answer
Correct Answer is :
Virtual
5. Global destructors execute in ___________ order after main function is terminated
A. Sequential
B. Random
C. Reverse
D. Depending on priority
Show Correct Answer
Correct Answer is :
Reverse
6. When is it advised to have user defined destructor?
A. When class contains some pointer to memory allocated in class
B. When a class contains static variables
C. When a class contains static functions
D. When a class is inheriting another class only
Show Correct Answer
Correct Answer is :
When class contains some pointer to memory allocated in class
7. Which among the following is correct for destructors concept?
A. Destructors can be overloaded
B. Destructors can have only one parameter at maximum
C. Destructors are always called after object goes out of scope
D. There can be only one destructor in a class
Show Correct Answer
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;
A. ~A()
B. ~B()
C. ~C()
D. ~B() and ~C()
Show Correct Answer
Correct Answer is :
~C()
9. When an object is passed to a function, its copy is made in the function and then:
A. The destructor of the copy is called when function is returned
B. The destructor is never called in this case
C. The destructor is called but it is always implicit
D. The destructor must be user defined
Show Correct Answer
Correct Answer is :
The destructor of the copy is called when function is returned
10. What happens when an object is passed by reference?
A. Destructor is not called
B. Destructor is called at end of function
C. Destructor is called when function is out of scope
D. Destructor is called when called explicitly
Show Correct Answer
Correct Answer is :
Destructor is not called
11. What is downcasting?
A. Casting subtype to supertype
B. Casting supertype to subtype
C. Casting subtype to supertype and vice versa
D. Casting anytype to any other type
Show Correct Answer
Correct Answer is :
Casting supertype to subtype
12. Which among the following is a mandatory condition for downcasting?
A. It must not be done explicitly
B. It must be done implicitly
C. It must be done explicitly
D. It can’t be done explicitly
Show Correct Answer
Correct Answer is :
It must be done explicitly
13. Downcasting is _______________________
A. Always safe
B. Never safe
C. Safe sometimes
D. Safe, depending on code
Show Correct Answer
Correct Answer is :
Never safe
14. Downcasting ____________________
A. Can result in unexpected results
B. Can’t result in unexpected result
C. Can result only in out of memory error
D. Can’t result in any error
Show Correct Answer
Correct Answer is :
Can result in unexpected results
15. What should be used for safe downcast?
A. Static cast
B. Dynamic cast
C. Manual cast
D. Implicit cast
Show Correct Answer
Correct Answer is :
Dynamic cast
16. What does dynamic_cast return after successful type casting?
A. Address of object which is converted
B. Address of object that is used for conversion
C. Address of object that is mentioned in the syntax
D. Doesn’t return any address
Show Correct Answer
Correct Answer is :
Address of object which is converted
17. If dynamic_cast fails, which value is returned?
A. void
B.
C. void pointer
D. null pointer
Show Correct Answer
Correct Answer is :
null pointer
18. Which is the proper syntax of dynamic_cast?
A. dynamic_cast(object)
B. dynamic_cast new (object)
C. dynamic_cast(object)
D. dynamic_cast(object)
Show Correct Answer
Correct Answer is :
dynamic_cast(object)
19. Which is the exception handler for the exceptions of downcasting?
A. CastException
B. ClassCastingExeption
C. ClassCasting
D. ClassCastException
Show Correct Answer
Correct Answer is :
ClassCastException
20. How to prevent the ClassCastExceptions?
A. By using instanceof
B. By using is-a check
C. By using arrow operator with check function
D. By checking type of conversion
Show Correct Answer
Correct Answer is :
By using instanceof
Similar Interview Questions
Search for latest jobs
Find Jobs