Errors, exceptions and debugging Flashcards

1
Q

Three main types of errors

A

Syntax
Runtime
Logic

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Exception/run time errors

A

Occurs during execution of program and if not handled can crash the program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Logical error

A
  • Most difficult to detect
  • Program works but gives unexpected results
How well did you know this?
1
Not at all
2
3
4
5
Perfectly