Your SlideShare is downloading. ×
0
Revision
Revision
Revision
Revision
Revision
Revision
Revision
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Revision

58

Published on

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
58
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. 1 Sun Educación México Revision Examen de Practica I
  • 2. 2 Sun Educación México Given: 5. enum Towns1{NY, LA, SF} 6. 7. public class DeclareEnum { 8. 9. enum Towns2{NY, LA, SF}; 10. 11. public static void main(String [] args) { 12. enum Towns3{NY, LA, SF}; 13. } 14. } What is the result? A. The code compiles B. Compilation fails due to an error on line 5 C. Compilation fails due to an error on line 9 D. Compilation fails due to an error on line 12 E. Compilation fails due to errors on lines 5 and 12 F. Compilation fails due to errors on lines 9 and 12
  • 3. 3 Sun Educación México Given three different source files: package com.sun2; public enum Seasons {SUMMER, FALL, WINTER, SPRING } And: import com.sun2.Seasons; class Enum3a { Seasons s = Seasons.FALL; } And: import com.sun2.*; class Enum3b { Seasons s = Seasons.FALL; } • A. Both classes, Enum3a and Enum3b, will compile • B. Neither class, Enum3a nor Enum3b, will compile • C. Class Enum3a will compile, class Enum3b will NOT compile • D. Class Enum3b will compile, class Enum3a will NOT compile
  • 4. 4 Sun Educación México • 1. enum Days {MONDAY, TUESDAY, WEDNESDAY} • 2. • 3. class Test { • 4. public static void main(String [] args) { • 5. int x = 0; • 6. Days d = Days.TUESDAY; • 7. switch(d) { • 8. case MONDAY: x++; • 9. case TUESDAY: x = x + 10; • 10. case WEDNESDAY: x = x + 100; • 11. case THURSDAY: x = x + 1000; • 12. } • 13. System.out.println("x = " + x); • 14. } • 15. } • What is the result? • A. x = 10 • B. x = 110 • C. x = 1110 • D. Compilation fails • E. An exception is thrown at runtime
  • 5. 5 Sun Educación México • 1. class Test2 { • 2. public static void main(String [] args) { • 3. boolean x = true; • 4. boolean y = false; • 5. short z = 42; • 6. • 7. if((x == true) && (y = true)) z++; • 8. if((y == true) || (++z == 44)) z++; • 9. • 10. System.out.println("z = " + z); • 11. } • 12. } • What is the result? • A. z = 42 • B. z = 43 • C. z = 44 • D. z = 45 • E. Compilation fails • F. An exception is thrown at runtime
  • 6. 6 Sun Educación México • 1. class WhileTests { • 2. public static void main(String [] args) { • 3. int x = 5; • 4. while (++x < 3) { • 5. --x; • 6. } • 7. System.out.println("x = " + x); • 8. } • 9. } • What is the result? • A. x = 2 • B. x = 5 • C. x = 6 • D. Compilation fails • E. A stack overflow occurs
  • 7. 7 Sun Educación México • 21. class Beta { • 22. public static void main(String [] args) { • 23. • 24. Integer x = new Integer(6) * 7; • 25. if (x != 42) { • 26. System.out.print("42 "); • 27. } else if (x < new Integer(44-1)) { • 28. System.out.println("less"); • 29. } else { • 30. System.out.print("done"); • 31. } } } • What is the result? • A. less • B. 42 • C. done • D. Compilation fails • E. An exception is thrown at runtime

×