Question 126

Given:

What is the result?
  • Question 127

    Given:
    class RateOfInterest {
    public static void main (String[] args) {
    int rateOfInterest = 0;
    String accountType = "LOAN";
    switch (accountType) {
    case "RD";
    rateOfInterest = 5;
    break;
    case "FD";
    rateOfInterest = 10;
    break;
    default: assert false: "No interest for this account"; //line n1 } System.out.println ("Rate of interest:" + rateOfInterest); } }
    and the command:
    java -ea RateOfInterest
    What is the result?
  • Question 128

    Given the code fragment:
    public static void main (String[] args) throws IOException {
    BufferedReader brCopy = null;
    try (BufferedReader br = new BufferedReader (new FileReader("employee.txt"))) { //
    line n1
    br.lines().forEach(c -> System.out.println(c));
    brCopy = br;//line n2
    }
    brCopy.ready(); //line n3;
    }
    Assume that the ready method of the BufferedReader, when called on a closed BufferedReader, throws an exception, and employee.txt is accessible and contains valid text.
    What is the result?
  • Question 129

    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?
  • Question 130

    Given:
    class Bird {
    public void fly () { System.out.print("Can fly"); }
    }
    class Penguin extends Bird {
    public void fly () { System.out.print("Cannot fly"); }
    }
    and the code fragment:
    class Birdie {
    public static void main (String [ ] args) {
    fly( ( ) -> new Bird ( ));
    fly (Penguin : : new);
    }
    /* line n1 */
    }
    Which code fragment, when inserted at line n1, enables the Birdie class to compile?