Mid Term Study Error types + Control Handling Flashcards

1
Q

Explain these exceptions:

IOException

ArrayIndexOutOfBoundsException

ArithmeticException

IllegalArgumentException

InputMismatchException

A

IOException - Input/Output failure like failure to read from a file

ArrayIndexOutOfBoundsException - index not in array

ArithmeticException - Trying to divide by 0 or square root by a negative

IllegalArgumentException - Inappropriate argument passed

InputMismatchException - Incorrect datatype given

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

Name all java primitive datatypes and their bit size

A

byte size 8 bits - For byte size ints
short 16 bits - For short size ints
int 32 bits - for int
long 64 bits - For long size ints
float 32 bits - includes decimals
double 64 bits - includes decimals
char 16 bits - represents a single 16-bit unicode character

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

try/catch syntax?

A

try {
//If an exception is thrown go to the catch
}
catch(ArithmeticException err){
//In this case arithmetic exceptions will be resolved in this catch block
System.out.println(“Error: “ + err);
}

NOTE: Can also use catch(Exception err){} to catch all error types

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