Debugging and Errors Flashcards
This is an illegal operation performed by the user which results in the abnormal working of the program.
Error
This are often remain undetected until the program is compiled or executed.
Programming Errors
True or False:
Some of the errors inhibit the program from getting compiled or executed.
True
True or False:
Errors should be removed before compiling and executing
True
This occur or we can say, are detected during the execution of the program.
Run Time Error
A Runtime Error can be discovered when the user enters an _______
Invalid Data
This occur when a program does not contain any syntax errors but asks the computer to of something that the computer is unable to reliable do.
Runtime Error
True or False:
During compilation, the compiler has no technique to detect a Runtime Error
True
What is the meaning of JVM?
Java Virtual Machine
This can detects the Runtime Error while the program is running.
Java Virtual Machine
How to handle the Runtime Error during a runtime?
Put the error code inside the try block and catch the error inside the catch block.
How to know if you are having a runtime error?
- if the user inputs a data of string format when the computer is expecting an integer, there will be a runtime error.
- Assigning/Retrieving Value from an array using an index which is greater than the size of the array
These are those errors which prevent the code from running, because of an incorrect syntax such as a missing semicolon at the end of a statement or a missing bracket, class not found, etc.
Compile Time Error
How can a Compile Time Error detected?
By the Java Compiler and an error message is displayed on the screen while compiling.
Compile Time Errors are sometimes also referred to as ____
Syntax Errors
These kind of errors are easy to spot and rectify, because the java compiler finds them for you.
Compile Time Error
This will tell you which piece of code in the program got in trouble and its best guess as to what you did wrong.
The Compiler
True or False:
The Compiler indicates the exact line where the error is, or sometimes the line just before it.
True, but if the problem is with incorrectly nested braces, the actual error may be at the beginning of the block. In effect, syntax errors represent grammatical errors in the use of the programming language.
What are the examples of Compile Time Error?
- Misspelled Variable name or Method Names
- Missing Semicolons
- Missing parenthesis, square brackets, or curly braces
This is when your program compiles and executes, but does the wrong thing or returns an incorrect result or no output when it should be returning an output.
Logical Error
True or False:
These errors are detected neither by the compiler nor by JVM.
True
True or False:
The Java system has no idea what your program is supposed to do, so it provides no additional information to help you find the error.
True
What are the examples of Logical Error?
- Accidentally using an incorrect operator on the variables to perform an operation
- Displaying the wrong message
These statements are called loops, and are used to repeat the same code multiple times in succession.
Repetition Statements
True or False:
The number of repetitions is based on criteria defined in the loop structure, usually a true/false expression
True
What are the three loop structures in Java?
- While Loops
- Do-while Loops
- For Loops
This is a test condition that is evaluated to decide whether the loop should repeat or not.
Boolean Expression
In a Boolean expression, this means run the loop body again.
True
In a Boolean expression, this means quit.
False
These both follow the same basic flowchart.
While and Do-While Loop
The only exception in this loop is that the test expression is checked first
While Loop
The only exception in this loop is that the loop “body” is executed first
Do-while Loop
This is the most convenient with counting loops. This loops are based on a counting variable, usually a known number of iterations.
For loop