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 an operation that accepts a single input argument and returns no result?

A - BooleanSupplier

B - Consumer<T>

C - DoubleBinaryOperator

D - DoubleConsumer

Answer : B

Explanation

Consumer<T> functional interface represents an operation that accepts a single input argument and returns no result.

Q 3 - Which of the following functional interface represents an operation upon two int-valued operands and produces an int-valued result?

A - DoubleToLongFunction

B - DoubleUnaryOperator

C - Function<T,R>

D - IntBinaryOperator

Answer : D

Explanation

FunctionIntBinaryOperator functional interface represents an operation upon two int-valued operands and produces an int-valued result.

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

A - LongToDoubleFunction

B - LongToIntFunction

C - LongUnaryOperator

D - ObjDoubleConsumer<T>

Answer : C

Explanation

LongUnaryOperator functional interface represents an operation on a single long-valued operand that produces a long-valued 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 : B

Explanation

The 'map' method is used to map each element to its corresponding result.

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) -> { 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 - Most of the stream operations return stream itself so that their result can be pipelined.

A - false

B - true

Answer : B

Explanation

Most of the stream operations return stream itself so that their result can be pipelined.

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