public class Tigers { public static void main( String args[] ) { try { petfood1(
ID: 3548520 • Letter: P
Question
public class Tigers {
public static void main( String args[] )
{
try { petfood1(); }
catch ( CatException e ) {
System.err.println( e.getMessage() + " The stack trace is:" );
e.printStackTrace();
}
}
public static void petfood1() throws Exception {
petfood2();
}
public static void petfood2() throws Exception {
petfood3();
}
public static void petfood3() throws Throwable {
throw new CatException();
}
}
class CatException extends Exception {
public CatException() {
super( "user defined exception." );
}
}
Explanation / Answer
Tigers.java:4: error: unreported exception Exception; must be caught or declared to be thrown try { petfood1 (); } ^ Tigers.java:14: error: unreported exception Throwable; must be caught or declared to be thrown petfood3(); ^ 2 errors
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.