SlideShare a Scribd company logo
1 of 9
Download to read offline
Garbage Collection
Team Members:
Aleezay Yousaf BCSF13M002
Seemal Afza BCSF13M012
Shazim Khan BCSF13M006
1. What does garbage collection do?
a. Memory Management technique.
b. Process of freeing objects.
c. No longer referenced by the program.
d. All of above
2. In .Net, which pointer does Managed heap use to indicate the position where next object
is to be allocated within the heap?
a. Next
b. Ptr
c. NextObjPtr
d. Pointer is not used
3. Ways for making objects eligible for collection that are no longer needed
a. Nulling a reference
b. Reassigning a reference variable
c. Isolating a reference
d. All of above
4. Which part of the memory is involved in Garbage Collection?
a. Stack
b. Heap
c. Both
5. How many times does the garbage collector calls the finalize() method for an object?
a. Once
b. Never
c. Twice
6. What happens if an uncaught exception is thrown from during the execution of the
finalize() method of an object?
a. The exception will be ignored and the garbage collection (finalization) of that
object terminates.
b. Program crashes due to that exception.
c. Depends on the type of exception
d. None of above
7. How to call garbage collector?
a. System.gc()
b. Runtime.getRuntime().gc()
c. Both a & b
d. None of them
8. Why is it good?
a. Manual memory management is time consuming, and error prone
b. Most programs still contain leaks when using manual memory management
c. Both a & b
d. None of above
9. Is garbage collector a dameon thread?
a. Yes
b. No
c. Not sure
10. What does allows user to destroy an object x in Java?
a. x.delete()
b. x.finalize()
c. Runtime.getRuntime().gc()
d. Only the garbage collection system can destroy an object.
11. Which operator is used by Java run time implementations to free the memory of an object
when it is no longer needed?
a. Delete
b. Free
c. New
d. None of the mentioned
12. Which function is used to perform some action when the object is to be destroyed?
a. Finalize()
b. delete()
c. main()
d. None of the mentioned
13. Which of the following statements are incorrect?
a. Default constructor is called at the time of declaration of the object if a
constructor has not been defined.
b. Constructor can be parameterized.
c. finalize() method is called when a object goes out of scope and is no longer
needed.
d. finalize() method must be declared protected.
14.
15. void start() {
16. A a = new A();
17. B b = new B();
18. a.s(b);
19. b = null; /* Line 5 */
20. a = null; /* Line 6 */
21. System.out.println("start completed"); /* Line 7 */
22. }
When is the B object, created in line 3, eligible for garbage collection?
a. After line 5
b. After line 6
c. After line 7
d. There is no certain way of knowing
15.
class Test
{
private Demo d;
void start()
{
d = new Demo();
this.takeDemo(d); /* Line 7 */
} /* Line 8 */
void takeDemo(Demo demo)
{
demo = null;
demo = new Demo();
}
}
When is the Demo object eligible for garbage collection?
a. After line 7
b. After line 8
c. After the start() method completes
d. When the instance running this code is made eligible for garbage collection.
16.
public class X
{
public static void main(String [] args)
{
X x = new X();
X x2 = m1(x); /* Line 6 */
X x4 = new X();
x2 = x4; /* Line 8 */
doComplexStuff();
}
static X m1(X mx)
{
mx = new X();
return mx;
}
}
After line 8 runs. how many objects are eligible for garbage collection?
a. 0
b. 1
c. 2
d. 3
17.
18. public Object m()
19. {
20. Object o = new Float(3.14F);
21. Object [] oa = new Object[l];
22. oa[0] = o; /* Line 5 */
23. o = null; /* Line 6 */
24. oa[0] = null; /* Line 7 */
25. return o; /* Line 8 */
26. }
When is the Float object, created in line 3, eligible for garbage collection?
a. After line 5
b. After line 6
c. After line 7
d. After line 8
18.
19. class X2
20. {
21. public X2 x;
22. public static void main(String [] args)
23. {
24. X2 x2 = new X2(); /* Line 6 */
25. X2 x3 = new X2(); /* Line 7 */
26. x2.x = x3;
27. x3.x = x2;
28. x2 = new X2();
29. x3 = x2; /* Line 11 */
30. doComplexStuff();
31. }
32. }
after line 11 runs, how many objects are eligible for garbage collection?
a. 0
b. 1
c. 2
d. 3
19.
20. class Bar { }
21. class Test
22. {
23. Bar doBar()
24. {
25. Bar b = new Bar(); /* Line 6 */
26. return b; /* Line 7 */
27. }
28. public static void main (String args[])
29. {
30. Test t = new Test(); /* Line 11 */
31. Bar newBar = t.doBar(); /* Line 12 */
32. System.out.println("newBar");
33. newBar = new Bar(); /* Line 14 */
34. System.out.println("finishing"); /* Line 15 */
35. }
36. }
At what point is the Bar object, created on line 6, eligible for garbage collection?
a. after line 12
b. after line 14
c. after line 7, when doBar() completes
d. after line 15, when main() completes
20.
21. class HappyGarbage01
22. {
23. public static void main(String args[])
24. {
25. HappyGarbage01 h = new HappyGarbage01();
26. h.methodA(); /* Line 6 */
27. }
28. Object methodA()
29. {
30. Object obj1 = new Object();
31. Object [] obj2 = new Object[1];
32. obj2[0] = obj1;
33. obj1 = null;
34. return obj2[0];
35. }
36. }
Where will be the most chance of the garbage collector being invoked?
a. After line 9
b. After line 10
c. After line 11
d. Garbage collector never invoked in methodA()
21. Which statement is true?
a. Programs will not run out of memory
b. Objects that will never again be used are eligible for garbage collection.
c. Objects that are referred to by other objects will never be garbage collected.
d. Objects that can be reached from a live thread will never be garbage collected.
22. Which statement is true?
a. All objects that are eligible for garbage collection will be garbage collected by the
collector.
b. Objects with at least one reference will never be garbage collected.
c. Objects from a class with the finalize() method overridden will never be garbage
collected.
d. Objects instantiated within anonymous inner classes are placed in the garbage
collectible heap.
23. Which of the following is not an approach for garbage collection?
a. Copying
b. Tracing
c. Reference Counting
d. The plane algorithm
24. What does reference counting do?
a. Count for each object.
b. Count increases as number of reference increases.
c. Eligible for GC when count equals zero.
d. All of above
25. Tracing is also known as
a. Mark algorithm
b. Mark and Sweep algorithm
c. Sweeping algorithm
d. None of them
26. Which objects are not reachable in tracing?
a. Marked ones
b. Unmarked ones
c. None of above
27. Which approach works on the basis of lifetimes of objects.
a. Generational Collectors
b. Tracing
c. Reference counting
d. Copying
28. Which of the following statement is incorrect?
a. Finalize is very different from destructors.
b. Finalize is same as destructors.
c. Finalizable objects may refer to other (non-finalizable) objects, prolonging their
lifetime unnecessarily.
d. None of them
29. What is resurrection?
a. An object requiring finalization dies, lives, and then dies again, this phenomenon
is called resurrection.
b. An object requiring finalization lives, and then dies again, this phenomenon is
called resurrection.
30. Which objects are collected before others in generational collectors?
a. Short lived objects
b. Long lived objects
c. Any object can be collected at any time
d. None of above
Video Link: https://www.youtube.com/watch?v=7AcptSGscKY&feature=youtu.be

