0% found this document useful (0 votes)
35 views

Java 8 Mock Test

Java 8 Mock Test

Uploaded by

DAVID SEDZRO
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Java 8 Mock Test

Java 8 Mock Test

Uploaded by

DAVID SEDZRO
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

6/8/24, 3:55 PM Java 8 Mock Test

Java 8 Mock Test


This section presents you various set of Mock Tests related to Java 8. You can
download these sample mock tests at your local machine and solve offline at your
convenience. Every mock test is supplied with a mock test key to let you verify the
final score and grade yourself.

Mock Test I Mock Test II Mock Test III

Mock Test IV

Java 8 Mock Test I

Q 1 - Which of the following is correct about Java8?

A - Lambda expression - Adds functional processing capability to Java.

B - Method references - Referencing functions by their names instead of


invoking them directly. Using functions as parameter.

C - Default method - Interface to have default method implementation.

D - All of the above.

Answer : D

Explanation

https://www.tutorialspoint.com/java/java8_mock_test.htm 1/15
6/8/24, 3:55 PM Java 8 Mock Test

All of the above options are correct.

Q 2 - Which of the following is correct about Java8?

A - New compiler tools and utilities are added like 'jdeps' to figure out
dependencies.

B - New stream API to facilitate pipeline processing is added.

C - New Improved date time API added.

D - All of the above.

Answer : D

Explanation
All of the above options are correct.

Q 3 - Which of the following is correct about Java 8 lambda expression?

A - Optional type declaration - No need to declare the type of a parameter.


The compiler can inference the same from the value of the parameter.

B - Optional parenthesis around parameter - No need to declare a single


parameter in parenthesis. For multiple parameters, parentheses are
required.

C - Both of the above.

D - None of the above.

Answer : C

Explanation

https://www.tutorialspoint.com/java/java8_mock_test.htm 2/15
6/8/24, 3:55 PM Java 8 Mock Test

Both of the above options are correct.

Q 4 - Which of the following is correct about Java 8 lambda expression?

A - Optional curly braces - No need to use curly braces in expression body if


the body contains a single statement.

B - Optional return keyword - The compiler automatically returns the value if


the body has a single expression to return the value.

C - Both of the above.

D - None of the above.

Answer : C

Explanation
Both of the above options are correct.

Q 5 - Which of the following is correct about Java 8 lambda expression?

A - Lambda expressions are used primarily to define inline implementation of


a functional interface.

B - Lambda expression eliminates the need of anonymous class and gives a


very simple yet powerful functional programming capability to Java.

C - Both of the above.

D - None of the above.

Answer : C

Explanation

https://www.tutorialspoint.com/java/java8_mock_test.htm 3/15
6/8/24, 3:55 PM Java 8 Mock Test

Both of the above options are correct.

Q 6 - Which of the following is correct about Java 8 lambda expression?

A - Using lambda expression, you can refer to final variable or effectively


final variable (which is assigned only once).

B - Lambda expression throws a compilation error, if a variable is assigned a


value the second time.

C - Both of the above.

D - None of the above.

Answer : C

Explanation
Both of the above options are correct.

Q 7 - Which of the following is correct about Java 8 method references?

A - Method references help to point to methods by their names.

B - A method reference is described using :: (double colon) symbol.

C - Both of the above.

D - None of the above.

Answer : C

Explanation
Both of the above options are correct.

https://www.tutorialspoint.com/java/java8_mock_test.htm 4/15
6/8/24, 3:55 PM Java 8 Mock Test

Q 8 - Which of the following is correct about System.out::println


expression?

A - System.out::println method is a static method reference to println


method of out object of System class.

B - System.out::println method is a instance method reference to println


method of out object of System class.

C - Both of the above.

D - None of the above.

Answer : A

Explanation
System.out::println method is a static method reference to println method of
out object of System class.

Q 9 - 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.

https://www.tutorialspoint.com/java/java8_mock_test.htm 5/15
6/8/24, 3:55 PM Java 8 Mock Test

Q 10 - Which of the following functional interface represents an


operation that accepts two input arguments, and returns a result?

A - BiConsumer<T,U>

B - BiFunction<T,U,R>

C - BinaryOperator<T>

D - BiPredicate<T,U>

Answer : B

Explanation
BiFunction<T,U> functional interface represents an operation that accepts
two input arguments, and returns a result.

Q 11 - 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.

https://www.tutorialspoint.com/java/java8_mock_test.htm 6/15
6/8/24, 3:55 PM Java 8 Mock Test

Q 12 - Which of the following functional interface represents a predicate


