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 2 - Which of the following functional interface represents a function that accepts a double-valued argument and produces an int-valued result?

A - DoubleFunction<R>

B - DoublePredicate

C - DoubleSupplier

D - DoubleToIntFunction

Answer : D

Explanation

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

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 an operation on a single int-valued operand that produces an int-valued result?

A - IntToDoubleFunction

B - IntToLongFunction

C - IntUnaryOperator

D - LongBinaryOperator

Answer : C

Explanation

IntUnaryOperator functional interface represents an operation on a single int-valued operand that produces an int-valued result.

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

A - ObjIntConsumer<T>

B - ObjLongConsumer<T>

C - Predicate<T>

D - Supplier<T>

Answer : A

Explanation

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

Answer : C

Explanation

Both of the above options are correct.

Q 8 - Which of the following method of Base64 class returns a Base64.Encoder that encodes using the Basic type base64 encoding scheme?

A - getDecoder()

B - getEncoder()

C - getMimeDecoder()

D - getMimeEncoder

Answer : B

Explanation

getEncoder() method of Base64 class returns a Base64.Encoder that encodes using the Basic type base64 encoding scheme.

Q 9 - A stream provides a set of elements of specific type in a sequential manner.

A - true

B - false

Answer : A

Explanation

A stream provides a set of elements of specific type in a sequential manner. A stream gets/computes elements on demand. It never stores the elements.

Q 10 - The new date-time API in java 8 is immutable and does not have setter methods.

A - true

B - false

Answer : A

Explanation

The new date-time API in java 8 is immutable and does not have setter methods.

java8_questions_answers.htm
Advertisements