exam questions

Exam 1z0-808 All Questions

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

Exam 1z0-808 topic 1 question 138 discussion

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

Given the code fragment:

Which two modifications should you make so that the code compiles successfully? (Choose two.)

  • A. Replace line 13 with:
  • B. Replace line 7 with throw IOException (ג€Exception raisedג€);
  • C. Replace line 11 with public static void main(String[]) args) throws Exception {
  • D. At line 14, insert throw new IOException();
  • E. Replace line 5 with public void printFileContent() throws IOException {
Show Suggested Answer Hide Answer
Suggested Answer: CE 🗳️

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
jackymak
1 week, 3 days ago
class X { public void printFileContent() throws IOException { throw new IOException(); } } public class Test { public static void main(String[] args) throws IOException { X xobj = new X(); xobj.printFileContent(); } }
upvoted 1 times
...
TOPPSI
5 months, 1 week ago
Result: CE. A not. Because in the catche statment Exception was caught first. In the following catch statment ia a IO Exception caught, since this is a subclass of Exception. The compiler recognizes that the code would never get to this place in the code
upvoted 2 times
...
iSnover
8 months, 1 week ago
Selected Answer: CE
The answer is CE, no comments, putting this in the class/method will make it compile normally. In relation to the OCA, in this type of question you have to go with the most obvious.
upvoted 2 times
iSnover
8 months ago
And forgot to comment, Exceptions need to be declared in the constructor declaration.
upvoted 1 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