(Boolean-valued function) of two arguments?

A - BiConsumer<T,U>

B - BiFunction<T,U,R>

C - BinaryOperator<T>

D - BiPredicate<T,U>

Answer : D

Explanation
BiPredicate<T,U> functional interface represents a predicate (Boolean-
valued function) of two arguments.

Q 13 - Which of the following functional interface represents a supplier


of Boolean-valued results?

A - BooleanSupplier

B - Consumer<T>

C - DoubleBinaryOperator

D - DoubleConsumer

Answer : A

Explanation
BooleanSupplier functional interface represents a supplier of Boolean-valued
results.

https://www.tutorialspoint.com/java/java8_mock_test.htm 7/15
6/8/24, 3:55 PM Java 8 Mock Test

Q 14 - 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 15 - Which of the following functional interface represents an


operation upon two double-valued operands and producing a double-
valued result?

A - BooleanSupplier

B - Consumer<T>

C - DoubleBinaryOperator

D - DoubleConsumer

Answer : C

Explanation
DoubleBinaryOperator functional interface represents an operation upon two
double-valued operands and producing a double-valued result.

https://www.tutorialspoint.com/java/java8_mock_test.htm 8/15
6/8/24, 3:55 PM Java 8 Mock Test

Q 16 - Which of the following functional interface represents an


operation that accepts a single double-valued argument and returns no
result?

A - BooleanSupplier

B - Consumer<T>

C - DoubleBinaryOperator

D - DoubleConsumer

Answer : D

Explanation
DoubleConsumer functional interface represents an operation that accepts a
single double-valued argument and returns no result.

Q 17 - 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.

https://www.tutorialspoint.com/java/java8_mock_test.htm 9/15
6/8/24, 3:55 PM Java 8 Mock Test

Q 18 - 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 19 - Which of the following functional interface represents a supplier


of double-valued results?

A - DoubleFunction<R>

B - DoublePredicate

C - DoubleSupplier

D - DoubleToIntFunction

Answer : C

Explanation
DoubleSupplier functional interface represents a supplier of double-valued
results.

https://www.tutorialspoint.com/java/java8_mock_test.htm 10/15
6/8/24, 3:55 PM Java 8 Mock Test

Q 20 - Which of the following functional interface represents a function


that accepts a double-valued argument and produces an int-valued
result?

A - DoubleFunction<R>

B - DoublePredicate

C - DoubleSupplier

D - DoubleToIntFunction

Answer : D

Explanation
DoubleToIntFunction functional interface represents a function that accepts a
double-valued argument and produces an int-valued result.

Q 21 - Which of the following functional interface represents a function


that accepts a double-valued argument and produces a long-valued
result?

A - DoubleToLongFunction

B - DoubleUnaryOperator

C - Function<T,R>

D - IntBinaryOperator

Answer : A

Explanation
DoubleToLongFunction functional interface represents a function that accepts
a double-valued argument and produces a long-valued result.

https://www.tutorialspoint.com/java/java8_mock_test.htm 11/15
6/8/24, 3:55 PM Java 8 Mock Test

Q 22 - Which of the following functional interface represents an


operation on a single double-valued operand that produces a double-
valued result?

A - DoubleToLongFunction

B - DoubleUnaryOperator

C - Function<T,R>

D - IntBinaryOperator

Answer : B

Explanation
DoubleUnaryOperator functional interface represents an operation on a
single double-valued operand that produces a double-valued result.

Q 23 - Which of the following functional interface represents a function


that accepts one argument and produces a result?

A - DoubleToLongFunction

B - DoubleUnaryOperator

C - Function<T,R>

D - IntBinaryOperator

Answer : C

Explanation
Function<T,R> functional interface represents a function that accepts one
argument and produces a result.

https://www.tutorialspoint.com/java/java8_mock_test.htm 12/15
6/8/24, 3:55 PM Java 8 Mock Test

Q 24 - 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 25 - 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.

https://www.tutorialspoint.com/java/java8_mock_test.htm 13/15
6/8/24, 3:55 PM Java 8 Mock Test

Question Number Answer Key

1 D

2 D

3 C

4 C

5 C

6 C

7 C

8 A

9 A

10 B

11 C

12 D

13 A

14 B

15 C

16 D

17 A

18 B

19 C

20 D

21 A

22 B

23 C

24 D

https://www.tutorialspoint.com/java/java8_mock_test.htm 14/15
6/8/24, 3:55 PM Java 8 Mock Test

25 A

Download

https://www.tutorialspoint.com/java/java8_mock_test.htm 15/15

You might also like