Worksheets2ND QTR-QUIZ 5-Java Garbage Collection-12-6-2022
Total questions: 20
Worksheet time: 14mins
Means unreferenced objects.
Garbage
Garbage Collection
Unused objects
Java Garbage Collection
A process of reclaiming the runtime unused memory automatically.
Garbage Collection
Garbage
Java Virtual Machine
Unreferenced objects
In other words, it is a way to destroy the unused objects.
Garbage
Java virtual machine
Garbage Collection
Unreferenced objects
The process by which Java programs perform automatic memory management.
Dangling pointer
Java Virtual Machine
Garbage
Java garbage collection
Occur when a piece of memory is freed while there are still pointers to it, and one of those pointers is dereferenced.
Dangling free bugs
Double free bugs
Dangling pointer bugs
Double pointer bugs
Occur when the program tries to free a region of memory that has already been freed and perhaps already been allocated again.
Dangling pointer bugs
Double free bugs
Double pointer bugs
Dangling free bugs
Said to have occurred when unreachable objects in the young generation heap memory are removed.
A minor or incremental garbage collection
A major or full garbage collection
A minor or full garbage collection
A major or incremental garbage collection
Said to have occurred when the objects that survived the minor garbage collection and copied into the old generation
or permanent generation heap memory are removed.
A major or incremental garbage collection
A major or full garbage collection
A minor or incremental garbage collection
A minor or full garbage collection
Can impact the performance of Java application in unpredictable ways.
Excessive garbage collection
CPU load
JVM
Garbage collection
Can occur due to a memory leak in the Java application.
Garbage collection process
Excessive garbage collection activity
Garbage collection
Java Virtual Machine
Advantage of Garbage Collection. (Choose 2 answers)
It makes java memory efficient because garbage collector removes the unreferenced objects from heap memory.
Monitoring Garbage Collection
Insufficient memory allocation to the JVM can also result in increased garbage collection activity.
It is automatically done by the garbage collector (a part of JVM) so we don’t need to make extra efforts.
How can an object be unreferenced? (Choose 2 answers)
By assigning a null to another
By assigning a reference to another
By anonymous reference etc.
By nulling the reference
Employee e1 = new Employee();
Employee e2 = new Employee();
e1 = e2;
The above syntax java code is an example of what unreferenced?
By assigning a reference to another
By nulling the reference
By anonymous object etc.
By assigning a null to another
Invoked each time before the object is garbage collected.
gc() method
finalize() method
Object class
Unreferenced()
This method can be used to perform cleanup processing.
finalize() method
gc() method
Object class()
nulling()
protected void finalize()
{
// codes
}
The above syntax code is an example of what method?
class() method
finalize() method
gc() method
object() method
Used to invoke the garbage collector to perform cleanup processing.
gc() method
finalize() method
object() method
class() method
Found in System and Runtime classes.
class() method
gc() method
finalize() method
object() method
Certain kinds of memory leaks, in which a program fails to free memory occupied by objects that have become unreachable, which can lead to memory exhaustion.
TRUE
FALSE
Garbage collection frees the programmer from automatic dealing with memory allocation.
TRUE
FALSE
