6.2 Introducing Functional Interfaces Flashcards

1
Q

📝️ What friend can help us remember what is a functional interface?

A

Our dear friend SAM, because a Functional Interface contains a Single Abstract Method aka (SAM)

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

📝️ What annotation does Java provide to confirm an Interface is Functional?

A

@FunctionalInterface

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

📝️ What package is specifically designed to contain only functional interfaces that are reused in the rest of the library?

A

java.util.function

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

📝️ What are the 4 fundamental predefined Functional Interfaces?

A

Predicate -> boolean test(T t)
Function -> R apply(T t)
Consumer -> void accept(T t)
Supplier -> T get()

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

📝️ What feature does java.lang.Comparable provides?

A

single-sorting sequence
-> In other words, we can sort the collection on the basis of a 🧠️single element🧠️ such as id, name, or price. (It’s predefined Natural sort)

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

📝️ Does Comparable interface affects the original class?

A

Yes, It performs a 💥️Mutable💥️ process

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

📝️ What is the S.A.M of Comparable?

A

Comparable :: int compareTo​(T o);

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

📝️ What features does java.util.Comparator provides?

A

multiple-sorting sequence

-> We can sort a collection on the basis of 🧠️multiple elements🧠️

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

📝️ Does Comparator interface affects the original class?

A

No, , It performs an💥️Immutable💥️ process

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

📝️ What is the S.A.M of Comparator?

A

Comparator :: int compare(T o1, T o2);

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