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
During program execution, if division by zero occurs with integer values and is not addressed by the program, then the program terminates with an error message indicating an attempt to divide by zero.
(True/False)
4.8/5
(44)
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?
(Multiple Choice)
4.8/5
(20)
Which of the following is NOT a typical action of the catch block?
(Multiple Choice)
4.9/5
(33)
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);Which exception-handling technique is the code in the accompanying figure using?
(Multiple Choice)
4.9/5
(27)
The order in which catch blocks are placed in a program has no impact on which catch block is executed.
(True/False)
4.8/5
(45)
Which of the following statements is NOT true about creating your own exceptions?
(Multiple Choice)
4.8/5
(41)
The try block contains statements that should be executed regardless of whether or not an exception occurs.
(True/False)
4.8/5
(38)
If you have a reference to an exception object, you can use the reference to throw the exception.
(True/False)
4.8/5
(43)
Showing 41 - 50 of 50
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)