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.
Q 1 - Which of the following functional interface represents an operation that accepts two input arguments, and returns no result?
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?
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?
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?
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?
Answer : D
Explanation
Supplier<T> functional interface represents a supplier of results.
Q 6 - How will you call a default method of an interface in a class?
A - Using super keyword along with interface name.
Answer : A
Explanation
Using super keyword along with interface name.
Q 7 - Which of the following is correct about Optional in java8?
A - Optional is a container object which is used to contain not-null objects.
B - Optional object is used to represent null with absent value.
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;};
Answer : C
Explanation
Both of the above options are correct.
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.
Answer : A
Explanation
java.util.Date is not thread safe, thus developers have to deal with concurrency issue while using date.