nerdexam
Oracle

1Z0-829 · Question #46

Given: ``java public class StockException extends Exception { public StockException(String s) { super(s); } } public class OutofStockException extends StockException { public…

Sign in or unlock 1Z0-829 to reveal the answer and full explanation for question #46. The question stem and answer options stay visible for context.

Working with Exceptions and Assertions

Question

Given:
public class StockException extends Exception {
 public StockException(String s) { super(s); }
}
public class OutofStockException extends StockException {
 public OutofStockException(String s) { super(s); }
}
and the code fragment:
public class Test {
 public static void main(String[] args) throws OutofStockException {
 m();
 }

 public static void m() throws OutofStockException {
 try {
 throw new StockException("Raised.");
 } catch (Exception e) {
 throw new OutofStockException(e.getMessage());
 }
 }
}
Which statement is true?

Unlock 1Z0-829 to see the answer

You've previewed enough free 1Z0-829 questions. Unlock 1Z0-829 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.

Topics

#custom exceptions#checked exceptions#throws declaration#exception hierarchy
Full 1Z0-829 Practice