More Related Content

What's hot

III EEE-CS2363-Computer-Networks-model-question-paper-set-1-for-may-june-2014
III EEE-CS2363-Computer-Networks-model-question-paper-set-1-for-may-june-2014III EEE-CS2363-Computer-Networks-model-question-paper-set-1-for-may-june-2014
III EEE-CS2363-Computer-Networks-model-question-paper-set-1-for-may-june-2014Selva Kumar
 
Coroutines in Kotlin
Coroutines in KotlinCoroutines in Kotlin
Coroutines in KotlinAlexey Soshin
 
Devoxx - France : Making Swift – 10 enseignements qu’on peut tirer des 31.463...
Devoxx - France : Making Swift – 10 enseignements qu’on peut tirer des 31.463...Devoxx - France : Making Swift – 10 enseignements qu’on peut tirer des 31.463...
Devoxx - France : Making Swift – 10 enseignements qu’on peut tirer des 31.463...Publicis Sapient Engineering
 
PVS-Studio for Linux (CoreHard presentation)
PVS-Studio for Linux (CoreHard presentation)PVS-Studio for Linux (CoreHard presentation)
PVS-Studio for Linux (CoreHard presentation)Andrey Karpov
 
Ruby basics || updated
Ruby basics || updatedRuby basics || updated
Ruby basics || updateddatt30
 
