Question 151

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 FuelNotAvailException {//line n2
super ride ();
}
}
and the code fragment:
public static void main (String[] args) throws Exception {
Vehicle v = new SolarVehicle ();
v.ride();
}
Which modification enables the code fragment to print Happy Journey!?
  • Question 152

    Given the code fragment:
    public static void main (String [ ] args) throws IOException {
    BufferedReader br = new BufferedReader (new InputStremReader (System.in)); System.out.print ("Enter GDP: ");
    //line 1
    }
    Which code fragment, when inserted at line 1, enables the code to read the GDP from the user?
  • Question 153

    Given:

    And given the code fragment:

    What is the result?
  • Question 154

    Given the code fragment:

    What is the result?
  • Question 155

    Given the code fragment:
    BiFunction<Integer, Double, Integer> val = (t1, t2) -> t1 + t2; //line n1 System.out.println(val.apply(10, 10.5));
    What is the result?