QUESTION 51 Given: 1. public class BuildStuff { 2. public static void main(String[] args) { 3. Boolean test = new Boolean(true); 4. Integer x = 343; 5. Integer y = new BuildStuff().go(test, x); 6. System.out.println(y); 7. } 8. int go(Boolean b, int i) { 9. if(b) return (i/7); 10. return (i/49); 11. } 12. } What is the result? A. 7 B. 49 C. 343 D. Compilation fails. E. An exception is thrown at ..
QUESTION 50 Given: 18. import java.util.Date; 19. import java.text.DateFormat; 20. 21. DateFormat df; 22. Date date = new Date(); 23. //insert code here 24. String s = df.format(date); Which code fragment, inserted at line 23, allows the code to compile? A. df = new DateFormat(); B. df = Date.getFormat(); C. df = date.getFormat(); D. df = DateFormat.getFormat(); E. df = DateFormat.getInstance();..
QUESTION 49 Given: 1. d is a valid, non-null Date object 2. df is a valid, non-null DateFormat object set to the current locale What outputs the current locale's country name and the appropriate version of d's date? A. Locale loc = Locale.getLocale(); System.out.println(loc.getDisplayCountry() + " " + df.format(d)); B. Locale loc = Locale.getDefault(); System.out.println(loc.getDisplayCountry() ..
QUESTION 48 Given: 1. public class TestString3 { 2. public static void main(String[] args) { 3. // insert code here 4. 5. System.out.println(s); 6. } 7. } Which two code fragments, inserted independently at line 3, generate the output 4247? (Choose two.) A. String s = "123456789"; s = (s-"123").replace(1,3,"24") - "89"; B. StringBuffer s = new StringBuffer("123456789"); s.delete(0,3).replace(1,3..
QUESTION 47 Given: 11. public static void main(String[] args) { 12. Integer i = new Integer(1) + new Integer(2); 13. switch(i) { 14. case 3: System.out.println("three"); break; 15. default: System.out.println("other"); break; 16. } 17. } What is the result? A. three B. other C. An exception is thrown at runtime. D. Compilation fails because of an error on line 12. E. Compilation fails because of..
QUESTION 46 Given: public class Foo { static int[] a; static { a[0]=2; } public static void main( String[] args ) {} } Which exception or error will be thrown when a programmer attempts to run this code? A. java.lang.StackOverflowError B. java.lang.IllegalStateException C. java.lang.ExceptionInInitializerError D. java.lang.ArrayIndexOutOfBoundsExceptionSolution : C plus imformation Exception in ..