Skip to content

Instantly share code, notes, and snippets.

@ozkansari
Forked from anonymous/QuizException.java
Last active December 11, 2015 03:18
Show Gist options
  • Save ozkansari/4536819 to your computer and use it in GitHub Desktop.
Save ozkansari/4536819 to your computer and use it in GitHub Desktop.
/**
* What is printed to standard output ?
*
* a) "NullPointerException thrown"
* b) "Exception thrown"
* c) "Done with exceptions"
* d) "checkResult is done"
* e) None of the above
*
*/
void checkResult(String result) {
try {
String expected = null;
if(expected.equals(result)){
System.out.println( "Success" );
}
} catch( NullPointerException npex ) {
System.out.println( "NullPointerException thrown " );
} catch( Exception ex ) {
System.out.println( "Exception thrown " );
} finally {
System.out.println( "Done with exceptions " );
return;
}
System.out.println( "checkResult is done" );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment