1/6
Week 6 Topics for MATH 140
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
You use this statement to throw an exception:
try
generate
throw
System.exit(0)
throw
You cannot have more than one catch per try statement
True or False
False
Find the error in the following code segment:
catch (FileNotFoundException e)
{
System.out.println("File not found.");
}
try
{
File file = new File("MyFile.txt");
Scanner inputFile = new Scanner(file);
}No Error
Used a wrong exception
The try block must appear first
no need for { }
The try block must appear first
Look at the following program and tell what it will output when run:
public class ExceptionTest{
public static void main(String[] args){
int number;
String str;
try
{
str = "xyz";
number = Integer.parseInt(str);
System.out.print("A");
}
catch(NumberFormatException e)
{
System.out.print("B");
}
catch(IllegalArgumentException e)
{
System.out.print("C");
}
System.out.print("D");
}
}
ABCD
ABD
AB
BD
BD
This method can be used to retrieve the error message from an exception object
errorMessage
errorString
getMessage
getError
getMessage
This is an internal list of all methods that are currently executing.
invocation list
call stack
call list
list trace
call stack
When in the same try statement you are handling multiple exceptions and some of the exceptions are related to ech other through inheritance, you should handle the more general exception classes before the more specialized exception classes
True or False
False