Chapter 9 - Debugging – what goes wrong and how to fix it Flashcards

1
Q

describe
regression errors

A

An error found in older code when developing new code.

this can occur when legacy code does not work with new data or was never properly tested to begin with.

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

decsribe
Compilation errors

A

An error detected by acompilerwhen code iscompiled.

Nobytecode (.class)is generated if these are present.

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

describe
IndexOutOfBoundsException

A

created when we try and access an index that is out of bounds such as on an ArrayList

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

What are the
basic format specifiers
in formatting strings?

A

these include:
1. %c for a Unicode character
2. %d for an integer
3. %e for scientific notation
4. %f for a decimal (floating-point) number
5. %s for a string
6. %x for hexadecimal numbers.

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

what are 4 ways to
test input and output data

A

methods include:
1. documenting
2. positive testing
3. negative testing
4. boundary testing

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

What is a
Template String
in formatting strings?

A

this is a string that contains format specifiers, where the format specifiers will be replaced by a given input and will follow the rules of the format specifier.

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

describe
Syntax Error

A

An error that occurs when the source code does not follow the syntax rules of the programming language.

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

describe the debugging method
Manual Walkthrough

A

A process of going through a section of code line by line to understand how each line affects the state of the object or other parts of the application.

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

describe
positive testing

A

Using known and valid inputs to check that code produces expected outputs.

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

think of 4 possible fixes for the
“Cannot Find Symbol” Error

A

fixes for this error inclue:
1. Fix the spelling of the variable name.
2. Add a local variable to a method or constructor.
3. Add a parameter to a method or constructor.
4. Add a field to the class.

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

describe
NumberFormatException

A

created to indicate that a method that converts a string to one of the numeric types has been passed an argument with an inappropriate format

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

these include:
1. %c for a Unicode character
2. %d for an integer
3. %e for scientific notation
4. %f for a decimal (floating-point) number
5. %s for a string
6. %x for hexadecimal numbers.

A

What are the
basic format specifiers
in formatting strings?

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

describe
StackOverflowError

A

created when a program repeatedly calls methods until there is no stack space left to store the state of all the method invocations.

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

these include:
1. System.out.printf()
2. String.format()

A

which two
options are available in java to format strings

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

describe
Semantic Error

A

An error that is caused by violating higher-level relationships between parts of code, rather than incorrect syntax.

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

methods include:
1. documenting
2. positive testing
3. negative testing
4. boundary testing

A

what are 4 ways to
test input and output data

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

describe
NullPointerException

A

created when you try to call a method using a reference variable whose value isnull

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

what are 2 approaches that try and
prevent the misuse of code by programmers

A

two approaches that prevent this are:
1. Design by Contract
2. Defensive Code

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

fixes for this error inclue:
1. Fix the spelling of the variable name.
2. Add a local variable to a method or constructor.
3. Add a parameter to a method or constructor.
4. Add a field to the class.

A

think of 4 possible fixes for the
“Cannot Find Symbol” Error

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

Errors that only become apparent when a program is run, and have not been detected beforehand.

theseerrors can be caused by logical errors or conditions outside of the control of the programmer.

A

describe
Runtime errors

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

describe
Boundary Testing

A

Testing with values at and near the extreme values of data fields and collection sizes.

can prevent an error known as an “off-by-one error”

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

ignore

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

think of 6 possible examples
semantic errors

A

examples of this include:
1. Unreachable statements: return x + y; y++;
2. Using an incompatible type of argument in a method call
3. Using an incompatible type of operand with an operator
4. Failing to initialize a local variable before it is first used.
5. Return types not defined correctly
6. Missing variables

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

points include:
1. Occur during the execution of the bytecode
2. Can occur soon after execution or go unnoticed for years
3. Can be detected by JVM or programmer, but some may not signal their presence
4. Result from logical errors, misuse of library code, or failure to take into account software usage
5. May also occur due to reasons out of the programmer’s control such as deleted files, internet failure, JVM failure, or timing errors with the larger system.

A

