Question 1
Which of the following is true about lambda expressions in Java?
Lambda expressions can be used to define a method.
Lambda expressions are instances of functional interfaces.
Lambda expressions cannot access instance variables.
Lambda expressions are not supported in Java 8.
Question 2
What is the correct syntax for a lambda expression in Java?
(parameter) -> {body}
parameter => body
parameter -> {body}
{parameter} -> body
Question 3
What will the following lambda expression do? x -> x * 2
Doubles the value of x
Prints the value of x
Doubles the value of x and prints it
Nothing
Question 4
What does the following code snippet represent? () -> { return 42; }
A method reference
A functional interface
A lambda expression
An anonymous class
Question 5
Which of the following functional interfaces can be used with lambda expressions in Java?
Runnable
Callable
Comparator
All of the above
Question 6
Which of the following lambda expressions is correct for a function that takes two integers and returns their sum?
(a, b) -> a + b
a, b -> {return a + b;}
(a, b) { return a + b }
(a, b) -> a * b
Question 7
Which of these statements correctly describes the Stream API in Java 8?
Streams are used to process collections of objects sequentially or in parallel.
Streams allow modifying the original data source.
Streams are primarily used to create new collections.
Streams only allow sequential processing.
Question 8
Which of the following is an intermediate operation in the Stream API?
collect()
map()
forEach()
reduce()
Question 9
Which of the following is a terminal operation in the Stream API?
map()
filter()
reduce()
flatMap()
Question 10
How can a stream be parallelized in Java?
By using stream.parallel()
By using stream.parallelize()
By using parallelStream()
By using stream.split()
There are 13 questions to complete.