Java 8 Online Quiz


Advertisements


Following quiz provides Multiple Choice Questions (MCQs) related to Java 8. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.

Questions and Answers

Answer : A

Explanation

System.out::println method is a static method reference to println method of out object of System class.

Q 2 - Which of the following functional interface represents a predicate (Boolean-valued function) of two arguments?

A - BiConsumer<T,U>

B - BiFunction<T,U,R>

C - BinaryOperator<T>

D - BiPredicate<T,U>

Answer : D

Explanation

BiPredicate<T,U> functional interface represents a predicate (Boolean-valued function) of two arguments.

Q 3 - Which of the following functional interface represents a function that accepts an int-valued argument and produces a double-valued result?

A - IntToDoubleFunction

B - IntToLongFunction

C - IntUnaryOperator

D - LongBinaryOperator

Answer : A

Explanation

IntPredicate functional interface represents a function that accepts an int-valued argument and produces a double-valued result.

Q 4 - Which of the following functional interface represents a function that accepts a long-valued argument and produces an int-valued result?

A - LongToDoubleFunction

B - LongToIntFunction

C - LongUnaryOperator

D - ObjDoubleConsumer<T>

Answer : B

Explanation

LongToIntFunction functional interface represents a function that accepts a long-valued argument and produces an int-valued result.

Q 5 - Which of the following functional interface represents an operation that accepts an object-valued and a long-valued argument, and returns no result?

A - ObjIntConsumer<T>

B - ObjLongConsumer<T>

C - Predicate<T>

D - Supplier<T>

Answer : B

Explanation

ObjLongConsumer<T> functional interface represents an operation that accepts an object-valued and a long-valued argument, and returns no result.

Answer : A

Explanation

Stream has provided a new method 'forEach' to iterate each element of the stream.

Answer : D

Explanation

The 'sorted' method is used to sort the stream.

Q 8 - Using lambda expression, you can refer to final variable or effectively final variable (which is assigned only once).

A - false

B - true

Answer : B

Explanation

Using lambda expression, you can refer to final variable or effectively final variable (which is assigned only once).

Q 9 - Functional interfaces have a single functionality to exhibit.

A - false

B - true

Answer : B

Explanation

Functional interfaces have a single functionality to exhibit.

Q 10 - Optional.orElse method returns the value if present otherwise returns the default value passed.

A - false

B - true

Answer : B

Explanation

Optional.orElse method returns the value if present otherwise returns the default value passed.


java8_questions_answers.htm

Advertisements