Given Classes Output Following Program Execution Ablic Class Badcharexception Extends Exce Q43890368
Given the classes below, what is the output of the following program execution: Ablic class BadCharException extends Exception public BadCharException (String message) (super message); } public class Test Names public static void main(String[] args) String[] names (“one”,”two”, “three”); BadCharException problem new BadcharException (“x”); tryd for (String name: names) if (name.charAt(0) -t’) throw problems System.out.print (name.charAt(0)); catch (BadCharException e) { System.out.print(e.getMessage(): catch(Exception e) { System.out.print(“y”)) b. xox e None of the above 9. Given the following code, what is the output? public class Figure public void display System.out.print(“Figure”); public class Line extends Figure! public void display System.out.print(“Line); public class Inherit public static void tryme (Figure ) ( f.display(); } public static void main(String! ] args) { Figure f = new Figure ); Line In- new Line(); fon; tryme (f); a Line b. Figure c. FigureLine d. Compilation error e. None of the above b nclusive i in the o very 10. Why does the code in the following method represent an infinite recursion? public int infinite Recursion(int n) [ if (n > 0) return infinite Recursion (n) + 1; else return 0; a. Because there is no base case b. Because the recursive call does not move the parameter closer to the base case c. Because the recursive call moves the problem further away from the base case d. Because there is no recursive call e. None of the above Show transcribed image text Given the classes below, what is the output of the following program execution: Ablic class BadCharException extends Exception public BadCharException (String message) (super message); } public class Test Names public static void main(String[] args) String[] names (“one”,”two”, “three”); BadCharException problem new BadcharException (“x”); tryd for (String name: names) if (name.charAt(0) -t’) throw problems System.out.print (name.charAt(0)); catch (BadCharException e) { System.out.print(e.getMessage(): catch(Exception e) { System.out.print(“y”)) b. xox e None of the above 9. Given the following code, what is the output? public class Figure public void display System.out.print(“Figure”); public class Line extends Figure! public void display System.out.print(“Line); public class Inherit public static void tryme (Figure ) ( f.display(); } public static void main(String! ] args) { Figure f = new Figure ); Line In- new Line(); fon; tryme (f); a Line b. Figure c. FigureLine d. Compilation error e. None of the above b nclusive i in the o very 10. Why does the code in the following method represent an infinite recursion? public int infinite Recursion(int n) [ if (n > 0) return infinite Recursion (n) + 1; else return 0; a. Because there is no base case b. Because the recursive call does not move the parameter closer to the base case c. Because the recursive call moves the problem further away from the base case d. Because there is no recursive call e. None of the above
Expert Answer
Answer to Given the classes below, what is the output of the following program execution: Ablic class BadCharException extends Exc…
OR