Novata09 de Enero del 2006
PreguntaHola!
Alguien me puede ayudar.Me dan un código y debo decir la salida por pantalla. Mi gran duda es si sale "X" o no.La cosa es que he intentado de mil maneras que se ejecute pero no lo consigo.
class Pruebas {
public static void main(String args[]) {
try {
f();
} catch (InterruptedException e) {
System.out.print("A");
throw new RuntimeException();
} catch (RuntimeException e) {
System.out.print("B");
return;
} catch (Exception e) {
System.out.print("C");
return;
} finally {
System.out.print("D");
}
System.out.print("Z");
}
// InterruptedException es subclase de Exception
static void f() throws InterruptedException {
throw new InterruptedException("X");
}
}
Alguien me puede ayudar.Me dan un código y debo decir la salida por pantalla. Mi gran duda es si sale "X" o no.La cosa es que he intentado de mil maneras que se ejecute pero no lo consigo.
class Pruebas {
public static void main(String args[]) {
try {
f();
} catch (InterruptedException e) {
System.out.print("A");
throw new RuntimeException();
} catch (RuntimeException e) {
System.out.print("B");
return;
} catch (Exception e) {
System.out.print("C");
return;
} finally {
System.out.print("D");
}
System.out.print("Z");
}
// InterruptedException es subclase de Exception
static void f() throws InterruptedException {
throw new InterruptedException("X");
}
}
