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.
| 1. |
How To Enable /disable Call Of Finalize() Method Of Exit Of Application? |
|
Answer» Runtime.getRuntime().runFinalizersOnExit(boolean VALUE). PASSING the boolean value true and false will ENABLE or DISABLE the FINALIZE() call. Runtime.getRuntime().runFinalizersOnExit(boolean value). passing the boolean value true and false will enable or disable the finalize() call. |
|
| 2. |
What Are The Different Ways To Call Garbage Collector? |
Answer»
|
|
| 3. |
What Happens If An Uncaught Exception Is Thrown From During The Execution Of Finalize() Method Of An Object? |
|
Answer» The EXCEPTION will be ignored and the GARBAGE collection (FINALIZATION) of that OBJECT terminates The exception will be ignored and the garbage collection (finalization) of that object terminates |
|
| 4. |
How Many Times Does The Garbage Collector Calls The Finalize() Method For An Object? |
|
Answer» Only once. Only once. |
|
| 5. |
What Is Purpose Of Overriding Finalize() Method? |
|
Answer» The finalize() method should be OVERRIDDEN for an OBJECT to include the CLEAN up CODE or to dispose of the system resources that should to be done before the object is GARBAGE collected. The finalize() method should be overridden for an object to include the clean up code or to dispose of the system resources that should to be done before the object is garbage collected. |
|
| 6. |
What Are The Different Ways To Make An Object Eligible For Garbage Collection When It Is No Longer Needed? |
Answer»
package com.instanceofjava; class GarbageCollectionTest1{ public static void main(String [] args){ String str="garbage COLLECTION interview questions"; // String object REFERENCED by variable str and is not eligible for GC yet. str=null; //String object referenced by variable str is eligible for GC } }
package com.instanceofjava; class GarbageCollectionTest2{ public static void main(String [] args){ String str1="garbage collection interview questions"; String str2="Top 15 garbage collection interview questions"; // String object referenced by variable str1 and str2 and is not eligible for GC yet. str1=str2; //String object referenced by variable str1 is eligible for GC } } package com.instanceofjava; class GarbageCollectionTest1{ public static void main(String [] args){ String str="garbage collection interview questions"; // String object referenced by variable str and is not eligible for GC yet. str=null; //String object referenced by variable str is eligible for GC } } package com.instanceofjava; class GarbageCollectionTest2{ public static void main(String [] args){ String str1="garbage collection interview questions"; String str2="Top 15 garbage collection interview questions"; // String object referenced by variable str1 and str2 and is not eligible for GC yet. str1=str2; //String object referenced by variable str1 is eligible for GC } } |
|
| 7. |
When Does An Object Become Eligible For Garbage Collection? |
|
Answer» An OBJECT becomes ELIGIBLE for GARBAGE COLLECTION when no LIVE thread can access it. An object becomes eligible for garbage collection when no live thread can access it. |
|
| 8. |
What Is Responsibility Of Garbage Collector? |
Answer»
|
|
| 9. |
Which Part Of The Memory Is Involved In Garbage Collection? |
|
Answer» Heap. Heap. |
|
| 10. |
What Is The Algorithm Jvm Internally Uses For Destroying Objects? |
|
Answer» "MARK and SWAP" is the ALGORITHM JVM INTERNALLY uses. "mark and swap" is the algorithm JVM internally uses. |
|
| 11. |
How Can We Request Jvm To Start Garbage Collection Process? |
| Answer» | |
| 12. |
Can We Force Garbage Collector? |
|
Answer» No, we can not FORCE GARBAGE collector to destroy OBJECTS , but we can REQUEST it. No, we can not force garbage collector to destroy objects , but we can request it. |
|
| 13. |
So Can You Guarantee Objects Destruction? |
| Answer» | |
| 14. |
How Jvm Can Destroy Unreferenced Object? |
Answer»
|
|
| 15. |
What Is Garbage Collection In Java? |
Answer»
|
|