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 an operation upon two operands of the same type, producing a result of the same type as the operands?

A - BiConsumer<T,U>

B - BiFunction<T,U,R>

C - BinaryOperator<T>

D - BiPredicate<T,U>

Answer : C

Explanation

BinaryOperator<T> functional interface represents an operation upon two operands of the same type, producing a result of the same type as the operands.

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 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 double-valued result?

A - ToDoubleBiFunction<T,U>

B - ToDoubleFunction<T>

C - ToIntBiFunction<T,U>

D - ToIntFunction<T>

Answer : B

Explanation

ToDoubleFunction<T> functional interface represents a function that produces a double-valued result.

Answer : B

Explanation

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

Q 7 - Which of the following class implements a decoder for decoding byte data using the Base64 encoding scheme in Java8?

A - Base64.Decoder

B - Base64.Encoder

C - Base64Decoder

D - Base64Encoder

Answer : A

Explanation

static class Base64.Decoder - This class implements a decoder for decoding byte data using the Base64 encoding scheme as specified in RFC 4648 and RFC 2045.

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

A - getDecoder()

B - getEncoder()

C - getMimeDecoder()

D - getMimeEncoder

Answer : A

Explanation

getDecoder() method of Base64 class returns a Base64.Decoder that decodes using the Basic 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.orElse method returns the value if present otherwise returns the default value passed.

A - false

B - true

Answer : B

Explanation

Optional.orElse method returns the value if present otherwise returns the default value passed.

java8_questions_answers.htm
Advertisements