OCP - 2
Functional Programming, Dates, Strings, Localization, Exceptions and Assertions
Functional Programming, Dates, Strings, Localization, Exceptions and Assertions
Kartei Details
Karten | 115 |
---|---|
Sprache | English |
Kategorie | Informatik |
Stufe | Andere |
Erstellt / Aktualisiert | 22.02.2019 / 08.01.2020 |
Lizenzierung | Keine Angabe |
Weblink |
https://card2brain.ch/box/20190222_ocp_2
|
Einbinden |
<iframe src="https://card2brain.ch/box/20190222_ocp_2/embed" width="780" height="150" scrolling="no" frameborder="0"></iframe>
|
What is the return type of Predicate?
Primitive boolean (prmitive)
What common Built-In Functional Interfaces do exist?
- Supplier
- Consumer
- BiConsumer
- Predicate
- BiPredicate
- Function
- BiFunction
- UnaryOperator
- BinaryOperator
In which package can the built-in functional interfaces be found?
java.util.functional
Does the Predicate class define only exactly one method?
Only one abstract method, but some additional utility default implementations, such as and.
This makes it's use convenient: eg, given two predicates egg and brown: egg.and(brown)
What is the goal of the Function Interface?
Turning one parameter into a value of a potentially different type and returning it
What is the goal of the Unaryperator Interface?
A special case of Function, for which the Input and Output Parameter are the same. It is actually a subclass of the Function interface
What happens here?
Predicate ex = String::isEmpty;
It is missing the generic for Predicate. This makes the parameter that was passed an Object rather than a String. The lambda expects a String because it calls a method that eists on String rather than Object. Therfore, it does not compile
What static factory methods exist on Optional?
- Optional.empty()
- Optional.of(123)
- Optional.ofNullable(val)