1z0-809 Exam Question 76

Given the code fragment:
public class Foo {
public static void main (String [ ] args) {
Map<Integer, String> unsortMap = new HashMap< > ( );
unsortMap.put (10, "z");
unsortMap.put (5, "b");
unsortMap.put (1, "d");
unsortMap.put (7, "e");
unsortMap.put (50, "j");
Map<Integer, String> treeMap = new TreeMap <Integer, String> (new
Comparator<Integer> ( ) {
@Override public int compare (Integer o1, Integer o2) {return o2.compareTo
(o1); } } );
treeMap.putAll (unsortMap);
for (Map.Entry<Integer, String> entry : treeMap.entrySet () ) {
System.out.print (entry.getValue () + " ");
}
}
}
What is the result?
  • 1z0-809 Exam Question 77

    Given the code fragment:
    Path file = Paths.get ("courses.txt");
    // line n1
    Assume the courses.txt is accessible.
    Which code fragment can be inserted at line n1 to enable the code to print the content of the courses.txt file?
  • 1z0-809 Exam Question 78

    Given the records from the Employeetable:

    and given the code fragment:
    try {
    Connection conn = DriverManager.getConnection (URL, userName,
    passWord);
    Statement st = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_UPDATABLE);
    st.execute("SELECT*FROM Employee");
    ResultSet rs = st.getResultSet();
    while (rs.next()) {
    if (rs.getInt(1) ==112) {
    rs.updateString(2, "Jack");
    }
    }
    rs.absolute(2);
    System.out.println(rs.getInt(1) + " " + rs.getString(2));
    } catch (SQLException ex) {
    System.out.println("Exception is raised");
    }
    Assume that:
    The required database driver is configured in the classpath.
    The appropriate database accessible with the URL, userName, and passWordexists.
    What is the result?
  • 1z0-809 Exam Question 79

    Given:

    and the code fragment:

    What is the result?
  • 1z0-809 Exam Question 80

    Given the code fragment:
    List<String> codes = Arrays.asList ("DOC", "MPEG", "JPEG");
    codes.forEach (c -> System.out.print(c + " "));
    String fmt = codes.stream()
    .filter (s-> s.contains ("PEG"))
    .reduce((s, t) -> s + t).get();
    System.out.println("\n" + fmt);
    What is the result?