Get the sum square of variables

Report a typo

Print the sum square for num1 and num2 using a get() method to get their values before assigning null to both of them.

Sample Input 1:

3
4

Sample Output 1:

49
Write a program in Java 17
import java.util.Scanner;
import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference;

public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Integer num1 = scanner.nextInt();
Integer num2 = scanner.nextInt();
// Initialize an instance of SoftReference by passing num1 to the constructor
SoftReference<Integer> softReference = ...
// Initialize an instance of WeakReference by passing num2 to the constructor
WeakReference<Integer> weakReference = ...

num1 = null;
num2 = null;

System.out.println((int) Math.pow(/* print the sum here */, 2));
}
}
___

Create a free account to access the full topic