What are the three main types of programming errors?
Syntax errors, runtime errors, and logic errors.
Define a syntax error.
A syntax error is a mistake in the code's grammar or structure, such as a missing semicolon or misspelled keyword, which prevents the program from running.
Define a runtime error.
A runtime error occurs while the program is running, such as division by zero or trying to access a file that doesn't exist, causing the program to crash or halt.
Define a logic error.
A logic error is a mistake in the program's algorithm or reasoning, causing it to produce incorrect results without crashing.
Why is reading error messages important?
Error messages provide clues about the type and location of a problem, helping programmers identify and fix errors more efficiently.
What is normal data in testing?
Normal data is typical, valid input that the program is expected to handle correctly.
What is boundary data in testing?
Boundary data is input at the edges of acceptable ranges, such as the minimum or maximum values, to test how the program handles limits.
What is erroneous data in testing?
Erroneous data is invalid or unexpected input that the program should handle gracefully, such as rejecting it with an error message.
What is tracing in debugging?
Tracing involves stepping through code line by line or adding print statements to track the program's execution and variable values to find where things go wrong.
What is a debugger?
A debugger is a software tool that allows programmers to monitor program execution, set breakpoints, stop and restart the program, and inspect or change memory values.
What is a breakpoint?
A breakpoint is a marker set in a debugger that pauses program execution at a specific line so the programmer can inspect the state.
What is the origin of the term 'bug' in computing?
The term 'bug' was popularized by Grace Hopper when a moth was found in a relay of the Mark II computer, though the term was used earlier by Edison.
What is the difference between a syntax error and a logic error?
A syntax error prevents the program from running due to incorrect grammar, while a logic error allows the program to run but produces wrong results.
Why might a programmer use static code analysis tools?
Static code analysis tools scan source code for known problems without running it, helping to detect issues like using a variable before it is assigned.
What is a false positive in static code analysis?
A false positive is when the tool flags correct code as potentially erroneous, which can be misleading.
What is the purpose of testing with boundary data?
Boundary testing checks how the program handles values at the edges of input ranges, which often reveal off-by-one or overflow errors.
What is the purpose of testing with erroneous data?
Erroneous data testing ensures the program handles invalid input gracefully, such as showing an error message rather than crashing.
What is the first step in debugging?
The first step is to reproduce the problem consistently so you can observe the error and begin investigating its cause.
What does 'tracing' mean in the context of debugging?
Tracing means following the flow of execution and tracking variable values to pinpoint where the program deviates from expected behavior.
What is a runtime error example?
A runtime error example is dividing by zero, which causes the program to crash during execution.
What is a logic error example?
A logic error example is using the wrong formula to calculate area, so the program runs but gives incorrect results.
Why is it important to test with a variety of data?
Testing with normal, boundary, and erroneous data helps uncover different types of errors and ensures the program is robust.
What is the role of error messages in debugging?
Error messages provide specific information about the error type and location, guiding the programmer to the source of the problem.
What is the difference between a debugger and a static analysis tool?
A debugger runs the program and allows interactive inspection, while a static analysis tool examines the code without executing it.