COMPSCI 2S03 Lecture Notes - Lecture 18: Opentext

63 views1 pages

Document Summary

> throw # of objects when an error occurs during run time. For example, 1/0 will throw the exception divide by zero . Other examples: e. g. scanner. nextint() and user inputs string, it will break the program and throw an exception. Other examples: e. g. scanner. nextint() and user inputs string, it will break the program and throw an exception e. g. open text file and the file does not exist. Need to throw exceptions to validate data (to make sure the user inputed an int into nextint(), using try and catch) You can handle the exception in calculatespeed or in printspeed() Exceptions are propagated and passed to methods that calls them!

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents