A method reference keeps the old object
Predict the outputHardJava only
import java.util.function.*;
public class Main {
public static void main(String[] args) {
String name = "first";
Supplier<String> ref = name::toUpperCase;
name = "second";
System.out.println(ref.get());
System.out.println(name);
}
}
This question is part of Pro+
Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.