exam questions

Exam 1z0-809 All Questions

View all questions & answers for the 1z0-809 exam

Exam 1z0-809 topic 1 question 169 discussion

Actual exam question from Oracle's 1z0-809
Question #: 169
Topic #: 1
[All 1z0-809 Questions]

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!?

  • A. Replace line n1 with public void ride() throws FuelNotAvailException {
  • B. Replace line n1 with protected void ride() throws Exception {
  • C. Replace line n2 with public void ride()throws FuelNotAvailException, Exception {
  • D. Replace line n2 with private void ride() throws FuelNotAvailException {
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
steefaand
5 months, 4 weeks ago
Selected Answer: A
It compiles already but you can select A since it will compile too.
upvoted 1 times
...
duydn
10 months, 2 weeks ago
Selected Answer: B
Code is compilation successfully, no need to change, if change, change the modifier of default -> protected of n1
upvoted 1 times
duydn
10 months, 2 weeks ago
or public
upvoted 1 times
...
...
Svetleto13
3 years, 2 months ago
Code doesnt need change,but it works with answer A as well.
upvoted 3 times
...
JME_CHG
3 years, 4 months ago
no change needed in code... tested
upvoted 3 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago