Suppose the setRadius method throws the InValidRadiusException defined in Listing 1. What is displayed when the following program is run?
public class Test {
public static void main(String[] args) {
try {
method();
System.out.println("After the method call");
}
catch (RuntimeException ex) {
System.out.println("RuntimeException in main");
}
catch (Exception ex) {
System.out.println("Exception in main");
}
}
static void method() throws Exception {
try {
Circle c1 = new Circle(1);
c1.setRadius(-1);
System.out.println(c1.getRadius());
}
catch (RuntimeException ex) {
System.out.println("RuntimeException in method()");
}
catch (Exception ex) {
System.out.println("Exception in method()");
throw ex;
}
}
}
LISTING 1 InvalidRadiusException.java
1 public class InvalidRadiusException extends Exception {
2 private double radius;
3
4 /** Construct an exception */
5 public InvalidRadiusException(double radius) {
6 super("Invalid radius " + radius);
7 this.radius = radius;
8 }
9
10 /** Return the radius */
11 public double getRadius() {
12 return radius;
13 }
14 }
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.