Java Reference
In-Depth Information
11 . If a lambda expression throws a checked exception, the abstract method in the func-
tional interface must have a throws clause that includes that exception. True or
False?
12 . What is a method reference?
13 . When evaluated, a method reference creates an instance of the ____________
___________ supplied by its target context.
14 . Given a class called MyClass that contains a static method called myStaticMethod(
) , show how to specify a method reference to myStaticMethod( ) .
15 . Given a class called MyClass that contains an instance method called myInstMeth-
od( ) and assuming an object of MyClass called mcObj , show how to create a meth-
od reference to myInstMethod( ) on mcObj .
16 . To the MethodRefDemo2 program, add a new method to MyIntNum called
hasCommonFactor( ) . Have it return true if its int argument and the value stored in
the invoking MyIntNum object have at least one factor in common. For example, 9
and 12 have a common factor, which is 3, but 9 and 16 have no common factor. De-
monstrate hasCommonFactor( ) via a method reference.
17 . How is a constructor reference specified?
18 . Java defines several predefined functional interfaces in what package?
Search WWH ::




Custom Search