What is the result a compilation fails b aaaa aaa

This preview shows page 125 - 129 out of 166 pages.

13. }What is the result? A. Compilation fails.B. aAaA aAa AAaa AaAC. AAaa AaA aAa aAaAD. AaA AAaa aAaA aAaE. aAa AaA aAaA AAaaF. An exception is thrown at runtime.Answer:CQUESTION:237Given:5. class A {6. void foo() throws Exception { throw new Exception(); }7. }8. class SubB2 extends A {9. void foo() { System.out.println("B "); }10. }11. class Tester {12. public static void main(String[] args) {13. A a = new SubB2(); 14. a.foo(); 15. } 16. } What is the result? QUESTION:238Given a method that must ensure that its parameter is not null:11. public void someMethod(Object value) {12. // check for null value...310-065125
Background image
20. System.out.println(value.getClass()); 21. }What, inserted at line 12, is the appropriate way to handle a null value? QUESTION:239Given:1. public class Mule {2. public static void main(String[] args) {3. boolean assert = true;4. if(assert) {5. System.out.println("assert is true");6. }7. } 8. }Which command-line invocations will compile? QUESTION:240Click the Exhibit button.Given:25. try {26. A a = new A();27. a.method1();28. } catch (Exception e) {29. System.out.print("an error occurred"); 30. } Which two statements are true if a NullPointerException is thrown on line 3 of class C? (Choose two.)310-065126
Background image
1. public class Venus {2. public static void main(String[] args) {3. int [] x = {1,2,3};4. int y[] = {4,5,6};5. new Venus().go(x,y);6. }7. void go(int[]... z) {8. for(int[] a : z)9. System.out.print(a[0]);10. } 11. } What is the result? 310-065127
Background image
QUESTION:242Given:11. public class Test { 12. public enum Dogs {collie, harrier, shepherd};13. public static void main(String [] args) {14. Dogs myDog = Dogs.shepherd;15. switch (myDog) {16. case collie:17. System.out.print("collie ");18. case default:19. System.out.print("retriever ");20. case harrier:21. System.out.print("harrier ");22. }23. } 24. } What is the result? QUESTION:243Given:11. static void test() {12. try {
Background image
Image of page 129

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture