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 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 that accepts a single int-valued argument and returns no result?

A - IntConsumer

B - IntFunction<R>

C - IntPredicate

D - IntSupplier

Answer : A

Explanation

IntConsumer functional interface represents an operation that accepts a single int-valued argument and returns no result.

Q 4 - Which of the following functional interface represents an operation upon two long-valued operands and produces a long-valued result?

A - IntToDoubleFunction

B - IntToLongFunction

C - IntUnaryOperator

D - LongBinaryOperator

Answer : D

Explanation

LongBinaryOperator functional interface represents an operation upon two long-valued operands and produces a long-valued result.

Q 5 - Which of the following functional interface represents an operation that accepts an object-valued and a long-valued argument, and returns no result?

A - ObjIntConsumer<T>

B - ObjLongConsumer<T>

C - Predicate<T>

D - Supplier<T>

Answer : B

Explanation

ObjLongConsumer<T> functional interface represents an operation that accepts an object-valued and a long-valued argument, and returns no result.

Answer : B

Explanation

Using name of the interface.

Q 7 - Can you execute javascript code from java 8 code base?

A - true

B - false

Answer : A

Explanation

Yes! Using ScriptEngineManager, JavaScript code can be called and interpreted in Java.

Q 8 - Lambda expressions are used primarily to define inline implementation of a functional interface.

A - true

B - false

Answer : A

Explanation

Lambda expressions are used primarily to define inline implementation of a functional interface.

Q 9 - A stream provides a set of elements of specific type in a sequential manner.

A - true

B - false

Answer : A

Explanation

A stream provides a set of elements of specific type in a sequential manner. A stream gets/computes elements on demand. It never stores the elements.

Q 10 - Optional.of method throws NullPointerException if passed parameter is null.

A - true

B - false

Answer : A

Explanation

Optional.of method throws NullPointerException if passed parameter is null.

java8_questions_answers.htm
Advertisements