Advanced
Java
Q89 / 100
What is the difference between WeakReference and SoftReference?
Correct! Well done.
Incorrect.
The correct answer is B) WeakReference is cleared at the next GC; SoftReference is cleared only when memory is low
B
Correct Answer
WeakReference is cleared at the next GC; SoftReference is cleared only when memory is low
Explanation
WeakReference objects are eligible for collection as soon as no strong references exist. SoftReference objects are kept alive until the JVM needs memory, making them suitable for caches.
Progress
89/100