Java Lambda Expression MCQs with answers Page - 2

You will find multiple-choice questions (MCQs) related to #Java Lambda Expression here. Go through these questions to prepare effectively for your upcoming exams and interviews.

To view the correct answer for any question, simply click the "Show Answer" button.

Have a question to share? Click on "Add Question" to contribute!

A

Admin • 825.56K Points
Coach

Q. Which functional interface returns a boolean value after testing a condition?

  • (A) Predicate
  • (B) Function
  • (C) Supplier
  • (D) Consumer

A

Admin • 825.56K Points
Coach

Q. Which method reference operator is used in Java?

  • (A) ->
  • (B) ::
  • (C) =>
  • (D) %%

A

Admin • 825.56K Points
Coach

Q. Which of the following is a valid lambda expression for no parameters?

  • (A) () -> System.out.println("Hello")
  • (B) () : System.out.println("Hello")
  • (C) () => System.out.println("Hello")
  • (D) lambda: System.out.println("Hello")

A

Admin • 825.56K Points
Coach

Q. What is captured from the enclosing scope in a lambda expression?

  • (A) Local variables only if they are final or effectively final
  • (B) All variables regardless of finality
  • (C) Class variables only
  • (D) No variables are captured

A

Admin • 825.56K Points
Coach

Q. Which functional interface does not take any arguments nor return any result?

  • (A) Runnable
  • (B) Supplier
  • (C) Consumer
  • (D) Function

A

Admin • 825.56K Points
Coach

Q. Can a lambda expression throw a checked exception?

  • (A) No
  • (B) Yes, if declared in the functional interface
  • (C) Only runtime exceptions
  • (D) Only in custom functional interfaces

A

Admin • 825.56K Points
Coach

Q. Which of these is NOT a benefit of using lambda expressions?

  • (A) Concise code
  • (B) Enabling functional programming
  • (C) Anonymous class elimination
  • (D) Increased memory usage

A

Admin • 825.56K Points
Coach

Q. Which feature in Java 8 works closely with lambda expressions for collection processing?

  • (A) Streams API
  • (B) Threads API
  • (C) Reflection API
  • (D) Serialization API

A

Admin • 825.56K Points
Coach

Q. Can lambda expressions be used to override methods in interfaces with multiple abstract methods?

  • (A) Yes
  • (B) No
  • (C) Only if all methods have the same signature
  • (D) Only in abstract classes

A

Admin • 825.56K Points
Coach

Q. What is the default return type of a lambda expression without a return statement?

  • (A) void
  • (B) int
  • (C) boolean
  • (D) Depends on functional interface
What's Tag

As you may know, questions are organized under broad categories. Each category can include various types of questions. For example, the "History" category might contain questions about the Revolt of 1857, Shivaji Maharaj, Ancient History, Buddhism, and more.

To further refine this organization, we've introduced tags, which act as sub-categories to group questions more specifically.

Verified users can add tags to any question. If you have any suggestions regarding this system, we'd love to hear from you. Contact Us

Learn More