Swarm.js: реактивная синхронизация данных — Виктор Грищенко — MoscowJS 13
Swarm.js: реактивная синхронизация данных — Виктор Грищенко — MoscowJS 13Swarm.js: реактивная синхронизация данных — Виктор Грищенко — MoscowJS 13
Swarm.js: реактивная синхронизация данных — Виктор Грищенко — MoscowJS 13MoscowJS
 
D422 7-2 string hadeling
D422 7-2  string hadelingD422 7-2  string hadeling
D422 7-2 string hadelingOmkar Rane
 
Qtp certification questions and tutorial
Qtp certification questions and tutorialQtp certification questions and tutorial
Qtp certification questions and tutorialRamu Palanki
 
Stream Processing in the Cloud - Athens Kubernetes Meetup 16.07.2019
Stream Processing in the Cloud - Athens Kubernetes Meetup 16.07.2019Stream Processing in the Cloud - Athens Kubernetes Meetup 16.07.2019
Stream Processing in the Cloud - Athens Kubernetes Meetup 16.07.2019Rafał Leszko
 
Porting an MPI application to hybrid MPI+OpenMP with Reveal tool on Shaheen II
Porting an MPI application to hybrid MPI+OpenMP with Reveal tool on Shaheen IIPorting an MPI application to hybrid MPI+OpenMP with Reveal tool on Shaheen II
Porting an MPI application to hybrid MPI+OpenMP with Reveal tool on Shaheen IIGeorge Markomanolis
 

What's hot (14)

Java fork join
Java fork joinJava fork join
Java fork join
 
III EEE-CS2363-Computer-Networks-model-question-paper-set-1-for-may-june-2014
III EEE-CS2363-Computer-Networks-model-question-paper-set-1-for-may-june-2014III EEE-CS2363-Computer-Networks-model-question-paper-set-1-for-may-june-2014
III EEE-CS2363-Computer-Networks-model-question-paper-set-1-for-may-june-2014
 
Coroutines in Kotlin
Coroutines in KotlinCoroutines in Kotlin
Coroutines in Kotlin
 
C# p7
C# p7C# p7
C# p7
 
Permute
PermutePermute
Permute
 
Devoxx - France : Making Swift – 10 enseignements qu’on peut tirer des 31.463...
Devoxx - France : Making Swift – 10 enseignements qu’on peut tirer des 31.463...Devoxx - France : Making Swift – 10 enseignements qu’on peut tirer des 31.463...
Devoxx - France : Making Swift – 10 enseignements qu’on peut tirer des 31.463...
 
PVS-Studio for Linux (CoreHard presentation)
PVS-Studio for Linux (CoreHard presentation)PVS-Studio for Linux (CoreHard presentation)
PVS-Studio for Linux (CoreHard presentation)
 
Ruby basics || updated
Ruby basics || updatedRuby basics || updated
Ruby basics || updated
 
Analysis of algo
Analysis of algoAnalysis of algo
Analysis of algo
 
Swarm.js: реактивная синхронизация данных — Виктор Грищенко — MoscowJS 13
Swarm.js: реактивная синхронизация данных — Виктор Грищенко — MoscowJS 13Swarm.js: реактивная синхронизация данных — Виктор Грищенко — MoscowJS 13
Swarm.js: реактивная синхронизация данных — Виктор Грищенко — MoscowJS 13
 
D422 7-2 string hadeling
D422 7-2  string hadelingD422 7-2  string hadeling
D422 7-2 string hadeling
 
Qtp certification questions and tutorial
Qtp certification questions and tutorialQtp certification questions and tutorial
Qtp certification questions and tutorial
 
Stream Processing in the Cloud - Athens Kubernetes Meetup 16.07.2019
Stream Processing in the Cloud - Athens Kubernetes Meetup 16.07.2019Stream Processing in the Cloud - Athens Kubernetes Meetup 16.07.2019
Stream Processing in the Cloud - Athens Kubernetes Meetup 16.07.2019
 
Porting an MPI application to hybrid MPI+OpenMP with Reveal tool on Shaheen II
Porting an MPI application to hybrid MPI+OpenMP with Reveal tool on Shaheen IIPorting an MPI application to hybrid MPI+OpenMP with Reveal tool on Shaheen II
Porting an MPI application to hybrid MPI+OpenMP with Reveal tool on Shaheen II
 

Similar to Garbage collection

UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 2
UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 2UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 2
UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 2Knowledge Center Computer
 
Polymorphism, Abstarct Class and Interface in C#
Polymorphism, Abstarct Class and Interface in C#Polymorphism, Abstarct Class and Interface in C#
Polymorphism, Abstarct Class and Interface in C#Umar Farooq
 
