Govt. Exams
Entrance Exams
Advertisement
Topics in Java Programming
Which of the following is a valid lambda expression syntax in Java?
Correct Answer:
A. (int x, int y) -> x + y
EXPLANATION
Valid Java lambda syntax uses arrow operator (->). Parameters can be typed or untyped, and the expression or block follows the arrow.
What is the primary purpose of lambda expressions introduced in Java 8?
Correct Answer:
A. To provide a concise syntax for implementing functional interfaces
EXPLANATION
Lambda expressions provide a concise way to implement single abstract method (functional interfaces) without verbose anonymous class syntax.