Java Tutorial

Java Control Statements

Object Oriented Programming

Java Built-in Classes

Java File Handling

Java Error & Exceptions

Java Multithreading

Java Synchronization

Java Networking

Java Collections

Java List Interface

Java Queue Interface

Java Map Interface

Java Set Interface

Java Data Structures

Java Collections Algorithms

Advanced Java

Java Miscellaneous

Java APIs & Frameworks

Java Useful Resources

Java 8 Online Quiz



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 predicate of one double-valued argument?

A - DoubleFunction<R>

B - DoublePredicate

C - DoubleSupplier

D - DoubleToIntFunction

Answer : B

Explanation

DoublePredicate functional interface represents a predicate (Boolean-valued function) of one double-valued argument.

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

A - IntConsumer

B - IntFunction<R>

C - IntPredicate

D - IntSupplier

Answer : B

Explanation

IntFunction<R> functional interface represents a function that accepts an int-valued argument and produces a 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 function that produces a long-valued result?

A - ToLongBiFunction<T,U>

B - ToLongFunction<T>

C - UnaryOperator<T>

D - ToIntFunction<T>

Answer : B

Explanation

ToLongFunction<T> functional interface represents a function that produces a long-valued result.

Answer : B

Explanation

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

Answer : C

Explanation

Both of the above options are correct.

Q 8 - Which of the following method of Base64 class returns a Base64.Decoder that decodes using the URL and Filename safe type base64 encoding scheme?

A - getUrlDecoder()

B - getUrlEncoder()

C - getMimeDecoder()

D - getMimeEncoder

Answer : A

Explanation

getUrlDecoder() method of Base64 class returns a Base64.Decoder that decodes using the URL and Filename safe type base64 encoding scheme.

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 - 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