Prueba de conociemientos Fullsctack NET v2.docx
Prueba de conociemientos  Fullsctack NET v2.docxPrueba de conociemientos  Fullsctack NET v2.docx
Prueba de conociemientos Fullsctack NET v2.docxjairatuesta
 
Std 12 computer chapter 8 classes and objects in java important MCQs
Std 12 computer chapter 8 classes and objects in java important MCQsStd 12 computer chapter 8 classes and objects in java important MCQs
Std 12 computer chapter 8 classes and objects in java important MCQsNuzhat Memon
 
Qtp certification questions
Qtp certification questionsQtp certification questions
Qtp certification questionsRamu Palanki
 
Qtp certification questions
Qtp certification questionsQtp certification questions
Qtp certification questionsRamu Palanki
 
Qtp certification questions and tutorial
Qtp certification questions and tutorialQtp certification questions and tutorial
Qtp certification questions and tutorialRamu Palanki
 
C aptitude 1st jan 2012
C aptitude 1st jan 2012C aptitude 1st jan 2012
C aptitude 1st jan 2012Kishor Parkhe
 
Csphtp1 06
Csphtp1 06Csphtp1 06
Csphtp1 06HUST
 
Java level 1 Quizzes
Java level 1 QuizzesJava level 1 Quizzes
Java level 1 QuizzesSteven Luo
 
Multiple Choice Questions for Java interfaces and exception handling
Multiple Choice Questions for Java interfaces and exception handlingMultiple Choice Questions for Java interfaces and exception handling
Multiple Choice Questions for Java interfaces and exception handlingAbishek Purushothaman
 
Technical aptitude test 2 CSE
Technical aptitude test 2 CSETechnical aptitude test 2 CSE
Technical aptitude test 2 CSESujata Regoti
 
Comp 328 final guide
Comp 328 final guideComp 328 final guide
Comp 328 final guidekrtioplal
 
Geek Time Janvier 2017 : Quiz Java
Geek Time Janvier 2017 : Quiz JavaGeek Time Janvier 2017 : Quiz Java
Geek Time Janvier 2017 : Quiz JavaOLBATI
 
(Www.entrance exam.net)-tcs placement sample paper 2
(Www.entrance exam.net)-tcs placement sample paper 2(Www.entrance exam.net)-tcs placement sample paper 2
(Www.entrance exam.net)-tcs placement sample paper 2Pamidimukkala Sivani
 
200 mcq c++(Ankit dubey)
200 mcq c++(Ankit dubey)200 mcq c++(Ankit dubey)
200 mcq c++(Ankit dubey)Ankit Dubey
 
C++ memory leak detection
C++ memory leak detectionC++ memory leak detection
C++ memory leak detectionVõ Hòa
 

Similar to Garbage collection (20)

UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 2
UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 2UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 2
UGC-NET, GATE and all IT Companies Interview C++ Solved Questions PART - 2
 
Polymorphism, Abstarct Class and Interface in C#
Polymorphism, Abstarct Class and Interface in C#Polymorphism, Abstarct Class and Interface in C#
Polymorphism, Abstarct Class and Interface in C#
 
Prueba de conociemientos Fullsctack NET v2.docx
Prueba de conociemientos  Fullsctack NET v2.docxPrueba de conociemientos  Fullsctack NET v2.docx
Prueba de conociemientos Fullsctack NET v2.docx
 
Std 12 computer chapter 8 classes and objects in java important MCQs
Std 12 computer chapter 8 classes and objects in java important MCQsStd 12 computer chapter 8 classes and objects in java important MCQs
Std 12 computer chapter 8 classes and objects in java important MCQs
 
Qtp certification questions
Qtp certification questionsQtp certification questions
Qtp certification questions
 
Qtp certification questions
Qtp certification questionsQtp certification questions
Qtp certification questions
 
Qtp certification questions and tutorial
Qtp certification questions and tutorialQtp certification questions and tutorial
Qtp certification questions and tutorial
 
C aptitude 1st jan 2012
C aptitude 1st jan 2012C aptitude 1st jan 2012
C aptitude 1st jan 2012
 
Html
HtmlHtml
Html
 
Csphtp1 06
Csphtp1 06Csphtp1 06
Csphtp1 06
 
Java level 1 Quizzes
Java level 1 QuizzesJava level 1 Quizzes
Java level 1 Quizzes
 
