What is the result A pre b1 b2 r3 r2 hawk B pre b2 b1 r2 r3 hawk C pre b2 b1 r2

What is the result a pre b1 b2 r3 r2 hawk b pre b2 b1

This preview shows page 18 - 22 out of 88 pages.

What is the result?A.pre b1 b2 r3 r2 hawkB.pre b2 b1 r2 r3 hawkC.pre b2 b1 r2 r3 hawk r1 r4D.r1 r4 pre b1 b2 r3 r2 hawkE.r1 r4 pre b2 b1 r2 r3 hawkF.pre r1 r4 b1 b2 r3 r2 hawkG.pre r1 r4 b2 b1 r2 r3 hawkH.The order of output cannot be predictedI.Compilation fails7. Given:3. public class Bridge {4. public enum Suits {5. CLUBS(20), DIAMONDS(20), HEARTS(30), SPADES(30),6. NOTRUMP(40) { public int getValue(int bid) { return ((bid-1)*30)+40; } };7. Suits(int points) { this.points = points; 8. private int points; 9. public int getValue(int bid) { return points * bid; }10. 11. public static void main(String[] args) {12. System.out.println(Suits.NOTRUMP.getValue(3));13. System.out.println(Suits.SPADES + " " + Suits.SPADES.points);14. System.out.println(Suits.values());15. }}}16. }Which are true? (Choose all that apply.)
Background image
G.Compilation fails due to an error on line 9H.Compilation fails due to an error within lines 12 to 148. Given:3. public class Ouch {4. static int ouch = 7;5. public static void main(String[] args) {6. new Ouch().go(ouch);7. System.out.print(" " + ouch);8. }9. void go(int ouch) {10. ouch++;11. for(int ouch = 3; ouch < 6; ouch++) 12. ;13. System.out.print(" " + ouch);14. }15. } What is the result?A.5 7B.5 8C.8 7D.8 8 E.Compilation fails F.An exception is thrown at runtime9. Given:3. public class Bertha {4. static String s = "";5. public static void main(String[] args) {6. int x = 4; Boolean y = true; short[] sa = {1,2,3};7. doStuff(x, y);8. doStuff(x);9. doStuff(sa, sa);10. System.out.println(s);11. }12. static void doStuff(Object o) { s += "1"; }13. static void doStuff(Object... o) { s += "2"; }14. static void doStuff(Integer... i) { s += "3"; }15. static void doStuff(Long L) { s += "4"; }16. }Self Test 273
Background image
274Chapter 3: AssignmentsWhat is the result?}16. }Which two are true about the objects created within main(), and eligible for garbage collection when line 14 is reached?
Background image
11.Given:3. class Beta { }4. class Alpha {5. static Beta b1;6. Beta b2;7. }8. public class Tester {9. public static void main(String[] args) { 10. Beta b1 = new Beta(); Beta b2 = new Beta();11. Alpha a1 = new Alpha(); Alpha a2 = new Alpha();12. a1.b1 = b1;13. a1.b2 = b1;14. a2.b2 = b2;15. a1 = null; b1 = null; b2 = null;16. // do stuff17. }18. }When line 16 is reached, how many objects will be eligible for garbage collection?
Background image
Image of page 22

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture