Java MCQs with answers Page - 479

Here, you will find a collection of MCQ questions on Java. Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

A

Admin • 831.35K Points
Coach

Q. Which method is declared by the functional interface `Supplier`?

  • (A) get()
  • (B) accept()
  • (C) test()
  • (D) apply()

A

Admin • 831.35K Points
Coach

Q. What is the purpose of the `Predicate` functional interface?

  • (A) Consume an input and produce a result
  • (B) Test a condition on input and return boolean
  • (C) Supply values with no input
  • (D) Chain multiple consumers

A

Admin • 831.35K Points
Coach

Q. Which method does `Consumer` functional interface define?

  • (A) run()
  • (B) get()
  • (C) accept()
  • (D) apply()

A

Admin • 831.35K Points
Coach

Q. Which functional interface is used when no input is taken but a result is returned?

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

A

Admin • 831.35K Points
Coach

Q. What does the `Function` functional interface do?

  • (A) Consumes a value
  • (B) Produces a boolean
  • (C) Transforms input to output
  • (D) Runs in a new thread

A

Admin • 831.35K Points
Coach

Q. Which functional interface method is defined in `Predicate`?

  • (A) test()
  • (B) apply()
  • (C) accept()
  • (D) run()

A

Admin • 831.35K Points
Coach

Q. Which of these is NOT a standard functional interface in Java?

  • (A) Runnable
  • (B) Callable
  • (C) Cloneable
  • (D) Supplier

A

Admin • 831.35K Points
Coach

Q. Which functional interface returns a value and may throw an exception?

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

A

Admin • 831.35K Points
Coach

Q. What is the output type of `Function<String, Integer>` when applied to a String?

  • (A) String
  • (B) Integer
  • (C) Boolean
  • (D) Double

A

Admin • 831.35K Points
Coach

Q. Which functional interface is used to chain multiple transformations?

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

Add MCQ in this Category

If you want to share an MCQ question in this category, it's a great idea! It will be helpful for many other students using this website.

Share Your MCQ