Java Lambda Expression MCQs with answers
79 questions tagged Java Lambda Expression, each with the correct answer and an explanation. Page 1 of 4.
- In which Java version were method references introduced along with lambdas?
- Which functional interface should be used to replace a for-each loop with a lambda?
- What will be the output of `(x, y) -> x * y` for inputs 3 and 4?
- Can lambda expressions implement default methods in interfaces?
- What kind of interface is necessary for a lambda to be used?
- What will `() -> System.out.println("Hi")` produce?
- Lambda expressions were primarily introduced to support which Java feature?
- Which lambda expression can be used to check if a string is empty?
- What is the syntax to implement a `Runnable` using a lambda?
- Which functional interface represents a function that returns a value of type T and takes no arguments?
- What is the purpose of method references like `String::length`?
- Can lambda expressions contain loops?
- What is the role of parentheses in lambda expressions?
- Which of the following can lambda expressions NOT directly implement?
- What is the type of `x -> x.toUpperCase()` if x is a String?
- Can a lambda expression return a value?
- What does the following lambda expression represent: `x -> x % 2 == 0`?
- Which lambda expression will reverse a given string 's'?
- Which of the following is a correct lambda expression with no parameters that returns 100?
- Which interface is used to implement a lambda that takes two arguments and returns a boolean?