Saturday 15 March 2014

Java : Unknown error in exception handling -



Java : Unknown error in exception handling -

i have weird question. had quiz in class today. 1 portion of quiz find , right errors in short piece of code. 1 of questions this

class illustration { public static void main(string[] args) { seek { system.out.println("xyz"); } grab (exception e) { system.out.println("exception caught"); } { system.out.println("abc"); } } }

i thought there no error in programme professor insisted there was. can guess error is?

the "error" may don't need handle exception here: system.out.println not specify checked exception. be:

public static void main(string[] args) { system.out.println("xyz"); }

since exception class covers both checked , unchecked exceptions, if add together catch block here, in case handling unchecked exceptions, should not handle.

java exception exception-handling

No comments:

Post a Comment