Multiple Choice Questions for Java interfaces and exception handling
Multiple Choice Questions for Java interfaces and exception handlingMultiple Choice Questions for Java interfaces and exception handling
Multiple Choice Questions for Java interfaces and exception handling
 
Revisão OCPJP7 - Class Design (parte 02)
Revisão OCPJP7 - Class Design (parte 02) Revisão OCPJP7 - Class Design (parte 02)
Revisão OCPJP7 - Class Design (parte 02)
 
Technical aptitude test 2 CSE
Technical aptitude test 2 CSETechnical aptitude test 2 CSE
Technical aptitude test 2 CSE
 
Java Inheritance
Java InheritanceJava Inheritance
Java Inheritance
 
Comp 328 final guide
Comp 328 final guideComp 328 final guide
Comp 328 final guide
 
Geek Time Janvier 2017 : Quiz Java
Geek Time Janvier 2017 : Quiz JavaGeek Time Janvier 2017 : Quiz Java
Geek Time Janvier 2017 : Quiz Java
 
(Www.entrance exam.net)-tcs placement sample paper 2
(Www.entrance exam.net)-tcs placement sample paper 2(Www.entrance exam.net)-tcs placement sample paper 2
(Www.entrance exam.net)-tcs placement sample paper 2
 
200 mcq c++(Ankit dubey)
200 mcq c++(Ankit dubey)200 mcq c++(Ankit dubey)
200 mcq c++(Ankit dubey)
 
C++ memory leak detection
C++ memory leak detectionC++ memory leak detection
C++ memory leak detection
 

Recently uploaded

FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 

Recently uploaded (20)

FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 

