exam questions

Exam 1z0-809 All Questions

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

Exam 1z0-809 topic 1 question 155 discussion

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

Given the code fragments:
and

What is the result?

  • A. Video played.Game played.
  • B. A compilation error occurs.
  • C. class java.lang.Exception
  • D. class java.io.IOException
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
Chiraj
Highly Voted 3 years, 5 months ago
Rule: If the superclass method declares an exception, the subclass overridden method can declare the same, subclass exception or no exception but cannot declare parent exception.
upvoted 8 times
...
steefaand
Most Recent 5 months, 4 weeks ago
Selected Answer: B
B is true because when overriding method you must use that same Exception class or its child.
upvoted 1 times
...
iSnover
5 months, 4 weeks ago
Selected Answer: B
Answer is B, tested class test{ public void printValues() throws IOException { System.out.println("Hi"); } } class test2 extends test{ public void printValues() throws Exception{ super.printValues(); System.out.println("hi2"); } }
upvoted 1 times
...
WilsonKKerll
2 years, 4 months ago
Answer is B.
upvoted 1 times
...
mevlt
2 years, 5 months ago
The answer is A(tested) public class Video{ public void play() throws IOException{ System.out.print("Vidoe played."); } } class Game extends Video{ public void play() throws IOException{ super.play(); System.out.print("Game played."); } public static void main(String[] args) { try { new Game().play(); }catch (Exception e){ System.out.println(e.getClass()); } } }
upvoted 1 times
mevlt
2 years, 5 months ago
Nevermind.
upvoted 1 times
...
...
Svetleto13
2 years, 12 months ago
Answer is compilation error.Both classes shoult throw Exception to compile and get answer A.
upvoted 1 times
...
jduarte
3 years, 6 months ago
Answer B. Tested. Exception Exception is not compatible with throws clause in test.printValues()
upvoted 2 times
...
Abdullah_Rahahleah
3 years, 7 months ago
Answer is B, tested class test{ public void printValues() throws IOException { System.out.println("Hi"); } } class test2 extends test{ public void printValues() throws Exception{ super.printValues(); System.out.println("hi2"); } }
upvoted 2 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