exam questions

Exam 1z0-808 All Questions

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

Exam 1z0-808 topic 1 question 19 discussion

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

Given the code fragment:

What is the result?
A.

B. Compilation fails only at line n1.
C. Compilation fails only at line n2.
D. Compilation fails only at line n3.
E. Compilation fails at both line n2 and line n3.

Show Suggested Answer Hide Answer
Suggested Answer: D

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
RoxyFoxy
Highly Voted 2 years, 4 months ago
I think the correct answer is C. The exception for readCard() must be caught or declared to be thrown.
upvoted 12 times
...
MPignaProTech
Most Recent 2 months, 1 week ago
Correct answer is C. Exception must be verified. RunTimeException is not mandotory to be verified
upvoted 1 times
...
joeMP
3 months ago
Correct answer is C. Exception must be verified. RunTimeException is not mandotory to be verified
upvoted 1 times
...
z24134
1 year, 2 months ago
checked exception needs to be thrown
upvoted 2 times
...
yefiw
1 year, 2 months ago
Answer should be C
upvoted 1 times
...
arjunrawatirissoftware
1 year, 3 months ago
Answer - C
upvoted 1 times
...
DriftKing
1 year, 4 months ago
Answer is C. Compilation fails only at line n2. \\Code public class Test { void readCard(int cardNo) throws Exception { System.out.println("Reading Card"); } void checkCard(int cardNo) throws RuntimeException { System.out.println("Checking Card"); } public static void main(String[] args) { Test ex = new Test(); int cardNo = 12344; ex.readCard(cardNo); ex.checkCard(cardNo); } }
upvoted 2 times
...
duydn
1 year, 4 months ago
C is the correct one, because when method throw checked exception, u have to handle it.
upvoted 1 times
...
a_really_reliable_programmer
1 year, 4 months ago
Answer is C A, compile error (Does not print) B, The method itself is not wrong, you just have to try/catch C, Did not catch the Exception D, Last line won't fail because it's method is runtime and runtime doesn't happen if it doesn't even compile.
upvoted 2 times
...
Sreeni_A
1 year, 4 months ago
C is correct
upvoted 1 times
...
jlicini
1 year, 5 months ago
C, Unhandled exception: java.lang.Exception ... Runtime is unchecked exception
upvoted 1 times
...
dsms
1 year, 5 months ago
C is the correct
upvoted 1 times
...
billy_the_kid
1 year, 8 months ago
Answer is C. Checked Exceptions should be handled or declared, in this case the problem is that we missed to declare the Exception in main method. So in order your code to pass the compilation, you should add at the main method "throws Exception".
upvoted 1 times
...
Vicky_65
1 year, 9 months ago
The answer is option C.Because checked exception should be declared or handle in main method for readcard method.
upvoted 2 times
...
Shad657
1 year, 11 months ago
The answer should be C. The compilation error can be removed by doing this - class Test { void readCard (int cardNo) throws Exception { System.out.println("Reading Card"); } void checkCard (int cardNo) throws RuntimeException { System.out.println("Checking Card"); } public static void main (String[] args) throws Exception { Test ex = new Test(); int cardNo = 12344; ex. readCard (cardNo) ; ex. checkCard (cardNo); } }
upvoted 1 times
...
Ankit1010
1 year, 11 months ago
C is the correct answer
upvoted 2 times
...
haisaco
2 years ago
Vote C: RuntimeException no need trycatch or throws
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