Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
14Activity
0 of .
Results for:
No results containing your search query
P. 1
Chapter 4 Multi Threading and Exception Handling

Chapter 4 Multi Threading and Exception Handling

Ratings: (0)|Views: 1,275 |Likes:
Published by smrt007

More info:

Published by: smrt007 on Nov 07, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

08/07/2013

pdf

text

original

 
Chapter 4 Exceptions and MultithreadingJava Programming (9113) by T. B. Kute
1
Chapter 4- Exceptions and Multithreading
Marks Allotted: 16Lectures: 08Semester Pattern:Exam: Winter 2008 Summer 2009Marks: 28 20Yearly Pattern (JPR-IF 1526):Exam: S’04 W’04 S’05 W’05 S’06 W’06 S’07Marks: 24 08 24 20 20 28 16Syllabus Contents:4.1
 
Multi Threading
Creating Thread, Extending a thread class, Stopping andBlocking a thread, Life cycle of thread, Using thread method,Thread exceptions, Thread priority, Synchronization,Implementing a ‘Runnable’ Interface.
4.2 Managing Errors and Exceptions
Types of errors, Exception, Multiple catch statement, usingfinally statement, Using Exception for Debugging.
 
Chapter 4 Exceptions and MultithreadingJava Programming (9113) by T. B. Kute
2
Exceptions
 
Exception is a condition that is caused by run-time error in theprogram. In computer programming languages that do not supportexception handling, errors must be checked and handled manuallythrough the use of error codes, and so on. But this approach iscumbersome as well as troublesome. Java’s exception handling avoidsthese problems and, in the process and brings run-time errormanagement into the object-oriented world. C++ programming languagesupports exception handling but Java has enhanced some of its features.As Java is strictly object oriented, an exception is also an objectthat describes an exceptional (that is, error) condition that has occurredin a piece of source code. When an exceptional condition arises inprogram, an object representing that exception is created and thrown inthe method that caused the error. That method may choose to handle theexception itself, or pass it on. Exceptions can be generated by the Javarun-time system, or they can be manually generated by our code.Exceptions thrown by Java relate to fundamental errors that violate therules of the Java language or the constraints of the Java executionenvironment. Manually generated exceptions are typically used to reportsome error condition to the caller of a method.The purpose of exception handling mechanism is to provide ameans to detect and to report exceptional circumstances so thatappropriate action can be taken. The mechanism suggests incorporationof separate error handling code that performs following tasks:
 
Find the problem
 
Inform about error has occurred
 
Receive the error information
 
Take the corrective actionJava’s exception handling mechanism provides every step to beimplemented.
Types of Exceptions
All exception types in Java are subclasses of the built-in abstractclass java.lang.Throwable. Thus, Throwable is at the top of the exceptionclass hierarchy. There are two subclasses that partition exceptions intotwo distinct categories. That is Exception and Error. First category isException. This class is used for exceptional conditions that userprograms should catch. This is also the class that we will subclass tocreate our own exception types.There is an important subclass of Exception, calledRuntimeException. Exceptions of this type are automatically defined forthe programs that we write and include things such as division by zeroand invalid array indexing. Second category of exceptions is Error, whichdefines exceptions that are not expected to be caught under normalcircumstances by the program. Exceptions of type Error are used by the
 
Chapter 4 Exceptions and MultithreadingJava Programming (9113) by T. B. Kute
3
Java run-time system to indicate errors having to do with the run-timeenvironment, itself. Stack overflow is an example of such an error.
Partial exception class hierarchyException
The class Exception represents exceptions that a program wouldwant to be made aware of during execution. Its subclassRuntimeException represents many common programming errors thatmanifest at runtime. Other subclasses of the Exception class define othercategories of exceptions, for example, I/O-related exceptions(IOException, FileNotFoundException, EOFException) and GUI-relatedexceptions (AWTException). Remember here IOException is subclass of Exception which is defined in package java.io.
Throwable
ErrorExceptionAssertionErrorClassNotFoundExceptionRuntimeExceptionNullPointerExceptionArithmeticExceptionIllegalArgumentExceptionNumberFormatExceptionIndexOutOfBoundsExceptionArrayIndexOutOfBoundsExceptionIOExceptionEOFException
java.io java.lang

Activity (14)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
Neeraj Chaudhary liked this
tulsiparikh liked this
Emad Istanbuli liked this
Ricoh Love liked this
rajaramansuresh liked this
Murali Venkat liked this
gopalg liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->