Oracle
1Z0-809 · Question #260
Given: class FuelNotAvailException extends Exception { } class Vehicle { void ride() throws FuelNotAvailException { //line n1 System.out.println("Happy Journey!"); } } class SolarVehicle extends…
The correct answer is B. Replace line n1 with protected void ride() throws Exception {. You've hit your session limit · resets 5:20pm (America/New_York)
Question
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!?
Options
- AReplace line n1 with public void ride() throws FuelNotAvailException {
- BReplace line n1 with protected void ride() throws Exception {
- CReplace line n2 with void ride() throws Exception {
- DReplace line n2 with private void ride() throws FuelNotAvailException {
How the community answered
(32 responses)- A9% (3)
- B84% (27)
- C3% (1)
- D3% (1)
Explanation
You've hit your session limit · resets 5:20pm (America/New_York)
Community Discussion
No community discussion yet for this question.