πŸ“Š JAVA
Q. What is a functional interface in Java?
  • (A) An interface with default methods only
  • (B) An interface with exactly one abstract method
  • (C) Any interface with static methods
  • (D) Any abstract class
πŸ’¬ Discuss
βœ… Correct Answer: (B) An interface with exactly one abstract method

Explanation: A functional interface has exactly one abstract method, enabling it to be used with lambda expressions.

πŸ“Š JAVA
Q. Which annotation is used to indicate a functional interface?
  • (A) @Override
  • (B) @FunctionalInterface
  • (C) @Deprecated
  • (D) @Interface
πŸ’¬ Discuss
βœ… Correct Answer: (B) @FunctionalInterface

Explanation: `@FunctionalInterface` is used to enforce that an interface has exactly one abstract method.

πŸ“Š JAVA
Q. Which of the following is a functional interface?
  • (A) Runnable
  • (B) Serializable
  • (C) Comparable
  • (D) Cloneable
πŸ’¬ Discuss
βœ… Correct Answer: (A) Runnable

Explanation: `Runnable` is a functional interface with a single `run()` method.

πŸ“Š JAVA
Q. Which method is declared by the functional interface `Supplier`?
  • (A) get()
  • (B) accept()
  • (C) test()
  • (D) apply()
πŸ’¬ Discuss
βœ… Correct Answer: (A) get()

Explanation: `Supplier` provides the `get()` method to return a value.

πŸ“Š JAVA
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
πŸ’¬ Discuss
βœ… Correct Answer: (B) Test a condition on input and return boolean

Explanation: `Predicate` takes an input and returns a boolean result based on a condition.

πŸ“Š JAVA
Q. Which method does `Consumer` functional interface define?
  • (A) run()
  • (B) get()
  • (C) accept()
  • (D) apply()
πŸ’¬ Discuss
βœ… Correct Answer: (C) accept()

Explanation: `Consumer` defines `accept()` which consumes a single input with no return.

πŸ“Š JAVA
Q. Which functional interface is used when no input is taken but a result is returned?
  • (A) Consumer
  • (B) Supplier
  • (C) Predicate
  • (D) Function
πŸ’¬ Discuss
βœ… Correct Answer: (B) Supplier

Explanation: `Supplier` provides a result with no input.

πŸ“Š JAVA
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
πŸ’¬ Discuss
βœ… Correct Answer: (C) Transforms input to output

Explanation: `Function` transforms input of type T to output of type R.

πŸ“Š JAVA
Q. Which functional interface method is defined in `Predicate`?
  • (A) test()
  • (B) apply()
  • (C) accept()
  • (D) run()
πŸ’¬ Discuss
βœ… Correct Answer: (A) test()

Explanation: `Predicate` defines the `test()` method that returns a boolean.

πŸ“Š JAVA
Q. Which of these is NOT a standard functional interface in Java?
  • (A) Runnable
  • (B) Callable
  • (C) Cloneable
  • (D) Supplier
πŸ’¬ Discuss
βœ… Correct Answer: (C) Cloneable

Explanation: `Cloneable` is a marker interface and not a functional interface.