Question 36

Given:
final class Folder { //line n1
//line n2
public void open () {
System.out.print("Open");
}
}
public class Test {
public static void main (String [] args) throws Exception {
try (Folder f = new Folder()) {
f.open();
}
}
}
Which two modifications enable the code to print Open Close? (Choose two.)
  • Question 37

    Given the following array:

    Which two code fragments, independently, print each element in this array?
  • Question 38

    Given the code fragment:

    Which two modifications, when made independently, enable the code to print Joe:true:100.0?
  • Question 39

    Given the definition of the Country class:
    public class country {
    public enum Continent {ASIA, EUROPE}
    String name;
    Continent region;
    public Country (String na, Continent reg) {
    name = na, region = reg;
    }
    public String getName () {return name;}
    public Continent getRegion () {return region;}
    }
    and the code fragment:
    List<Country> couList = Arrays.asList (
    new Country (“Japan”, Country.Continent.ASIA),
    new Country (“Italy”, Country.Continent.EUROPE),
    new Country (“Germany”, Country.Continent.EUROPE));
    Map<Country.Continent, List<String>> regionNames = couList.stream ()
    .collect(Collectors.groupingBy (Country ::getRegion,
    Collectors.mapping(Country::getName, Collectors.toList()))));
    System.out.println(regionNames);
  • Question 40

    Given the code fragment:
    Path source = Paths.get ("/data/december/log.txt");
    Path destination = Paths.get("/data");
    Files.copy (source, destination);
    and assuming that the file /data/december/log.txt is accessible and contains:
    10-Dec-2014 - Executed successfully
    What is the result?