|
INTERVIEW QUESTIONS
J2EE
CORE JAVA
DETAILS
Question: Explain garbage collection?
Answer: Garbage collection is one of the most important feature of Java. Garbage collection is also called automatic memory management as JVM automatically removes the unused variables/objects (value is null) from the memory. User program cann't directly free the object from memory, instead it is the job of the garbage collector to automatically free the objects that are no longer referenced by a program. Every class inherits finalize() method from java.lang.Object, the finalize() method is called by garbage collector when it determines no more references to the object exists. In Java, it is good idea to explicitly assign null into a variable when no more in use. I Java on calling System.gc() and Runtime.gc(), JVM tries to recycle the unused objects, but there is no guarantee when all the objects will garbage collected.
|
|
|
Category |
Core Java Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.3) By 6515 users |
Added on |
8/24/2014 |
Views |
65702 |
Rate it! |
|
|
Question:
Explain garbage collection?
Answer:
Garbage collection is one of the most important feature of Java. Garbage collection is also called automatic memory management as JVM automatically removes the unused variables/objects (value is null) from the memory. User program cann't directly free the object from memory, instead it is the job of the garbage collector to automatically free the objects that are no longer referenced by a program. Every class inherits finalize() method from java.lang.Object, the finalize() method is called by garbage collector when it determines no more references to the object exists. In Java, it is good idea to explicitly assign null into a variable when no more in use. I Java on calling System.gc() and Runtime.gc(), JVM tries to recycle the unused objects, but there is no guarantee when all the objects will garbage collected. Source: CoolInterview.com
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
Explain the user defined Exceptions?
|
View Answer
|
|
How to define an Interface?
|
View Answer
|
|
How to define an Abstract class?
|
View Answer
|
|
What is difference between an Abstract class and Interface?
|
View Answer
|
|
What is similarities between an Abstract class and Interface?
|
View Answer
|
|
What is Collection API?
|
View Answer
|
|
What do you understand by Synchronization?
|
View Answer
|
|
What is transient variable?
|
View Answer
|
|
What is a local, member and a class variable?
|
View Answer
|
|
What are wrapped classes?
|
View Answer
|
|
What does it mean that a method or field is “static”?
|
View Answer
|
|
What modifiers are allowed for methods in an Interface?
|
View Answer
|
|
Why operator overloading is not there in java?
|
View Answer
|
|
What modifiers are allowed for methods in an Interface?
|
View Answer
|
|
What is a local, member and a class variable?
|
View Answer
|
Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.
View All Core Java Interview Questions & Answers - Exam Mode /
Learning Mode
|