Considere as seguintes classes Java, que ocupam arquivos public class Err01 extends Exception { public Err01() { } public Err01(String m) { super(m); } } public class Err02 extends Err01 { public Err02() { } public Err02(String m) { super(m); } } Qual classe NÃO produzirá erros de compilação?
- A public class Main { public double m01(double a, double b) { try { if(a < 0) throw new Err01(); if(b < 0) throw new Err02(); if(b == 0) throw new Exception(); } catch(Err01 e) { System.out.println("a menor do que zero"); } return a / b; } public static void main(String[] args) throws Exception { Main m=new Main(); System.out.println( m.m01 (8.0, 4.0) ); } } separados:
- B public class Main { public double m01(double a, double b) { try { if(a < 0) throw new Err01(); if(b <= 0) throw new Err02(); } catch(Err02 e) { System.out.println("b menor ou igual } return a / b; } public static void main(String[] args) throws Exception { Main m=new Main(); System.out.println( m.m01 (8.0, 4.0) ); } }
- C public class Main { public double m01(double a, double b) { try { if(a < 0) throw new Err01(); if(b <= 0) throw new Err02(); } catch(Err01 e) { System.out.println("a menor do que zero"); } catch(Err02 e) { System.out.println("b menor ou igual } catch(Exception e) { System.out.println("b igual a zero"); } return a / b; } public static void main(String[] args) throws Exception { Main m=new Main(); System.out.println( m.m01 (8.0, 4.0) ); } } a zero"); a zero")
- D public class Main { public double m01(double a, double b) throws Err01 try { if(a < 0) throw new Err01(); if(b < 0) throw new Err02(); if(b == 0) throw new Exception(); } catch(Exception e) { System.out.println("b igual a zero"); } return a / b; } public static void main(String[] args) throws Exception { Main m=new Main(); System.out.println( m.m01 (8.0, 4.0) ); } }
- E public class Main { public double m01(double a, double b) throws Exception { try { if(a < 0) throw new Err01(); if(b <= 0) throw new Err02(); } catch(Err01 e) { System.out.println("a menor do que zero"); } catch(Err02 e) { System.out.println("b menor ou igual } return a / b; } public static void main(String[] args) throws Exception { Main m=new Main(); System.out.println( m.m01 (8.0, 4.0) ); } } { a zero")