Method Reference MCQs with answers
78 questions tagged Method Reference, each with the correct answer and an explanation. Page 3 of 4.
- Method references are available from which Java version?
- Which interface does `Supplier<ClassName>` match with?
- Which operator is used in method reference syntax?
- Is `ClassName::fieldName` a valid method reference?
- What does `super::method` represent?
- What is the syntax for a method reference to the current instance's method?
- Method references can be used with which Java API feature extensively?
- Which reference is equivalent to `(x, y) -> x.compareTo(y)`?
- What does `Function<String, Integer> lengthFunc = String::length;` do?
- Which method reference type allows creating new object instances?
- Which is the correct way to reference an instance method on an arbitrary object?
- Method references can replace lambdas when:
- What is the output of `Arrays.asList("a", "b").forEach(System.out::println);`?
- Which method reference is equivalent to `str -> str.trim()`?
- Which is a valid method reference to a constructor?
- Which form of method reference is `ClassName::staticMethodName`?
- Which functional interface is most suitable for `System.out::println`?
- Which form of method reference is used to refer to an instance method of an existing object?
- Can a method reference refer to a method with parameters?
- Method references are part of which Java version?