Garbage collection

  • 1. Garbage Collection Team Members: Aleezay Yousaf BCSF13M002 Seemal Afza BCSF13M012 Shazim Khan BCSF13M006
  • 2. 1. What does garbage collection do? a. Memory Management technique. b. Process of freeing objects. c. No longer referenced by the program. d. All of above 2. In .Net, which pointer does Managed heap use to indicate the position where next object is to be allocated within the heap? a. Next b. Ptr c. NextObjPtr d. Pointer is not used 3. Ways for making objects eligible for collection that are no longer needed a. Nulling a reference b. Reassigning a reference variable c. Isolating a reference d. All of above 4. Which part of the memory is involved in Garbage Collection? a. Stack b. Heap c. Both 5. How many times does the garbage collector calls the finalize() method for an object? a. Once b. Never c. Twice 6. What happens if an uncaught exception is thrown from during the execution of the finalize() method of an object? a. The exception will be ignored and the garbage collection (finalization) of that object terminates. b. Program crashes due to that exception. c. Depends on the type of exception d. None of above 7. How to call garbage collector?
  • 3. a. System.gc() b. Runtime.getRuntime().gc() c. Both a & b d. None of them 8. Why is it good? a. Manual memory management is time consuming, and error prone b. Most programs still contain leaks when using manual memory management c. Both a & b d. None of above 9. Is garbage collector a dameon thread? a. Yes b. No c. Not sure 10. What does allows user to destroy an object x in Java? a. x.delete() b. x.finalize() c. Runtime.getRuntime().gc() d. Only the garbage collection system can destroy an object. 11. Which operator is used by Java run time implementations to free the memory of an object when it is no longer needed? a. Delete b. Free c. New d. None of the mentioned 12. Which function is used to perform some action when the object is to be destroyed? a. Finalize()
  • 4. b. delete() c. main() d. None of the mentioned 13. Which of the following statements are incorrect? a. Default constructor is called at the time of declaration of the object if a constructor has not been defined. b. Constructor can be parameterized. c. finalize() method is called when a object goes out of scope and is no longer needed. d. finalize() method must be declared protected. 14. 15. void start() { 16. A a = new A(); 17. B b = new B(); 18. a.s(b); 19. b = null; /* Line 5 */ 20. a = null; /* Line 6 */ 21. System.out.println("start completed"); /* Line 7 */ 22. } When is the B object, created in line 3, eligible for garbage collection? a. After line 5 b. After line 6 c. After line 7 d. There is no certain way of knowing 15. class Test { private Demo d; void start() { d = new Demo(); this.takeDemo(d); /* Line 7 */
  • 5. } /* Line 8 */ void takeDemo(Demo demo) { demo = null; demo = new Demo(); } } When is the Demo object eligible for garbage collection? a. After line 7 b. After line 8 c. After the start() method completes d. When the instance running this code is made eligible for garbage collection. 16. public class X { public static void main(String [] args) { X x = new X(); X x2 = m1(x); /* Line 6 */ X x4 = new X(); x2 = x4; /* Line 8 */ doComplexStuff(); } static X m1(X mx) { mx = new X(); return mx; } } After line 8 runs. how many objects are eligible for garbage collection? a. 0 b. 1 c. 2 d. 3 17.
  • 6. 18. public Object m() 19. { 20. Object o = new Float(3.14F); 21. Object [] oa = new Object[l]; 22. oa[0] = o; /* Line 5 */ 23. o = null; /* Line 6 */ 24. oa[0] = null; /* Line 7 */ 25. return o; /* Line 8 */ 26. } When is the Float object, created in line 3, eligible for garbage collection? a. After line 5 b. After line 6 c. After line 7 d. After line 8 18. 19. class X2 20. { 21. public X2 x; 22. public static void main(String [] args) 23. { 24. X2 x2 = new X2(); /* Line 6 */ 25. X2 x3 = new X2(); /* Line 7 */ 26. x2.x = x3; 27. x3.x = x2; 28. x2 = new X2(); 29. x3 = x2; /* Line 11 */ 30. doComplexStuff(); 31. } 32. } after line 11 runs, how many objects are eligible for garbage collection? a. 0 b. 1 c. 2 d. 3 19.
  • 7. 20. class Bar { } 21. class Test 22. { 23. Bar doBar() 24. { 25. Bar b = new Bar(); /* Line 6 */ 26. return b; /* Line 7 */ 27. } 28. public static void main (String args[]) 29. { 30. Test t = new Test(); /* Line 11 */ 31. Bar newBar = t.doBar(); /* Line 12 */ 32. System.out.println("newBar"); 33. newBar = new Bar(); /* Line 14 */ 34. System.out.println("finishing"); /* Line 15 */ 35. } 36. } At what point is the Bar object, created on line 6, eligible for garbage collection? a. after line 12 b. after line 14 c. after line 7, when doBar() completes d. after line 15, when main() completes 20. 21. class HappyGarbage01 22. { 23. public static void main(String args[]) 24. { 25. HappyGarbage01 h = new HappyGarbage01(); 26. h.methodA(); /* Line 6 */ 27. } 28. Object methodA() 29. { 30. Object obj1 = new Object(); 31. Object [] obj2 = new Object[1]; 32. obj2[0] = obj1; 33. obj1 = null; 34. return obj2[0]; 35. } 36. } Where will be the most chance of the garbage collector being invoked?
  • 8. a. After line 9 b. After line 10 c. After line 11 d. Garbage collector never invoked in methodA() 21. Which statement is true? a. Programs will not run out of memory b. Objects that will never again be used are eligible for garbage collection. c. Objects that are referred to by other objects will never be garbage collected. d. Objects that can be reached from a live thread will never be garbage collected. 22. Which statement is true? a. All objects that are eligible for garbage collection will be garbage collected by the collector. b. Objects with at least one reference will never be garbage collected. c. Objects from a class with the finalize() method overridden will never be garbage collected. d. Objects instantiated within anonymous inner classes are placed in the garbage collectible heap. 23. Which of the following is not an approach for garbage collection? a. Copying b. Tracing c. Reference Counting d. The plane algorithm 24. What does reference counting do? a. Count for each object. b. Count increases as number of reference increases. c. Eligible for GC when count equals zero. d. All of above 25. Tracing is also known as a. Mark algorithm b. Mark and Sweep algorithm
  • 9. c. Sweeping algorithm d. None of them 26. Which objects are not reachable in tracing? a. Marked ones b. Unmarked ones c. None of above 27. Which approach works on the basis of lifetimes of objects. a. Generational Collectors b. Tracing c. Reference counting d. Copying 28. Which of the following statement is incorrect? a. Finalize is very different from destructors. b. Finalize is same as destructors. c. Finalizable objects may refer to other (non-finalizable) objects, prolonging their lifetime unnecessarily. d. None of them 29. What is resurrection? a. An object requiring finalization dies, lives, and then dies again, this phenomenon is called resurrection. b. An object requiring finalization lives, and then dies again, this phenomenon is called resurrection. 30. Which objects are collected before others in generational collectors? a. Short lived objects b. Long lived objects c. Any object can be collected at any time d. None of above Video Link: https://www.youtube.com/watch?v=7AcptSGscKY&feature=youtu.be