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 a result?

A - BiConsumer<T,U>

B - BiFunction<T,U,R>

C - BinaryOperator<T>

D - BiPredicate<T,U>

Answer : B

Explanation

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

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

A - DoubleFunction<R>

B - DoublePredicate

C - DoubleSupplier

D - DoubleToIntFunction

Answer : A

Explanation

DoubleFunction<R> functional interface represents a function that accepts a double-valued argument and produces a result.

Q 3 - Which of the following functional interface represents an operation on a single double-valued operand that produces a double-valued result?

A - DoubleToLongFunction

B - DoubleUnaryOperator

C - Function<T,R>

D - IntBinaryOperator

Answer : B

Explanation

DoubleUnaryOperator functional interface represents an operation on a single double-valued operand that 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 a function that accepts two arguments and produces a long-valued result?

A - ToLongBiFunction<T,U>

B - ToLongFunction<T>

C - UnaryOperator<T>

D - ToIntFunction<T>

Answer : A

Explanation

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

Answer : A

Explanation

Using super keyword along with interface name.

Q 7 - Which of the following API represents a simplified date-time API with no complexity of timezone handling in java8?

A - Local

B - Zoned

C - Both of the above.

D - None of the above.

Answer : A

Explanation

Local − Simplified date-time API with no complexity of timezone handling.

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 - Optional is a container object which is used to contain not-null objects.

A - true

B - false

Answer : A

Explanation

Optional is a container object which is used to contain not-null objects.

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
E-Books Store