InterviewSolution
| 1. |
What are some standard Java pre-defined functional interfaces? |
|
Answer» Some of the famous pre-defined functional interfaces from previous Java versions are Runnable, Callable, COMPARATOR, and Comparable. While Java 8 introduces functional interfaces like SUPPLIER, Consumer, Predicate, etc. Please refer to the java.util.function doc for other predefined functional interfaces and its description introduced in Java 8. Runnable: use to EXECUTE the instances of a class over another thread with no arguments and no return value. Callable: use to execute the instances of a class over another thread with no arguments and it EITHER returns a value or throws an exception. Comparator: use to sort different objects in a user-defined ORDER Comparable: use to sort objects in the natural sort order |
|