Lernkarten

Karten 115 Karten
Lernende 1 Lernende
Sprache English
Stufe Andere
Erstellt / Aktualisiert 22.02.2019 / 04.03.2019
Lizenzierung Keine Angabe
Weblink
Einbinden
0 Exakte Antworten 113 Text Antworten 2 Multiple Choice Antworten
Fenster schliessen

What is the return type of Predicate?

Primitive boolean (prmitive)

Fenster schliessen

What common Built-In Functional Interfaces do exist?

  • Supplier
  • Consumer
  • BiConsumer
  • Predicate
  • BiPredicate
  • Function
  • BiFunction
  • UnaryOperator
  • BinaryOperator
Fenster schliessen

In which package can the built-in functional interfaces be found?

java.util.functional

Fenster schliessen

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)

Fenster schliessen

What is the goal of the Function Interface?

Turning one parameter into a value of a potentially different type and returning it

Fenster schliessen

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

Fenster schliessen

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

Fenster schliessen

What static factory methods exist on Optional?

  • Optional.empty()
  • Optional.of(123)
  • Optional.ofNullable(val)