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

Q 1 - Which of the following functional interface represents an operation that accepts two input arguments, and returns no result?

A - BiConsumer<T,U>

B - BiFunction<T,U,R>

C - BinaryOperator<T>

D - BiPredicate<T,U>

Answer : A

Explanation

BiConsumer<T,U> functional interface represents an operation that accepts two input arguments, and returns no result.

Q 2 - Which of the following functional interface represents a supplier of double-valued results?

A - DoubleFunction<R>

B - DoublePredicate

C - DoubleSupplier

D - DoubleToIntFunction

Answer : C

Explanation

DoubleSupplier functional interface represents a supplier of double-valued results.

Q 3 - Which of the following functional interface represents a function that accepts one argument and produces a result?

A - DoubleToLongFunction

B - DoubleUnaryOperator

C - Function<T,R>

D - IntBinaryOperator

Answer : C

Explanation

Function<T,R> functional interface represents a function that accepts one argument and produces a result.

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

A - LongConsumer

B - LongFunction<R>

C - LongPredicate

D - LongSupplier

Answer : C

Explanation

LongPredicate functional interface represents a predicate (Boolean-valued function) of one long-valued argument.

Q 5 - Which of the following functional interface represents a function that accepts two arguments and produces an int-valued result?

A - ToDoubleBiFunction<T,U>

B - ToDoubleFunction<T>

C - ToIntBiFunction<T,U>

D - ToIntFunction<T>

Answer : C

Explanation

ToIntBiFunction<T,U> functional interface represents a function that accepts two arguments and produces an int-valued result.

Answer : B

Explanation

Using name of the interface.

Q 7 - Which of the following API represents a specialized date-time API to deal with various timezones in java8?

A - Local

B - Zoned

C - Both of the above.

D - None of the above.

Answer : B

Explanation

Zoned − Specialized date-time API to deal with various timezones.

Q 8 - Which of the following is the correct lambda expression which add two numbers and return their sum?

A - (int a, int b) -> a + b;

B - (a, b) -> a + b

C - Both of the above.

D - None of the above.

Answer : C

Explanation

Both of the above options are correct.

Q 9 - Stream takes Collections, Arrays, or I/O resources as input source.

A - true

B - false

Answer : A

Explanation

Stream takes Collections, Arrays, or I/O resources as input source.

Q 10 - Optional.get method gets the value, value should be present.

A - false

B - true

Answer : B

Explanation

Optional.get method gets the value, value should be present.


java8_questions_answers.htm

Advertisements