






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







Program Errors
Compile-time (syntax) errors Run-time errors Logic errors
Program Errors โ Compile Time
Errors in code construction Lexical (typographical), grammatical, types Detected during compilation Usually easy to correct quickly
Misspelled keyword Missing or misplaced symbol Incorrect operator for variable type
Java Review Topics
Exceptions
Division by zero Access past end of array Out of memory Number input in wrong format (float vs. integer) Unable to write output to file Missing input file
Exception Handling โ Throw Exception
Throw exception
if (error) throw new ExceptionType(); } B( ) { try { A( ); } catch (ExceptionType e) { ...action... } }
Java exception backtracks to caller(s) until matching catch block found
Representing Exceptions in Java
Objects derived from class Throwable
public class Throwable( ) extends Object { Throwable( ) // No error message Throwable( String mesg ) // Error message String getMessage() // Return error mesg void printStackTrace( ) { โฆ } // Record methods โฆ // called & location }
Exceptions โ Examples
Request to open file fails
Method passed illegal / inappropriate argument
Generic I/O error
Attend to access object using null reference
Object does not provide requested operation
Java Review Topics
Debugging
After testing detects error
Determine cause of run-time & logic errors Correct errors (without introducing new errors)
Carefully inspect information in program Code Values of variables Program behavior
Debugging โ Approaches
Insert debugging statements Trace program control flow Display value of variables
IDE (integrated development environment) Interactive debugger
Interactive Debugger
Specify location(s) in code Execute program until breakpoint encountered Can skip past uninteresting code