MATH 140 Exceptions

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/6

flashcard set

Earn XP

Description and Tags

Week 6 Topics for MATH 140

Last updated 6:39 AM on 4/14/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

7 Terms

1
New cards

You use this statement to throw an exception:

try

generate

throw

System.exit(0)

throw

2
New cards

You cannot have more than one catch per try statement

True or False

False

3
New cards

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

4
New cards

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

5
New cards

This method can be used to retrieve the error message from an exception object

errorMessage
errorString
getMessage
getError

getMessage

6
New cards

This is an internal list of all methods that are currently executing.

invocation list
call stack
call list
list trace

call stack

7
New cards

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