class Welcome { public static void main(String[] args) { Deque deque = new ArrayDeque<>(); deque.addAll(Arrays.asList(1, 2, 3, 4, 5)); System.out.println("First removed element is = " + deque.remove()); } } 1. Code will through compile time exception.
2. Code will compile but through Runtime exception "IllegalStateException"
3. Code will compile and run perfectly and print First removed element is = 5
4. Code will compile and run perfectly and print First removed element is = 1
4. Code will not compile because there is an ambiguity in code call method
Correct Answer : Get Lastest Questions and Answer : Explanation: When code check compile time there are two methods defined call(S s) and call(T t). And no datatype is defined for them. Hence, compile will see signature of the methods as call (String) and call(S extends CharSequence) and they would be considered as overloaded method and not overridden method. Having the same signature for overloaded method it will through compile time exception considering the ambiguity.
Question : Select the correct functional interface from below.
A. java.util.stream.Stream B. java.util.function.Consumer C. java.util.function.Supplier D. java.util.function.Predicate E. java.util.function.Function
Correct Answer : Get Lastest Questions and Answer : Explanation: The interface java.util.stream.Stream is not a functional interface-it has numerous abstract methods. The other four options are functional interfaces. The functional interface java.util.function.Consumer has an abstract method with the signature void accept(T t); The functional interface java.util.function.Supplier has an abstract method with the signature T get(); The functional interface java.util.function.Predicate has an abstract method with the signature boolean test(T t); The functional interface java.util.function.Function has an abstract method with the signature R apply(T t);