Suppose you have the following code:
public class ReferenceTypesDemo {
public static void main(String[] args) {
Integer num = 1995;
SoftReference<Integer> softReference = new SoftReference<>(num);
WeakReference<Integer> weakReference = new WeakReference<>(num);
num = null;
}
}
Will the object created for the num variable survive garbage collections until the application is close to running out of memory?