Question 146

Given the code fragment:

Which code fragment, when inserted at line n1, enables the code to print /First.txt?
  • Question 147

    Given:
    class FuelNotAvailException extends Exception { }
    class Vehicle {
    void ride() throws FuelNotAvailException {//line n1
    System.out.println("Happy Journey!");
    }
    }
    class SolarVehicle extends Vehicle {
    public void ride () throws Exception {//line n2
    super ride ();
    }
    }
    and the code fragment:
    public static void main (String[] args) throws FuelNotAvailException, Exception {
    Vehicle v = new SolarVehicle ();
    v.ride();
    }
    Which modification enables the code fragment to print Happy Journey!?
  • Question 148

    Given:

    And given the code fragment:

    What is the result?
  • Question 149

    Given:

    What is the result?
  • Question 150

    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?