think of 5 points about
runtime errors

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
An error that occurs when the source code does not follow the syntax rules of the programming language.
describe **Syntax Error**
26
this is a string within a template string that defines rules of how it will be replaced by a variable.
What is a **Format Specifier** in formatting strings?
27
this is a string that contains format specifiers, where the format specifiers will be replaced by a given input and will follow the rules of the format specifier.
What is a **Template String** in formatting strings?
28
An error found in older code when developing new code. this can occur when legacy code does not work with new data or was never properly tested to begin with.
describe **regression errors**
29
what are two common **compile time errors**
these include: 1. syntax errors 2. semantic errors
30
A method of locating a bug by gradually narrowing down its source using print statements.
describe the debugging method **Wolf Fencing**
31
give 3 examples of **syntax errors**
examples of this include: 1. **Wrong order of tokens:** `new ArrayList()<>;` 2. **Missing tokens:** `hello world"; or int x = 55` 3. **Mismatched tokens:** `int y = (10 / 2) * (3 + 4) + 6);`
32
Using known invalid inputs to check that the code responds appropriately.
describe **Negative Testing**
33
describe a **logical error**
Result in incorrect behavior of the program due to incorrect implementation by the programmer.
34
Result in incorrect behavior of the program due to incorrect implementation by the programmer.
describe a **logical error**
35
think of 5 points about **runtime errors**
points include: 1. Occur during the execution of the bytecode 2. Can occur soon after execution or go unnoticed for years 3. Can be detected by JVM or programmer, but some may not signal their presence 4. Result from logical errors, misuse of library code, or failure to take into account software usage 5. May also occur due to reasons out of the programmer's control such as deleted files, internet failure, JVM failure, or timing errors with the larger system.
36
describe **ArithmeticException**
created when an exceptional arithmetic condition has occurred for example, when division by zero has occurred
37
examples of this include: 1. incorrect if statement 2. assigning incorrect value to a variable 3. incorrect argument value 4. incorrect value returned from a method 5. incorrect expression calculation.
try and think of 5 examples of a **logical error**
38
try and think of 5 examples of a **logical error**
examples of this include: 1. incorrect if statement 2. assigning incorrect value to a variable 3. incorrect argument value 4. incorrect value returned from a method 5. incorrect expression calculation.
39
An error that is caused by violating higher-level relationships between parts of code, rather than incorrect syntax.
describe **Semantic Error**
40
describe **Design by Contract**
A concept that requires programmers to follow a "contract" of only using valid arguments to prevent errors and unexpected behavior. if the programmer does not comply then it is there fault for any errors
41
What is a **Format Specifier** in formatting strings?
this is a string within a template string that defines rules of how it will be replaced by a variable.
42
A process of going through a section of code line by line to understand how each line affects the state of the object or other parts of the application.
describe the debugging method **Manual Walkthrough**
43
examples of this include: 1. Unreachable statements: return x + y; y++; 2. Using an incompatible type of argument in a method call 3. Using an incompatible type of operand with an operator 4. Failing to initialize a local variable before it is first used. 5. Return types not defined correctly 6. Missing variables
think of 6 possible examples **semantic errors**
44
describe **Runtime errors**
Errors that only become apparent when a program is run, and have not been detected beforehand.  these errors can be caused by logical errors or conditions outside of the control of the programmer.
45
An error detected by a compiler when code is compiled. No bytecode (.class) is generated if these are present.
decsribe **Compilation errors**
46
created when an exceptional arithmetic condition has occurred for example, when division by zero has occurred
describe **ArithmeticException**
47
describe an **Off-by-One Error**
A logical error in which code is off by one unit example: a comparison operator that checks "<" when "<=" was required
48
created to indicate that a method that converts a string to one of the numeric types has been passed an argument with an inappropriate format
describe **NumberFormatException**
49
these include: 1. syntax errors 2. semantic errors
what are two common **compile time errors**
50
describe the debugging method **Wolf Fencing**
A method of locating a bug by gradually narrowing down its source using print statements.
51
which two **options are available in java to format strings**
these include: 1. System.out.printf() 2. String.format()
52
An approach that attempts to prevent errors and unexpected behavior through misuses.
describe **Defensive Code**
53
the rule for this is: "the number and type of the format specifiers must match the argument values given"
what is the rule for when multiple format specifiers are used in a string template
54
two approaches that prevent this are: 1. Design by Contract 2. Defensive Code
what are 2 approaches that try and **prevent the misuse of code by programmers**
55
describe StringIndexOutOfBoundsException
created when a program tries to access a part of a string using an index outside the string’s limits
56
examples of this include: 1. **Wrong order of tokens:** `new ArrayList()<>;` 2. **Missing tokens:** `hello world"; or int x = 55` 3. **Mismatched tokens:** `int y = (10 / 2) * (3 + 4) + 6);`
give 3 examples of **syntax errors**
57
describe **Negative Testing**
Using known invalid inputs to check that the code responds appropriately.
58
when performing this: 1. Consider printing hard copies of the code and walking away from the computer 2. Make notes about what each line of code is doing 3. Don't delve into method calls until you've noted the current line of code
what 3 things should be kept in mind when performing a **manual walkthrough**
59
what is the rule for when multiple format specifiers are used in a string template
the rule for this is: "the number and type of the format specifiers must match the argument values given"
60
A logical error in which code is off by one unit example: a comparison operator that checks "<" when "<=" was required
describe an **Off-by-One Error**
61
Using known and valid inputs to check that code produces expected outputs.
describe **positive testing**
62
created when a program tries to access a part of a string using an index outside the string’s limits
describe StringIndexOutOfBoundsException
63
Testing with values at and near the extreme values of data fields and collection sizes. can prevent an error known as an "off-by-one error"
describe **Boundary Testing**
64
describe the **"Cannot Find Symbol" Error**
this is an error that occurs when a variable identifier is not found.
65
this is an error that occurs when a variable identifier is not found.
describe the **"Cannot Find Symbol" Error**
66
describe **ArrayIndexOutOfBoundsException**
created when a program tries to access an array with an index outside the array’s limits
67
what 3 things should be kept in mind when performing a **manual walkthrough**
when performing this: 1. Consider printing hard copies of the code and walking away from the computer 2. Make notes about what each line of code is doing 3. Don't delve into method calls until you've noted the current line of code
68
created when a program repeatedly calls methods until there is no stack space left to store the state of all the method invocations.
describe **StackOverflowError**
69
A concept that requires programmers to follow a "contract" of only using valid arguments to prevent errors and unexpected behavior. if the programmer does not comply then it is there fault for any errors
describe **Design by Contract**
70
created when you try to call a method using a reference variable whose value is null
describe **NullPointerException**
71
created when we try and access an index that is out of bounds such as on an ArrayList
describe **IndexOutOfBoundsException**
72
created when a program tries to access an array with an index outside the array’s limits
describe **ArrayIndexOutOfBoundsException**
73
describe **Defensive Code**
An approach that attempts to prevent errors and unexpected behavior through misuses.