LearnFrenzy
Sign in Take a free test

Lambda Expressions · Lambda Expressions MCQ · Question 16

Checked exceptions inside a Function lambda Answer, explanation & discussion

  • MCQ
  • Hard
  • 0 comments
  • Answer explained
  • Moderated community
Question 16 Back to Exercise

Why can't a Function<Path, String> lambda call Files.readString(p) directly?

  • A Files cannot be used in lambdas
  • B Function.apply declares no checked exceptions, but readString throws IOException; catch it or use an interface that declares it Correct
  • C Path is not serializable
  • D It can
Correct Answer: Option B

Callable.call(), by contrast, declares throws Exception.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links