Exam 11: Handling Exceptions and Events
Exam 1: An Overview of Computers and Programming Languages50 Questions
Exam 2: Basic Elements of Java50 Questions
Exam 3: Introduction to Objects and Input/output50 Questions
Exam 4: Control Structures I: Selection50 Questions
Exam 5: Control Structures II: Repetition50 Questions
Exam 6: Graphical User Interface GUI and Object-Oriented Design OOD50 Questions
Exam 7: User-Defined Methods50 Questions
Exam 8: User-Defined Classes50 Questions
Exam 9: Arrays46 Questions
Exam 10: Inheritance and Polymorphism50 Questions
Exam 11: Handling Exceptions and Events50 Questions
Exam 12: Advanced Guis and Graphics48 Questions
Exam 13: Recursion50 Questions
Exam 14: Applications of Arrays Searching and Sorting and Strings50 Questions
Select questions type
To handle window events, if the class containing the application program does not extend the definition of another class, you can make that class extend the definition of the class ____.
(Multiple Choice)
4.8/5
(42)
If you have created an exception class, you can define other exception classes extending the definition of the exception class you created.
(True/False)
4.7/5
(41)
int number;
Boolean done = false;do
{
Try
{
System.out.print("Enter an integer: ");
Number = console.nextInt();
System.out.println();
Done = true;
System.out.println("number = " + number);
}
Catch (InputMismatchException imeRef)
{
Str = console.next();
System.out.println("Exception "
+ imeRef.toString()
+ " " + str);
}
}
While (!done);What is the most likely type of exception in the code in the accompanying figure?
(Multiple Choice)
4.9/5
(37)
When an exception occurs, an object of a particular exception class is created.
(True/False)
4.7/5
(27)
How many finally blocks can there be in a try/catch structure?
(Multiple Choice)
4.7/5
(32)
int number;
Boolean done = false;do
{
Try
{
System.out.print("Enter an integer: ");
Number = console.nextInt();
System.out.println();
Done = true;
System.out.println("number = " + number);
}
Catch (InputMismatchException imeRef)
{
Str = console.next();
System.out.println("Exception "
+ imeRef.toString()
+ " " + str);
}
}
While (!done);How many times will the code in the try block in the accompanying figure execute?
(Multiple Choice)
4.8/5
(27)
An unchecked exception is any exception that causes a program to terminate.
(True/False)
4.8/5
(36)
Statements that might generate an exception are placed in a catch block.
(True/False)
4.8/5
(40)
The class RuntimeException is the superclass of which of the following classes?
(Multiple Choice)
4.8/5
(32)
A checked exception is any exception checked for by the programmer.
(True/False)
4.9/5
(31)
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?
(Multiple Choice)
4.8/5
(45)
The methods getMessage and printStackTrace are private methods of the class Throwable.
(True/False)
4.9/5
(33)
If an exception occurs in a try block and that exception is caught by a catch block, then the remaining catch blocks associated with that try block are ignored.
(True/False)
4.8/5
(41)
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?
(Multiple Choice)
4.7/5
(27)
The JList GUI component generates events that call the actionStateChanged method.
(True/False)
5.0/5
(38)
A message is returned by which method of an Exception object?
(Multiple Choice)
4.8/5
(34)
Showing 21 - 40 of 50
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)