Java 8 Flashcards

1
Q

What is a lambda expression in Java 8?

A

A concise way to represent an anonymous function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the purpose of the Stream API in Java 8?

A

To manipulate collections of data in a functional style.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Which annotation is used to declare a functional interface in Java 8?

A

@FunctionalInterface

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How many types of method references are there in Java 8?

A

4
(Exp.: There are four types of method references in Java 8: static method references, instance method references of a particular object, instance method references of an arbitrary object, and constructor references.)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the default method in an interface in Java 8?

A

A method that is automatically inherited by implementing classes.
(Exp.: A default method in an interface is automatically inherited by implementing classes and can be overridden if needed.)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the purpose of the Optional class in Java 8?

A

To represent nullable values safely and avoid NullPointerExceptions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the main advantage of using parallel streams in Java 8?

A

Concurrent execution on multiple threads

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Which package contains the Predicate functional interface in Java 8?

A

java.util.function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the purpose of the forEach method in the Stream API in Java 8?

A

To apply a function to each element of a stream

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly