Question 21
Given:
and
Which interface from the java.util.functionpackage should you use to refactor the class Txt?
Question 22
Given that course.txt is accessible and contains:
Course : : Java
and given the code fragment:
public static void main (String[ ] args) {
int i;
char c;
try (FileInputStream fis = new FileInputStream ("course.txt");
InputStreamReader isr = new InputStreamReader(fis);) {
while (isr.ready()) { //line n1
isr.skip(2);
i = isr.read ();
c = (char) i;
System.out.print(c);
}
} catch (Exception e) {
e.printStackTrace();
}
}
What is the result?
Question 23
Assume customers.txtis accessible and contains multiple lines.
Which code fragment prints the contents of the customers.txtfile?
Stream<String> stream = Files.find (Paths.get (“customers.txt”));
Question 24
Which two reasons should you use interfaces instead of abstract classes?
Question 25
Which statement is true about the single abstract method of the java.util.function.Function interface?
