Skip to main content

Exceptions and Assertions

  • Chapter
SCJP Exam for J2SE 5
  • 478 Accesses

Abstract

Errors do happen in a computer program. Generally speaking, there are two kinds of possible errors in a program. One kind happens due to problems originating from the execution environment, such as running out of memory, and is represented in Java by the class Error and its subclasses. The second kind of error, called an exception, happens due to problems originating inside the application itself, and is represented by the class Exception and its subclasses. When an exception happens, either there is code to handle it or it is ignored. If it is ignored, the program terminates. However, Java offers an extensive mechanism to handle exceptions. When an exception happens, the exception propagates, changing the normal execution control flow of the application. In other words, exceptions are the messengers that carry the bad news inside the world of an application. Programmers may use the exception-handling mechanism of Java to write well-behaved, robust Java applications.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

eBook
USD 16.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 39.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Rights and permissions

Reprints and permissions

Copyright information

© 2006 Paul Sanghera, Ph.D.

About this chapter

Cite this chapter

(2006). Exceptions and Assertions. In: SCJP Exam for J2SE 5. Apress. https://doi.org/10.1007/978-1-4302-0173-1_7

Download citation

Publish with us

Policies and ethics