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 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 a function that accepts a double-valued argument and produces a long-valued result?

A - DoubleToLongFunction

B - DoubleUnaryOperator

C - Function<T,R>

D - IntBinaryOperator

Answer : A

Explanation

DoubleToLongFunction functional interface represents a function that accepts a double-valued argument and produces a long-valued result.

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

A - LongConsumer

B - LongFunction<R>

C - LongPredicate

D - LongSupplier

Answer : B

Explanation

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

Q 5 - Which of the following functional interface represents a supplier of results?

A - ObjIntConsumer<T>

B - ObjLongConsumer<T>

C - Predicate<T>

D - Supplier<T>

Answer : D

Explanation

Supplier<T> functional interface represents a supplier of results.

Answer : A

Explanation

Using super keyword along with interface name.

Answer : C

Explanation

Both of the above options are correct.

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

A - (int a, int b) -> { return a + b;};

B - (a, b) -> {return a + b;};

C - Both of the above.

D - None of the above.

Answer : C

Explanation

Both of the above options are correct.

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 - java.util.Date is not thread safe, thus developers have to deal with concurrency issue while using date.

A - true

B - false

Answer : A

Explanation

java.util.Date is not thread safe, thus developers have to deal with concurrency issue while using date.


java8_questions_answers.htm

Advertisements