1z0-809 Exam Question 131

Given the code fragments:
interface CourseFilter extends Predicate<String> {
public default boolean test (String str) {
return str.equals ("Java");
}
}
and
List<String> strs = Arrays.asList("Java", "Java EE", "Java ME");
Predicate<String> cf1 = s - > s.length() > 3;
Predicate cf2 = new CourseFilter() { //line n1
public boolean test (String s) {
return s.contains ("Java");
}
};
long c = strs.stream()
.filter(cf1)
.filter(cf2 //line n2
.count();
System.out.println(c);
What is the result?
  • 1z0-809 Exam Question 132

    Given the content of /resourses/Message.properties:
    welcome1="Good day!"
    and given the code fragment:
    Properties prop = new Properties ();
    FileInputStream fis = new FileInputStream
    ("/resources/Message.properties");
    prop.load(fis);
    System.out.println(prop.getProperty("welcome1"));
    System.out.println(prop.getProperty("welcome2", "Test"));//line n1
    System.out.println(prop.getProperty("welcome3"));
    What is the result?
  • 1z0-809 Exam Question 133

    Given the code fragment:

    And given the requirements:
    * If the value of the qty variable is greater than or equal to 90, discount = 0.5
    * If the value of the qty variable is between 80 and 90, discount = 0.2 Which two code fragments can be independently placed at line n1 to meet the requirements?
  • 1z0-809 Exam Question 134

    Which statement is true about the single abstract method of the java.util.function.Function interface?
  • 1z0-809 Exam Question 135

    Given the code fragment:
    Stream<Path> files = Files.walk(Paths.get(System.getProperty("user.home")));
    files.forEach (fName -> {//line n1
    try {
    Path aPath = fName.toAbsolutePath();//line n2
    System.out.println(fName + ":"
    + Files.readAttributes(aPath, Basic.File.Attributes.class).creationTime
    ());
    } catch (IOException ex) {
    ex.printStackTrace();
    });
    What is the result?