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();
}
}
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
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.
And forgot to comment, Exceptions need to be declared in the constructor declaration.
upvoted 1 times
...
...
Log in to ExamTopics
Sign in:
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.
jackymak
1 week, 3 days agoTOPPSI
5 months, 1 week agoiSnover
8 months, 1 week agoiSnover
8 months ago