Method Reference MCQs with answers
78 questions tagged Method Reference, each with the correct answer and an explanation. Page 2 of 4.
- Can method references refer to overloaded methods?
- In which Java version were method references introduced?
- Which interface is typically used with `ClassName::new` to provide objects?
- What is returned by `Function<String, String> f = String::trim;` when applied to " Hello "?
- Is `object::staticMethod` a valid method reference?
- Which method reference form would match `Function<String, Integer> length = String::length;`?
- What kind of reference is `Arrays::sort`?
- Which is the correct method reference for `String::valueOf`?
- In which scenario can method references replace a lambda?
- Which is a valid method reference for creating a new `ArrayList`?
- What does `super::methodName` refer to?
- Method references require the functional interface to match in:
- Which method reference is equivalent to `(list, e) -> list.add(e)`?
- Which method reference replaces `s -> s.isEmpty()`?
- Which functional interface matches with `String::new` when used with a Supplier?
- What type of method reference is `this::equals`?
- Given `Comparator<String> comp = String::compareToIgnoreCase;`, what does the method reference resolve to?
- Which of these is NOT a valid form of method reference?
- Which method reference is valid for invoking an instance method on a particular object?
- Which method reference can replace `x -> x.toString()`?