Question

1.
2.
3.
4.
Answer (Detailed Solution Below)

Option 4 : It only suggests garbage collection; the JVM may ignore it / यह केवल garbage collection का सुझाव देता है; JVM इसे नज़रअंदाज़ कर सकता है

Advertisement

Detailed Solution

सही उत्तर It only suggests garbage collection; the JVM may ignore it / यह केवल garbage collection का सुझाव देता है; JVM इसे नज़रअंदाज़ कर सकता है है।

Key Points
Helpful?
PrepSnapprepsnap.in • Part -A

Question:

Which statement about Java's `System.gc()` is TRUE? / Java के `System.gc()` के बारे में कौन-सा कथन सत्य है?

1.
It immediately destroys all unreachable objects / यह सभी unreachable ऑब्जेक्ट तुरंत नष्ट कर देता है
2.
It compacts the heap synchronously before returning / यह लौटने से पहले heap को synchronously compact करता है
3.
It throws an exception if the heap is full / heap भरने पर यह अपवाद फेंकता है
4.
It only suggests garbage collection; the JVM may ignore it / यह केवल garbage collection का सुझाव देता है; JVM इसे नज़रअंदाज़ कर सकता है

Correct Answer: It only suggests garbage collection; the JVM may ignore it / यह केवल garbage collection का सुझाव देता है; JVM इसे नज़रअंदाज़ कर सकता है

`System.gc()` is a hint to the JVM, which is free to ignore it — there is no guarantee that any collection runs, let alone synchronously. The trap is treating it as a deterministic "collect now" command. / `System.gc()` JVM को एक सुझाव है, जिसे वह नज़रअंदाज़ कर सकता है — इस बात की कोई गारंटी नहीं कि कोई collection चलेगा, saath ही synchronous तो बिल्कुल नहीं। जाल इसे नियतात्मक "अभी collect करो" कमांड समझना है।

Downloaded from PrepSnap (prepsnap.in)