OCJP认证解析3.docVIP

  • 18
  • 0
  • 约2.4万字
  • 约 24页
  • 2017-05-26 发布于河南
  • 举报
OCJP认证解析3

Exam : 1Z0-851 Java Standard Edition 6?Programmer Certified?Professional Exam 以下分析全都是我自己分析或者参考网上的,定有疏漏,还请大家对我的分析提出质疑。 QUESTION 61 Given: 1. public class TestString1 { 2. public static void?main(String[] args) { 3. String str = 420; 4. str += 42; 5. System.out.print(str); 6. } 7. } What is the output? A. 42 B. 420 C. 462 D. 42042 E. Compilation fails. F. An exception is thrown at runtime. Answer: D 42会自动类型转换成String类型。 QUESTION 62 Given: 12. Date date = new Date(); 13. df.setLocale(Locale.ITALY); 14. String s = df.format(date); The variable df is an object of type DateFormat that has been initialized in line 11. What is the result if this code is run on December 14, 2000? A. The value of s is 14-dic-2000. B. The value of s is Dec 14, 2000. C. An exception is thrown at runtime. D. Compilation fails because of an error in line 13. Answer: D 设置地点不是这样设置,如下: Locale.setDefault(Locale.US);//设置为美国地区?? QUESTION 63 Given: 1. public class KungFu { 2. public static void main(String[] args) { 3. Integer x = 400; 4. Integer y = x; 5. x++; 6. StringBuilder sb1 = new StringBuilder(123); 7. StringBuilder sb2 = sb1; 8. sb1.append(5); 9. System.out.println((x==y) + + (sb1==sb2)); 10. } 11. } What is the result? A. true true B. false true C. true false D. false false E. Compilation fails. F. An exception is thrown at runtime. Answer: B x与y引用相同的对象400,但是x++即x = x + 1; 使x引用401,而y依然引用400,输出false。 QUESTION 64 Given that the current directory is empty, and that the user has read and write privileges to the current directory, and the following: 1. import java.io.*; 2. public class Maker { 3. public static void main(String[] args) { 4. File dir = new File(dir); 5. File f = new File(dir, f); 6. } 7. } Which statement is true? A. Compilation fails. B. Nothing is added to the file system. C. Only a new file is created on the file system. D. Only a new directory is created on the file system. E. Both a new file and a new directory are created on the file system. Answer: B 没调用creat函数,不会是文件系统

文档评论(0)

1亿VIP精品文档

相关文档