Рет қаралды 92,600
In this video of code decode we have covered Garbage Collection Interview questions for experienced and fresher in Java
Udemy Course of Code Decode on Microservice k8s AWS CICD link:
openinapp.co/u...
Course Description Video :
yt.openinapp.c...
Garbage collection in java is a very crucial and complicated interview topic. It hides many complexities within.
As an overview we can say that Garbage collection in java is an automatic process of looking at heap memory, identifying which objects are in use and which are not, and deleting the unused objects.
An in use object, or a referenced object, means that some part of your program still maintains a pointer to that object.
An unused object, or unreferenced object, is no longer referenced by any part of your program. So the memory used by an unreferenced object can be reclaimed.
Main Advantage of automatic garbage collection in java is that it removes the burden of manual memory allocation/deallocation from us so that we can focus on problem solving.
Area where we get this object manages is heap :
Whenever an object is created, it’s always stored in the Heap space and stack memory contains the reference to it. Stack memory only contains local primitive variables and reference variables to objects in heap space.
Thus All Java objects are always created on heap in java. EG
CustomeObj s1 = new CustomeObj ()
What are the different ways to make an object eligible for GC when it is no longer needed??
1) Set all available object references to null
2) Make the reference variable to refer to another object
3) Creating Islands of Isolation
In video we have seen live demo of all the three methods
What is the purpose of overriding finalize() method?
Finalize method in Java also called finalizer is a method defined in java.lang.Object
Its called by Garbage collector just before collecting any object which is eligible for GC.
Thus Finalize() method provides last chance to object to do cleanup and free any remaining resource
In video we have seen live demo of overriding Object class's finalize method so that we can implement our customization before garbage collection is called.
And many such java garbage collection interview questions are solved using live demo examples.
Heap memory and generation strategy is covered in next section
Garbage Collections Interview Questions part -2
• Garbage Collection Int...
-------------------------------------------------------------------------------------------------------------------------------------
Code Decode Playlists
Most Asked Core Java Interview Questions and Answers : • Core Java frequently a...
Advance Java Interview Questions and Answers : • Advance Java Interview...
Java 8 Interview Questions and Answers : • Java 8 Interview Quest...
Hibernate Interview Questions and Answers : • Hibernate Interview Qu...
Spring Boot Interview Questions and Answers : • Advance Java Interview...
Angular Playlist : • Angular Course Introdu...
GIT : • GIT
-------------------------------------------------------------------------------------------------------------------------------------
Subscriber and Follow Code Decode
Subscriber Code Decode : www.youtube.co...
Linkedin : / codedecodeyoutube
Instagram : / codedecode25
--------------------------------------------------------------------------------------------------------------------------------------
#garbageCollectionInterviewQuestions #codedecode #garbageCollectionJava