Lecture 10 Flashcards

1
Q

Which three things can cause “problems” with your program? Give examples

A
  • The programmer, error in source code
  • The user, giving wrong input (floating-point instead of int)
  • The environment, file not found
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What three types of errors can a “problem” with your program result in? Rank them from worst to least bad.

A

Error in results
Error during execution
Error during compilation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the difference between an exception and an error?

A

Exceptions are usually solvable by the programmer (and should be solved), while errors are irrecoverable (e.g. hardware problems, running out of memory).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What two types of exceptions are there? What is the difference between them?

A

Checked and unchecked exceptions. Java forces you to deal with checked exceptions (so either throw or catch them!)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you create a structure to deal with exceptions?

A

Try { insert code}
catch(exceptionlol e) { insert code}
finally {close your scanner please & insert code}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you create your own exception classes and why would you?

A

You would create your own to be specific about the exception that happened ( you always want to be as specific as possible!) and you do it by creating a class that inherits Exception and creating the methods MyException() and MyException(string s) and implementing them as super() and super(s).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly