Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Java 8 Interview Questions and Answers

Question: What is the difference between Predicate and Function?
Answer:
Both are functional interfaces.
  • Predicate<T> is single argument function and either it returns true or false. This can be used as the assignment target for a lambda expression or method reference.
  • Function<T,R> is also single argument function but it returns an Object. Here T denotes type of input to the function and R denotes type of Result. This can also be used as the assignment target for a lambda expression or method reference.
Is it helpful? Yes No

Most helpful rated by users:

©2024 WithoutBook