Загрузка страницы

Garbage Collection in java || Garbage collection interview questions (With Live Demo)

Garbage Collection in java || Garbage collection interview questions (With Live Demo)

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
https://youtu.be/bu12JCTeWOo

-------------------------------------------------------------------------------------------------------------------------------------

Code Decode Playlists

Most Asked Core Java Interview Questions and Answers : https://youtube.com/playlist?list=PLyHJZXNdCXscoyL5XEZoHHZ86_6h3GWE1

Advance Java Interview Questions and Answers : https://youtube.com/playlist?list=PLyHJZXNdCXsexOO1VQ4vs-BM2-8CKrixd

Java 8 Interview Questions and Answers : https://youtube.com/playlist?list=PLyHJZXNdCXsdeusn4OM33415DCMQ6sUKy

Hibernate Interview Questions and Answers : https://youtube.com/playlist?list=PLyHJZXNdCXsdC-p2186C6NO4FpadnCC_q

Spring Boot Interview Questions and Answers : https://youtube.com/playlist?list=PLyHJZXNdCXsexOO1VQ4vs-BM2-8CKrixd

Angular Playlist : https://www.youtube.com/watch?v=CAl7RQSdq2Q&list=PLyHJZXNdCXsfxRtDwtGkDD_lLfTWc1g0i

GIT : https://youtube.com/playlist?list=PLyHJZXNdCXscpl6pxOnL2lRWJlzvzjyZE

-------------------------------------------------------------------------------------------------------------------------------------
Subscriber and Follow Code Decode

Subscriber Code Decode : https://www.youtube.com/c/CodeDecode?sub_confirmation=1

Linkedin : https://www.linkedin.com/in/codedecodeyoutube/

Instagram : https://www.instagram.com/codedecode25/

--------------------------------------------------------------------------------------------------------------------------------------

#garbageCollectionInterviewQuestions #codedecode #garbageCollectionJava

Видео Garbage Collection in java || Garbage collection interview questions (With Live Demo) канала Code Decode
Показать
Комментарии отсутствуют
Введите заголовок:

Введите адрес ссылки:

Введите адрес видео с YouTube:

Зарегистрируйтесь или войдите с
Информация о видео
4 декабря 2020 г. 0:53:20
00:25:02
Яндекс.Метрика