Errors, exceptions and debugging Flashcards
1
Q
Three main types of errors
A
Syntax
Runtime
Logic
2
Q
How are syntax errors checked
A
Java compiler checks syntax before generating bytecode. If there are any syntax errors the bytecode is not generated and compiler tries to identify error
3
Q
Syntax error examples
A
- Capital letters
- Incompatible type assignments
- Missing semicolon, brackets
- Using variable without declaration or initialisation
- Using a class/function not in language without import
- Missing operator/operand in expression
4
Q
Exception/run time errors
A
Occurs during execution of program and if not handled can crash the program
5
Q
exception/run time error examples
A
- division of 0
- method call to take integer input but double or char is entered
- accessing array beyond limit
- trying to read a file where file does not exist
6
Q
Logical error
A
- Most difficult to detect
- Program works but gives unexpected results