Question 11 Which of the following is NOT a method of the class Throwable? getMe
ID: 3823570 • Letter: Q
Question
Question 11
Which of the following is NOT a method of the class Throwable?
getMessage
throwMessage
printStackTrace
toString
1 points
Question 12
import java.util.*;
public class ExceptionExample1
{
static Scanner console = new Scanner(System.in);
public static void main(String[] args)
{
int dividend, divisor, quotient;
try
{
System.out.print("Enter dividend: ");
dividend = console.nextInt();
System.out.println();
System.out.print("Enter divisor: ");
divisor = console.nextInt();
System.out.println();
quotient = dividend / divisor;
System.out.println("quotient = " + quotient);
}
catch (ArithmeticException aeRef)
{
System.out.println("Exception" + aeRef.toString());
}
catch (InputMismatchException imeRef)
{
System.out.println("Exception "
+ imeRef.toString());
}
catch( IOException ioeRef)
{
System.out.println("Exception "
+ ioeRef.toString());
}
}
}
Which of the following will cause the first exception to occur in the code in the accompanying figure?
If the divisor is zero
If the dividend is zero
If the quotient is zero
This code will not compile, so an exception cannot be triggered.
1 points
Question 13
import java.util.*;
public class ExceptionExample1
{
static Scanner console = new Scanner(System.in);
public static void main(String[] args)
{
int dividend, divisor, quotient;
try
{
System.out.print("Enter dividend: ");
dividend = console.nextInt();
System.out.println();
System.out.print("Enter divisor: ");
divisor = console.nextInt();
System.out.println();
quotient = dividend / divisor;
System.out.println("quotient = " + quotient);
}
catch (ArithmeticException aeRef)
{
System.out.println("Exception" + aeRef.toString());
}
catch (InputMismatchException imeRef)
{
System.out.println("Exception "
+ imeRef.toString());
}
catch( IOException ioeRef)
{
System.out.println("Exception "
+ ioeRef.toString());
}
}
}
Which of the following inputs would be caught by the second catch block in the program in the accompanying figure?
0
10
h3
-1
1 points
Question 14
Which of the following is NOT a typical action of the catch block?
Completely handling the exception
Partially processing of the exception
Rethrowing the same exception for the calling environment
Throwing the exception
1 points
Question 15
What happens in a method if there is an exception thrown in a try block but there is no catch block following the try block?
The program ignores the exception.
The program will not compile without a complete try/catch structure.
The program terminates immediately.
The program throws an exception and proceeds to execute the finallyblock.
1 points
Question 16
Which of the following exceptions might be thrown by the methods of the class String?
NullPointerException
FileNotFoundException
NoSuchElementsException
NumberFormatException
1 points
Question 17
How many finally blocks can there be in a try/catch structure?
There must be one finally block.
There can be one finally block following each catch block.
There can be zero or one finally blocks following the last catch block.
There is no limit to the number of finally blocks following the last catchblock.
1 points
Question 18
The class RuntimeException is the superclass of which of the following classes?
NullPointerException
NoSuchMethodException
IllegalAccessException
NoSuchFileException
1 points
Question 19
Which of the following statements is true?
The class Exception, which is derived from the class Object, is the superclass of the class Throwable.
The class Throwable, which is derived from the class Exception, is the superclass of the class Object.
The class Throwable, which is derived from the class Object, is the superclass of the class Exception.
None of these
1 points
Question 20
import java.util.*;
public class ExceptionExample1
{
static Scanner console = new Scanner(System.in);
public static void main(String[] args)
{
int dividend, divisor, quotient;
try
{
System.out.print("Enter dividend: ");
dividend = console.nextInt();
System.out.println();
System.out.print("Enter divisor: ");
divisor = console.nextInt();
System.out.println();
quotient = dividend / divisor;
System.out.println("quotient = " + quotient);
}
catch (ArithmeticException aeRef)
{
System.out.println("Exception" + aeRef.toString());
}
catch (InputMismatchException imeRef)
{
System.out.println("Exception "
+ imeRef.toString());
}
catch( IOException ioeRef)
{
System.out.println("Exception "
+ ioeRef.toString());
}
}
}
Which method throws the second exception in the code in the accompanying figure?
nextInt
toString
println
nextLine
getMessage
throwMessage
printStackTrace
toString
Explanation / Answer
11)
throwMessage
12)
If the divisor is zero
13)
h3
14)
Partially processing of the exception
15)
The program throws an exception and proceeds to execute the finallyblock.
16)
NullPointerException
17)
There must be one finally block.
18)
NullPointerException
19)
The class Throwable, which is derived from the class Object, is the superclass of the class Exception.
20)
nextInt
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.