InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 51. |
Which among the following is false?(a) Constructor can’t be overloaded in Kotlin(b) Constructors can’t be called recursively in java(c) Constructors can be overloaded in C++(d) Constructors overloading depends on different signaturesThis question was addressed to me during an interview.The query is from Overloading Constructors topic in division Constructors and Destructors of Object Oriented Programming |
|
Answer» The correct option is (a) Constructor can’t be overloaded in KOTLIN |
|
| 52. |
Which is correct syntax?(a) classname objectname= new() integer;(b) classname objectname= new classname;(c) classname objectname= new classname();(d) classname objectname= new() classname();I have been asked this question in a national level competition.Question is from Overloading Constructors in division Constructors and Destructors of Object Oriented Programming |
|
Answer» Right answer is (c) classname objectname= new classname(); |
|
| 53. |
Which among the following best describes the constructors?(a) A function which is called whenever an object is referenced(b) A function which is called whenever an object is created to initialize the members(c) A function which is called whenever an object is assigned to copy the values(d) A function which is called whenever an object is to be given values for membersThe question was asked by my school principal while I was bunking the class.This key question is from Execution of Constructor or Destructor topic in chapter Constructors and Destructors of Object Oriented Programming |
|
Answer» Correct choice is (b) A function which is called whenever an object is created to initialize the members |
|
| 54. |
Which among the following best describes destructor?(a) A function which is called just before the objects are destroyed(b) A function which is called after each reference to the object(c) A function which is called after termination of the program(d) A function which is called before calling any member functionI have been asked this question in an online quiz.I would like to ask this question from Execution of Constructor or Destructor in section Constructors and Destructors of Object Oriented Programming |
|
Answer» Correct choice is (a) A FUNCTION which is called just before the objects are destroyed |
|
| 55. |
Which among the following represents correct constructor?(a) ()classname(b) ~classname()(c) –classname()(d) classname()I have been asked this question during a job interview.I'm obligated to ask this question of Execution of Constructor or Destructor topic in chapter Constructors and Destructors of Object Oriented Programming |
|
Answer» Right OPTION is (d) CLASSNAME() |
|
| 56. |
Which among the following is correct syntax for the destructors?(a) classname()(b) ()classname(c) ~classname()(d) -classname()I got this question during an internship interview.I'm obligated to ask this question of Execution of Constructor or Destructor in section Constructors and Destructors of Object Oriented Programming |
|
Answer» Correct answer is (c) ~classname() |
|
| 57. |
Which among the following is true?(a) First the constructor of parent classes are called in sequence of inheritance(b) First the constructor of child classes are called in the sequence of inheritance(c) First constructor called is of the object being created(d) Constructors are called randomlyI have been asked this question during an internship interview.The query is from Execution of Constructor or Destructor in division Constructors and Destructors of Object Oriented Programming |
|
Answer» Right option is (a) First the CONSTRUCTOR of parent classes are called in sequence of INHERITANCE |
|
| 58. |
What is the sequence of destructors call?(a) Same order as that of the constructors call(b) Random order(c) According to the priority(d) Revere of the order of constructor callI got this question during an interview for a job.This key question is from Execution of Constructor or Destructor in division Constructors and Destructors of Object Oriented Programming |
|
Answer» Right OPTION is (d) REVERE of the order of CONSTRUCTOR call |
|
| 59. |
The destructors _____________________(a) Can have maximum one argument(b) Can’t have any argument(c) Can have more than one argument(d) Can’t have more than 3 argumentsI have been asked this question in final exam.The query is from Execution of Constructor or Destructor topic in division Constructors and Destructors of Object Oriented Programming |
|
Answer» Right choice is (b) Can’t have any argument |
|
| 60. |
Destructor calls ________________ (C++)(a) Are only implicit(b) Are only explicit(c) Can be implicit or explicit(d) Are made at end of program onlyThis question was posed to me by my college director while I was bunking the class.My doubt stems from Execution of Constructor or Destructor in section Constructors and Destructors of Object Oriented Programming |
|
Answer» Right option is (c) Can be implicit or explicit |
|
| 61. |
Number of destructors called are ____________(a) Always equal to number of constructors called(b) Always less than the number of constructors called(c) Always greater than the number of constructors called(d) Always less than or equal to number of constructorsThis question was addressed to me during a job interview.I need to ask this question from Execution of Constructor or Destructor in section Constructors and Destructors of Object Oriented Programming |
|
Answer» Right answer is (a) ALWAYS equal to NUMBER of CONSTRUCTORS called |
|
| 62. |
For explicit call _________________(a) The destructor must be private(b) The destructor must be public(c) The destructor must be protected(d) The destructor must be defined outside the classThis question was addressed to me in homework.Query is from Execution of Constructor or Destructor in division Constructors and Destructors of Object Oriented Programming |
|
Answer» Right answer is (B) The destructor must be public |
|
| 63. |
If a class have 4 constructors then it must have 4 destructors also.(a) True(b) FalseThe question was posed to me during an internship interview.My doubt is from Execution of Constructor or Destructor topic in section Constructors and Destructors of Object Oriented Programming |
|
Answer» Right OPTION is (b) False |
|
| 64. |
Which among the following is true for destructors?(a) Destructors can be overloaded(b) Destructors can be define more than one time(c) Destructors can’t be overloaded(d) Destructors are overloaded in derived classesThe question was posed to me during an interview.The question is from Execution of Constructor or Destructor in division Constructors and Destructors of Object Oriented Programming |
|
Answer» Correct choice is (c) Destructors can’t be overloaded |
|
| 65. |
The constructor _____________(a) Have a return type(b) May have a return type(c) Of derived classes have return type(d) Doesn’t have a return typeI have been asked this question in an online quiz.The above asked question is from Execution of Constructor or Destructor in division Constructors and Destructors of Object Oriented Programming |
|
Answer» RIGHT option is (d) Doesn’t have a return type Explanation: The CONSTRUCTORS doesn’t have any return type. The constructors are intended to allocate the resources for the OBJECT. MEMORY spaces are to be FINALIZED. |
|
| 66. |
The destructors ____________(a) Have a return type(b) May have a return type(c) Of derived classes have return type(d) Doesn’t have a return typeI have been asked this question during a job interview.My question is based upon Execution of Constructor or Destructor topic in portion Constructors and Destructors of Object Oriented Programming |
|
Answer» The correct choice is (d) Doesn’t have a return type |
|
| 67. |
The destructor can be called before the constructor if required.(a) True(b) FalseThis question was posed to me in an online interview.Enquiry is from Execution of Constructor or Destructor in chapter Constructors and Destructors of Object Oriented Programming |
|
Answer» The correct choice is (b) False |
|
| 68. |
Which among the following describes a destructor?(a) A special function that is called to free the resources, acquired by the object(b) A special function that is called to delete the class(c) A special function that is called anytime to delete an object(d) A special function that is called to delete all the objects of a classI have been asked this question during an interview.The above asked question is from Destructors topic in section Constructors and Destructors of Object Oriented Programming |
|
Answer» Right ANSWER is (a) A special function that is called to free the resources, acquired by the object |
|
| 69. |
When a destructor is called?(a) After the end of object life(b) Anytime in between object’s lifespan(c) At end of whole program(d) Just before the end of object lifeThis question was posed to me in an interview for job.I need to ask this question from Destructors topic in portion Constructors and Destructors of Object Oriented Programming |
|
Answer» Correct option is (d) Just before the end of OBJECT life |
|
| 70. |
Which among the following is correct for abstract class destructors?(a) It doesn’t have destructors(b) It has destructors(c) It may or may not have destructors(d) It contains an implicit destructorI have been asked this question in an interview for internship.My enquiry is from Destructors in division Constructors and Destructors of Object Oriented Programming |
|
Answer» Right ANSWER is (a) It doesn’t have destructors |
|
| 71. |
If in multiple inheritance, class C inherits class B, and Class B inherits class A. In which sequence are their destructors called if an object of class C was declared?(a) ~C() then ~B() then ~A()(b) ~B() then ~C() then ~A()(c) ~A() then ~B() then ~C()(d) ~C() then ~A() then ~B()This question was addressed to me in exam.The doubt is from Destructors in section Constructors and Destructors of Object Oriented Programming |
|
Answer» Correct choice is (a) ~C() then ~B() then ~A() |
|
| 72. |
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 neededI got this question in an online quiz.This intriguing question originated from Destructors topic in section Constructors and Destructors of Object Oriented Programming |
|
Answer» Right answer is (a) Just before end of program |
|
| 73. |
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 syntaxI had been asked this question during an online interview.The origin of the question is Destructors topic in chapter Constructors and Destructors of Object Oriented Programming |
|
Answer» Correct option is (C) Destructors are preceded with a tilde (~) symbol, and constructor doesn’t |
|
| 74. |
Destructors doesn’t accept parameters.(a) True(b) FalseThe question was posed to me in an interview.This intriguing question originated from Destructors topic in chapter Constructors and Destructors of Object Oriented Programming |
|
Answer» RIGHT ANSWER is (a) True The BEST explanation: The destructors doesn’t accept the ARGUMENTS. Those are just used to free up the resources. |
|
| 75. |
Destructors can be ________(a) Abstract type(b) Virtual(c) Void(d) Any type depending on situationThis question was posed to me in an online quiz.This question is from Destructors topic in portion Constructors and Destructors of Object Oriented Programming |
|
Answer» Correct option is (b) Virtual |
|
| 76. |
Global destructors execute in ___________ order after main function is terminated.(a) Sequential(b) Random(c) Reverse(d) Depending on priorityThis question was posed to me in semester exam.The query is from Destructors topic in section Constructors and Destructors of Object Oriented Programming |
|
Answer» Right option is (c) REVERSE |
|
| 77. |
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 onlyThis question was addressed to me during an online exam.Origin of the question is Destructors topic in division Constructors and Destructors of Object Oriented Programming |
|
Answer» The correct answer is (a) When class contains some pointer to MEMORY allocated in class |
|
| 78. |
Which among the following is correct for the 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 classThe question was asked in an interview.I would like to ask this question from Destructors in section Constructors and Destructors of Object Oriented Programming |
|
Answer» The CORRECT choice is (d) There can be only one destructor in a class |
|
| 79. |
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 definedThe question was posed to me in semester exam.Enquiry is from Destructors topic in division Constructors and Destructors of Object Oriented Programming |
|
Answer» CORRECT option is (a) The destructor of the copy is called when function is returned The explanation: When an OBJECT is passed to a function, its copy is made in the function. This copy acts as a real object till the function is live. When the function is returned, the copy’s destructor is called to FREE the resources held by it. |
|
| 80. |
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 explicitlyThe question was posed to me in final exam.Query is from Destructors in chapter Constructors and Destructors of Object Oriented Programming |
|
Answer» Right option is (a) Destructor is not called |
|