πŸ“Š JAVA
Q. Which functional interface returns a value and may throw an exception?
  • (A) Runnable
  • (B) Callable
  • (C) Consumer
  • (D) Supplier
πŸ’¬ Discuss
βœ… Correct Answer: (B) Callable

Explanation: `Callable` returns a value and may throw an exception.

πŸ“Š JAVA
Q. What is the output type of `Function<String, Integer>` when applied to a String?
  • (A) String
  • (B) Integer
  • (C) Boolean
  • (D) Double
πŸ’¬ Discuss
βœ… Correct Answer: (B) Integer

Explanation: `Function<String, Integer>` takes a String input and returns an Integer.

πŸ“Š JAVA
Q. Which functional interface is used to chain multiple transformations?
  • (A) Predicate
  • (B) Consumer
  • (C) Function
  • (D) Supplier
πŸ’¬ Discuss
βœ… Correct Answer: (C) Function

Explanation: `Function` can be composed and chained using `andThen` and `compose`.

πŸ“Š JAVA
Q. Which functional interface accepts two arguments and returns a result?
  • (A) Function
  • (B) BiFunction
  • (C) Supplier
  • (D) Consumer
πŸ’¬ Discuss
βœ… Correct Answer: (B) BiFunction

Explanation: `BiFunction` takes two inputs and returns a result.

πŸ“Š JAVA
Q. What is the main benefit of using functional interfaces in Java?
  • (A) Supports multiple inheritance
  • (B) Enables lambda expressions
  • (C) Allows method overloading
  • (D) Simplifies polymorphism
πŸ’¬ Discuss
βœ… Correct Answer: (B) Enables lambda expressions

Explanation: Functional interfaces enable the use of lambda expressions.

πŸ“Š JAVA
Q. Which interface is marked as functional even though it has `default` methods?
  • (A) Comparable
  • (B) Runnable
  • (C) Predicate
  • (D) Consumer
πŸ’¬ Discuss
βœ… Correct Answer: (C) Predicate

Explanation: `Predicate` is functional because it has only one abstract method despite default methods.

πŸ“Š JAVA
Q. Which functional interface method returns void?
  • (A) Supplier.get()
  • (B) Function.apply()
  • (C) Consumer.accept()
  • (D) Predicate.test()
πŸ’¬ Discuss
βœ… Correct Answer: (C) Consumer.accept()

Explanation: `Consumer.accept()` consumes input and returns nothing (void).

πŸ“Š JAVA
Q. In which Java version were functional interfaces introduced?
  • (A) Java 6
  • (B) Java 7
  • (C) Java 8
  • (D) Java 9
πŸ’¬ Discuss
βœ… Correct Answer: (C) Java 8

Explanation: Java 8 introduced functional interfaces along with lambda expressions.

πŸ“Š JAVA
Q. Which functional interface is preferred for computations that may fail with an exception?
  • (A) Supplier
  • (B) Runnable
  • (C) Callable
  • (D) Function
πŸ’¬ Discuss
βœ… Correct Answer: (C) Callable

Explanation: `Callable` can return a value and throw a checked exception.

πŸ“Š JAVA
Q. In the following URL, identify the protocol identifier? https://mcqmate.com:8080/course.php
  • (A) http
  • (B) gtu.ac.in
  • (C) //mcqmate.com:80/course.php
  • (D) 8080
πŸ’¬ Discuss
βœ… Correct Answer: (A) http