6.3 Predefined Functional Interfaces Flashcards

1
Q

πŸ“οΈ What is a Function?

A

A Function is a Functional Interface whose S.A.M β€œapply” takes a Generic argument and returns a Generic value

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

πŸ“οΈ What is the SAM signature of the pre-defined functional interface Function?

A

Function :: R apply(T t);

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

πŸ“οΈ What methods do take a generic argument and return a generic value?

A

o Collection -> toArray(..)
o Optional -> map()|flatMap()
o Stream -> map()|flatMap()
reduce()|toArray()
o Map -> compute+(If{Absent|Present)
merge()|replaceAll()
o Comparator -> comparing()|thenComparing()

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

πŸ“οΈ What is a Consumer?

A

A Consumer is a Functional Interface whose S.A.M takes a Generic argument and returns nothing

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

πŸ“οΈ What is the SAM signature of the pre-defined functional interface Consumer?

A

Consumer :: void accept(T t);

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

πŸ“οΈ What methods do take a generic argument and don’t return anything ?

A

o Collection -> forEach()
o Optional -> ifPresent()|ifPresentOrElse()
o Stream -> collect()|forEach()|forEachOrdered|peek()
o Map -> forEach()

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

πŸ“οΈ What is a Supplier?

A

A Supplier is a functional interface whose S.A.M takes NO argument and returns a generic value.

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

πŸ“οΈ What is the SAM signature of the pre-defined functional interface Supplier?

A

Supplier :: T get();

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

πŸ“οΈ What methods don’t take any argument and return a generic value ?

A

o Math -> random()
o Optional -> orElseGet()|orElseThrow()
o Objects.requireNonNull()
o CompletableFuture.supplyAsync()

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

πŸ“οΈ What is a Predicate?

A

A Predicate is Functional Interface whose S.A.M takes a Generic argument and returns a boolean.

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

πŸ“οΈ What is the SAM signature of the pre-defined functional interface Predicate?

A

Predicate :: boolean test(T t);

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

πŸ“οΈ What methods do take a generic argument and return boolean ?

A

o Collection -> removeIf(..)
o Optional -> filter(..)
o Stream -> filter
{none|any|all}Match
iterate|dropWhile|takeWhile
o Collectors -> filtering|partitioningBy*

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