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. |
In java, ____________________ takes care of managing memory for objects dynamically.(a) Free collector(b) Dust collector(c) Memory manager(d) Garbage collectorI had been asked this question in final exam.Asked question is from Memory Allocation of Object topic in chapter Object of Object Oriented Programming |
|
Answer» The CORRECT option is (d) Garbage collector |
|
| 52. |
If an object is declared in a user defined function __________________(a) Its memory is allocated in stack(b) Its memory is allocated in heap(c) Its memory is allocated in HDD(d) Its memory is allocated in cacheThe question was posed to me in a national level competition.I'm obligated to ask this question of Memory Allocation of Object in section Object of Object Oriented Programming |
|
Answer» The correct option is (a) Its memory is allocated in stack |
|
| 53. |
The memory allocated for an object ____________________(a) Can be only dynamic(b) Can be only static(c) Can be static or dynamic(d) Can’t be done using dynamic functionsI got this question by my college director while I was bunking the class.This intriguing question comes from Memory Allocation of Object in section Object of Object Oriented Programming |
|
Answer» Correct CHOICE is (C) Can be static or dynamic |
|
| 54. |
Which operator can be used to check the size of an object?(a) sizeof(objectName)(b) size(objectName)(c) sizeofobject(objectName)(d) sizedobject(objectName)The question was posed to me in final exam.The doubt is from Memory Allocation of Object in portion Object of Object Oriented Programming |
|
Answer» Correct answer is (a) SIZEOF(objectName) |
|
| 55. |
Which function is called whenever an object goes out of scope?(a) Destructor function(b) Constructor function(c) Delete function(d) Free functionI have been asked this question by my college professor while I was bunking the class.Question is taken from Memory Allocation of Object in portion Object of Object Oriented Programming |
|
Answer» CORRECT choice is (a) Destructor function Explanation: The destructor function of the CLASS is called whenever an object goes out of scope. This is because the destructor set all the RESOURCES, acquired by the object, FREE. This is an implicit work of compiler. |
|
| 56. |
Which among the following keyword can be used to free the allocated memory for an object?(a) delete(b) free(c) either delete or free(d) only deleteI got this question by my school teacher while I was bunking the class.Origin of the question is Memory Allocation of Object in chapter Object of Object Oriented Programming |
|
Answer» Right choice is (c) EITHER delete or free |
|
| 57. |
When is the memory allocated for an object gets free?(a) At termination of program(b) When object goes out of scope(c) When main function ends(d) When system restartsI have been asked this question during an interview for a job.Enquiry is from Memory Allocation of Object in portion Object of Object Oriented Programming |
|
Answer» The correct CHOICE is (b) When object GOES out of scope |
|
| 58. |
Which keyword among the following can be used to declare an array of objects in java?(a) new(b) create(c) allocate(d) arrThe question was posed to me by my school principal while I was bunking the class.My question is from Memory Allocation of Object in division Object of Object Oriented Programming |
|
Answer» CORRECT choice is (a) new For explanation: The keyword new can be used to declare an array of objects in java. The syntax MUST be specified with an object pointer which is ASSIGNED with a memory space containing the required number of object space. Even INITIALIZATION can be done directly. |
|
| 59. |
Which of the following function can be used for dynamic memory allocation of objects?(a) malloc()(b) calloc()(c) create()(d) malloc() and calloc()I have been asked this question during an internship interview.I need to ask this question from Memory Allocation of Object in division Object of Object Oriented Programming |
|
Answer» The correct CHOICE is (d) malloc() and calloc() |
|
| 60. |
Using new is type safe as _______________________(a) It require to be specified with type of data(b) It doesn’t require to be specified with type of data(c) It requires the name of data(d) It allocated memory for the dataThis question was addressed to me in a national level competition.My doubt is from Memory Allocation of Object topic in division Object of Object Oriented Programming |
|
Answer» Correct option is (b) It doesn’t REQUIRE to be specified with type of data |
|
| 61. |
When is the memory allocated for an object?(a) At declaration of object(b) At compile time(c) When object constructor is called(d) When object is initialized to another objectThe question was posed to me in an interview for internship.My doubt stems from Memory Allocation of Object topic in division Object of Object Oriented Programming |
|
Answer» RIGHT answer is (C) When object constructor is called For explanation: The object memory allocation TAKES place when the object constructor is called. Declaration of an object doesn’t mean that memory is ALLOCATED for its members. If object is initialized with another object, it may just GET a reference to the previously created object. |
|
| 62. |
Where is the memory allocated for the objects?(a) HDD(b) Cache(c) RAM(d) ROMThis question was addressed to me in unit test.The question is from Memory Allocation of Object topic in chapter Object of Object Oriented Programming |
|
Answer» The CORRECT ANSWER is (c) RAM |
|
| 63. |
What does memory allocation for objects mean?(a) Actual creation and memory allocation for object members(b) Creation of member functions(c) Creation of data members for a class(d) Actual creation and data declaration for object membersThis question was posed to me in quiz.Question is taken from Memory Allocation of Object topic in portion Object of Object Oriented Programming |
|
Answer» CORRECT CHOICE is (a) Actual creation and memory ALLOCATION for object members Explanation: The memory ALLOCATED for the object members indicates actual creation of the object members. This is KNOWN as memory allocation for object. |
|
| 64. |
Can reference to an object be returned from a method?(a) Yes, always possible(b) Yes, but not always(c) No, never possible(d) No, Not possible because referred element would be destroyedThe question was asked during an internship interview.My question comes from Object Reference topic in division Object of Object Oriented Programming |
|
Answer» The correct option is (b) Yes, but not always |
|
| 65. |
Invoking a method on a particular object is ____________ sending a message to that object.(a) Different from(b) Same as(c) Somewhat similar(d) Part ofThis question was posed to me in an online interview.This intriguing question comes from Object Reference topic in portion Object of Object Oriented Programming |
|
Answer» Right CHOICE is (b) Same as |
|