exam questions

Exam 1z0-808 All Questions

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

Exam 1z0-808 topic 1 question 71 discussion

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

Given the following code for the classes MyException and Test:

What is the result?

  • A. A
  • B. B
  • C. Either A or B
  • D. A B
  • E. A compile time error occurs at line n1
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

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
v323rs
Highly Voted 5 years ago
I agree, the correct answer B B
upvoted 9 times
...
MPignaProTech
Most Recent 3 months ago
Selected Answer: C
Answer is C, Math.Random can be<0.5
upvoted 1 times
...
yanoolthecool
1 year, 1 month ago
Selected Answer: B
exception is caught in method, B.
upvoted 1 times
...
Ripfumelo
2 years ago
THE ANSWER IS B
upvoted 1 times
...
carloswork
2 years, 2 months ago
Selected Answer: B
Tested. Answer is B. Source code: class MyException extends RuntimeException{} public class Test { public static void main(String[] args) { try { method1(); } catch (MyException e) { System.out.println("A"); } } public static void method1() { try { throw Math.random() > 0.5 ? new MyException() : new RuntimeException(); } catch (RuntimeException re) { System.out.println("B"); } } }
upvoted 1 times
...
Chirag3105
2 years, 8 months ago
B is only correct answers, as MyException is subclass of RuntimeException, so it will be caught by the catch block in the method1.
upvoted 4 times
...
deksero2
2 years, 9 months ago
Selected Answer: B
B is correct beacause MyException extends Runtime exception.
upvoted 1 times
...
BuhlebesizweMnqobi
2 years, 10 months ago
Selected Answer: B
B is Correct
upvoted 1 times
...
deksero2
2 years, 11 months ago
Selected Answer: B
It is B. Runtime catches MyException too.
upvoted 2 times
...
ddpk
2 years, 11 months ago
Answer is B. Because MyException is RuntimeException.
upvoted 1 times
...
Anupam_Anand
2 years, 12 months ago
correct answer is B because MyException is RuntimeException itself.
upvoted 1 times
...
admin8
3 years ago
Selected Answer: C
Answer is C!!!!!
upvoted 3 times
Nicolas_Cage
1 year, 8 months ago
yes it is!
upvoted 1 times
...
uncopino
2 years, 11 months ago
wrong. MyException extends RuntimeException
upvoted 2 times
...
Adel_Kedidi
2 years, 11 months ago
wrong. for both classes MyException or RuntimeException, we'll have 'B' printed since MyException is a subclass of RuntimeException. Thanks for rectifying...
upvoted 2 times
...
...
JongHwa
3 years, 1 month ago
correct answer is B class MyException extends RuntimeException{} public class Test{ public static void main(String[] args) { try { method1(); } catch (MyException e) { System.out.println("A"); } } public static void method1() { try { throw new MyException(); } catch (RuntimeException e) { System.out.println("bb"); } } }
upvoted 3 times
...
sudar123
3 years, 3 months ago
E. compilation error at line n1 "Exception" needs to be declared
upvoted 1 times
uncopino
2 years, 11 months ago
nope. RuntimeException as any class extenting it is an unchecked exception, plus it is already hadled in a try block so double wrong
upvoted 1 times
...
...
lena
3 years, 10 months ago
B , catch (RuntimeException re)” always catches a RuntimeException
upvoted 1 times
...
mete23
4 years, 11 months ago
the correct answer B
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