The following example shows how a programmer might avoid a division by zero error by explicitly checking for the error condition:
if(gallonsOfGas != 0)
mpg = milesDriven /gallonsOfGas;
else
mpg = 0;
Another possible way to deal with this is to use exception handling mechanisms.What factors help the programmer decide which of these methods to use?
Correct Answer:
Verified
View Answer
Unlock this answer now
Get Access to more Verified Answers free of charge
Q20: If you are working on a professional
Q21: The StackTrace property of an Exception can
Q22: The ApplicationException class is a sublcass of
Q23: What class should you extend in order
Q24: When creating an Exception class, what is
Q26: The int version of the TryParse() methods
Q27: When you catch an Exception, what property
Q28: The Environment.Exit() method is part of what
Q29: Most exceptions that are used by programmers
Q30: What type of exception is thrown if
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents