20 terms

Computer Programming:Debugging and Exceptions

STUDY
PLAY
Two possible program states in the debugger?
Running and In-Break
Symbol that marks a breakpoint you have set in the Visual C# IDE?
A red circle
What debugging command would you use to execute a complete statement, including any functions within the statement, without stepping through the details line-by-line?
Step Over
What is a breakpoint?
A place in the code where you want the debugger to pause the program in-break mode
What type of error does the C# language throw when something unexpected happens?
An exception
What debugging command would you execute to make the program resume running from the
current point?
Run or Continue
What two keywords are used to handle any possible errors in a program?
Try and Catch
What property on the System.Exception object contains a description of the error?
Message
When might exception handling code be particularly useful in a program?
If you have a block of code that is risky, complicated, or subject to bad input data
What is a "watch" and what is it used for?
A watch is a way to examine a variable's value while debugging
When your program is paused in the debugger, the line with the arrow on it is the:
next line that will be executed.
What is the most useful state for debugging a program?
In-Break
Consider the following code:
String myString = "12";
double myNumber = myString;
What kind of error or exception will be generated?
A compiler error, caused by a type mismatch
TRUE/FALSE
When an exception is thrown, all remaining code statements in that block are skipped.
TRUE
How can language and reference material help you find errors in your code?
These materials will allow you to double-check the syntax and format of different methods.
How does a code review help to pinpoint errors in your code?
A code review will examine your code line-by-line, looking to make sure the code makes sense, is formatted correctly and produces expected results.
How can program tracing help you to locate errors in your program?
Program tracing uses very verbose output to tell you where your program is executing within the source code.
Consider the following code:
Console.WriteLine("step 1"); // step 1 code here Console.WriteLine("step 2"); // step 2 code here Console.WriteLine("step 3"); // step 3 code here Console.WriteLine("step 4"); // step 4 code here
If at runtime you see the following output, which step threw an exception?
step 1 step 2 step 3
Step 3
What is the most likely type of exception the following code might throw?
int mystery(String input)
{
return input.Length;
}
NullReferenceException
What is the most likely type of exception that could be thrown from the following function?
String mystery(String[] input)
{
if (input != null)
return input[1];
else return "";
}
IndexOutOfRangeException
YOU MIGHT ALSO LIKE...