How can you tell whether an exception is checked or


1. What RuntimeException, if any, will the following program throw?
class Exception1
{
public static void main(String[] args)
{
int x = 1/0;
}
}

2. How can you tell whether an exception is checked or unchecked? What is required of checked exceptions that is not required of those that are unchecked?

3. What is the output of the following program?
class Exception2
{
public static void main(String[] args)
{
try
{
aMethod();
System.out.println("After the call");
}
catch (ArithmeticException exception)
{
System.out.println("Arithmetic Exception");
}
catch (RuntimeException exception)
{
System.out.println("Runtime Exception");
}
System.out.println("After the try-catch statement");
}
private static void aMethod() throws RuntimeException
{
int x = 1/0;
}
}

What will happen if the order of the catch blocks is reversed?

4. Why won't the following program compile?
class Exception3
{
public static void main(String[] args)
{
if (Integer.parseInt(args[0]) == 0)
throw new Exception("Invalid Command Line Argument");
}
}
Correct it so it will compile.

5. Explain the difference between the keywords throw and throws. When is each used?

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: How can you tell whether an exception is checked or
Reference No:- TGS01090634

Expected delivery within 24 Hours