Cadernos de Questões

Provas Favoritas

Filtros Salvos

Foi encontrada 1 questão.
#3246904

Considere as seguintes classes Java, que ocupam arquivos separados:


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?

  • 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) );      } }
  • 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 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) );     } }
  • 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 a zero");   }   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) );} }
  • 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) );     } }
  • 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 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) );     } }
Fale com IAgo
IAgo - Assistente IAProva
IA
Olá! Sou o IAgo, seu assistente aqui no IAProvatec 😊
Veja como posso te ajudar:
Agora