Suitsint points thispoints poi 8 private int points 9 public int getValueint

Suitsint points thispoints poi 8 private int points 9

This preview shows page 11 - 15 out of 43 pages.

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
A. The output could contain 30B. The output could contain @bf73faC. The output could contain DIAMONDSD. Compilation fails due to an error on line 6E. Compilation fails due to an error on line 7F. Compilation fails due to an error on line 8G. Compilation fails due to an error on line 9H. Compilation fails due to an error within lines 12 to 1431. 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 8E. Compilation failsF. An exception is thrown at runtime32. 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. }What is the result?33. Given:
Background image
3. class Dozens {4. int[] dz = {1,2,3,4,5,6,7,8,9,10,11,12};5. }6. public class Eggs {7. public static void main(String[] args) {8. Dozens [] da = new Dozens[3];9. da[0] = new Dozens();10. Dozens d = new Dozens();11. da[1] = d;12. d = null;13. da[1] = null;14. // do stuff15. }16. }Which two are true about the objects created within main(), and eligible for garbage collectionwhen line 14 is reached?A. Three objects were createdB. Four objects were createdC. Five objects were createdD. Zero objects are eligible for GCE. One object is eligible for GCF. Two objects are eligible for GCG. Three objects are eligible for GC34. 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?A. 0B. 1C. 2D. 3E. 4F. 535. Given:3. class Box {4. int size;5. Box(int s) { size = s; }6. }7. public class Laser {8. public static void main(String[] args) {
Background image
Background image
Image of page 15

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture