Java Reference
In-Depth Information
10. }catch(NumberFormatException e) {
11. System.out.print(“4”);
12. }
13. }
14.
15. public static void main(String [] args) {
16. Dog fido = new Dog();
17. fido.name = “Fido”;
18. fido.parseName();
19. System.out.print(“5”);
20. }
21. }
A. 1235
B. 124
C. 1245
D. 1234
E. 12
24. What is the output of the following program?
1. public class Cat {
2. public String name;
3.
4. public void parseName() {
5. System.out.print(“1”);
6. try {
7. System.out.print(“2”);
8. int x = Integer.parseInt(name);
9. System.out.print(“3”);
10. }catch(NullPointerException e) {
11. System.out.print(“4”);
12. }
13. System.out.print(“5”);
14. }
15.
16. public static void main(String [] args) {
17. Cat felix = new Cat();
18. felix.name = “Felix”;
19. felix.parseName();
20. System.out.print(“6”);
21. }
22. }
Search WWH ::




Custom Search