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+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents