What does the following output?
Predicate dash = c -> c.startsWith("-"); System.out.println(dash.test("-"));
C.
While it is common for a Predicate to have a generic type, it is not required.
It is treated like a Predicate of type Object if the generic type is missing.
Since startsWith()
does not exist on Object, the first line does not compile, and Option C is correct.