|
Answer» Choose the correct option based on this code SEGMENT in JAVA8 Innards import java.util.Optional; PUBLIC class App { public static void main(String[] args) { String[] str = new String[10]; str[5] = null;; str[4] = "JAVA OPTIONAL CLASS EXAMPLE"; Optional< String> checkNull = Optional.ofNullable(str[5]); if(checkNull.isPresent()){ // It Checks, value is present or not String lowercaseString = str[5].toLowerCase(); System.out.print(lowercaseString); }else System.out.println("String value is not present"); } } Choose the correct output. (1)String value is not present (2)Runtime error: Null POINTER Exception (3)Java optional example (4)Compilation error
Answer:-(1)String value is not present
|