반응형
자격증/OCJP_ExamB2018. 7. 13. 21:29QUESTION 54

QUESTION 54 Given: 1. public class LineUp { 2. public static void main(String[] args) { 3. double d = 12.345; 4. // insert code here 5. } 6. } Which code fragment, inserted at line 4, produces the output | 12.345|? A. System.out.printf("|%7d| \n", d); B. System.out.printf("|%7f| \n", d); C. System.out.printf("|%3.7d| \n", d); D. System.out.printf("|%3.7f| \n", d); E. System.out.printf("|%7.3d| \..

자격증/OCJP_ExamB2018. 7. 13. 21:18QUESTION 53

QUESTION 53 Given: 04. import java.io.*; 05. 06. public class Talk { 07. public static void main(String[] args) { 08. Console c = new Console(); 09. String pw; 10. System.out.print("password: "); 11. pw = c.readLine(); 12. System.out.println("got " + pw); 13. } 14.} If the user types the password aiko when prompted, what is the result? A. password: got B. password: got aiko C. password: aiko got..

자격증/OCJP_ExamB2018. 7. 13. 21:14QUESTION 52

QUESTION 52 Given: import java.io.*; public class Forest implements Serializable { private Tree tree = new Tree(); public static void main(String [] args) { Forest f = new Forest(); try { FileOutputStream fs = new FileOutputStream("Forest.ser"); ObjectOutputStream os = new ObjectOutputStream(fs); os.writeObject(f); os.close(); } catch (Exception ex) { ex.printStackTrace(); } }} class Tree { } Wh..

자격증/OCJP_ExamB2018. 7. 13. 21:03QUESTION 51

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 ..

자격증/OCJP_ExamB2018. 7. 13. 20:23QUESTION 50

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();..

자격증/OCJP_ExamB2018. 7. 13. 20:19QUESTION 49

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() ..

반응형
image