lecture-27 - Throwing Exceptions An exception is thrown...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
Object Oriented Programming Java - Exceptions & Assertions R.B. Lenin Winter 2006 DA-IICT 22 Throwing Exceptions An exception is thrown using the throw statement. throw <a throwable object> where <a throwable object> is an instance of the Throwable class or its subclasses.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Object Oriented Programming Java - Exceptions & Assertions R.B. Lenin Winter 2006 DA-IICT 23
Background image of page 2
Object Oriented Programming Java - Exceptions & Assertions R.B. Lenin Winter 2006 DA-IICT 24
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Object Oriented Programming Java - Exceptions & Assertions R.B. Lenin Winter 2006 DA-IICT 25 e.getMessage( )
Background image of page 4
Object Oriented Programming Java - Exceptions & Assertions R.B. Lenin Winter 2006 DA-IICT 26 Throwing Exceptions When there are multiple catch blocks in a try-catch statement, they are checked in sequence. It is important to check more specialized exception classes before the more general exception classes.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Java - Exceptions & Assertions R.B. Lenin Winter 2006 DA-IICT 27 Throwing Exceptions try { } catch (Exception e) { } catch (NumberFormatException e) { } Then the second catch block will never be executed because any exception object that is an instance of Exception or its subclasses will match the first catch block. Java compiler will complain and will stop continuing further.
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/15/2010 for the course CSE IT115 taught by Professor Rblenin during the Spring '10 term at Punjab Engineering College.

Page1 / 18

lecture-27 - Throwing Exceptions An exception is thrown...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online