Java 8 Online Quiz


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

Q 2 - Which of the following functional interface represents an operation that accepts a single double-valued argument and returns no result?

A - BooleanSupplier

B - Consumer<T>

C - DoubleBinaryOperator

D - DoubleConsumer

Answer : D

Explanation

DoubleConsumer functional interface represents an operation that accepts a single double-valued argument and returns no result.

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 an operation that accepts an object-valued and a double-valued argument, and returns no result?

A - LongToDoubleFunction

B - LongToIntFunction

C - LongUnaryOperator

D - ObjDoubleConsumer<T>

Answer : D

Explanation

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

Q 5 - Which of the following functional interface represents a predicate (Boolean-valued function) of one argument?

A - ObjIntConsumer<T>

B - ObjLongConsumer<T>

C - Predicate<T>

D - Supplier<T>

Answer : C

Explanation

Predicate<T> functional interface represents a predicate (Boolean-valued function) of one argument.

Answer : C

Explanation

The 'filter' method is used to eliminate elements based on a criteria.

Q 8 - Lambda expressions are used primarily to define inline implementation of a functional interface.

A - true

B - false

Answer : A

Explanation

Lambda expressions are used primarily to define inline implementation of a functional interface.

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.isPresent method checks the value is present or not.

A - false

B - true

Answer : B

Explanation

Optional.isPresent method checks the value is present or not.

java8_questions_answers.htm
Advertisements