Correct Answer : Get Lastest Questions and Answer : Explanation: As we are using AutoClosable resource with try block. As soon as we are done with the getting connection it will close the connection. Which causes executeUpdate statement as NullPointerException. Because, newConnection object is closed.
Question : You have been given below code, what will be printed when executed?
A container object which may or may not contain a non-null value. If a value is present, isPresent() will return true and get() will return the value. Additional methods that depend on the presence or absence of a contained value are provided, such as orElse() (return a default value if value not present) and ifPresent() (execute a block of code if the value is present). This is a value-based class; use of identity-sensitive operations (including reference equality (==), identity hash code, or synchronization) on instances of Optional may have unpredictable results and should be avoided. boolean java.util.Optional.isPresent()
Return true if there is a value present, otherwise false. Returns: true if there is a value present, otherwise false
Question : You have been given below source code. Select the correct behavior of it
package com.hadoopexam;
import java.util.function.Predicate;
public class Welcome { public static void main(String[] args) { Predicate predicate = ((Predicate) (arg -> arg == null)).negate(); System.out.println(predicate.test(null)); } }
5. Program will through NullPointerException at run time.
Correct Answer : Get Lastest Questions and Answer : Explanation: Given predicate expression is valid. Predicate predicate = ((Predicate) (arg -> arg == null)).negate(); As we are negating the expression result. Hence, if expression is producing true then it became false or from false to true.