Q78. What are the major features introduced in Java 8?
Lambda expressions
Functional interfaces
Stream API
Default methods in interfaces
Static interface methods
Optional class
Method references
New Date and Time API
Q79. What is a Lambda expression?
A lambda expression is a concise way of implementing a functional interface.
(a, b) -> a + bQ80. What is a Functional Interface?
An interface containing exactly one abstract method. It can have default and static methods.
@FunctionalInterface
interface MyInterface {
void display();
}Q81. What is the Stream API?
Stream API is used to process collections of data in a functional style.
List<Integer> nums = Arrays.asList(1, 2, 3, 4, 5);
nums.stream()
.filter(n -> n % 2 == 0)
.forEach(System.out::println);Output: 2 4
Q82. Difference between map() and filter()?
map()transforms elements.filter()selects elements based on a condition.
Q84. What is a method reference?
A shorter way of referring to an existing method using ::.
nums.forEach(System.out::println);Q85. What is a default method in an interface?
A method with an implementation inside an interface, declared using the default keyword.