ImageVerifierCode 换一换
格式:DOCX , 页数:30 ,大小:1MB ,
资源ID:7685640      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/7685640.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(SCJP题库.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

SCJP题库.docx

1、SCJP题库yModule 1-JAVA 基础一、选择题:Question 1Given:35. String #name = Jane Doe;36. int $age=24;37. Double _height = 123.5;38. double temp = 37.5;Which two are true? (Choose two.)A. Line 35 will not compile.B. Line 36 will not compile.C. Line 37 will not compile.D. Line 38 will not compile.Answer: AD 标识符以

2、字母,下划线,或者$开始Question 2Given:11. public class Test 12. public static void main(String args) 13. int x =5;14. boolean b1 = true;15. boolean b2 = false;16.17.if(x=4) & !b2)18. System.out.print(l );19. System.out.print(2 );20. if (b2 = true) & b1)21. System.out.print(3);22. 23. What is the result?A. 2B.

3、 3C. 1 2D. 2 3E. 1 2 3F. Compilation fails.G. An exceptional is thrown at runtime.Answer: D 注意20行,=为赋值,不要被骗Question 3Given:42. public class ClassA 43. public int getValue() 44. int value=0;45. boolean setting = true;46. String title=Hello;47. if (value | (setting & title = Hello) return 1; 48. if (v

4、alue = 1 & title.equals(Hello) return 2; 49. 50. And:70. ClassA a = new ClassA();71. a.getValue();What is the result?A. 1B. 2C. Compilation fails.D. The code runs with no output.E. An exception is thrown at runtime.Answer: C 编译不通过,47行value为int类型不是booleanQuestion 4Given:11. public void testIfA() 12.

5、if(testIfB(True) 13. System.out.println(True);14. else 15. System.out.println(Not true);16. 17. 18. public Boolean testIfB(String str) 19. return Boolean.valueOf(str);20. What is the result when method testIfA is invoked?A. TrueB. Not trueC. An exception is thrown at runtime.D. Compilation fails bec

6、ause of an error at line 12.E. Compilation fails because of an error at line 19.Answer: A 19行,如果str为true则返回ture,否则返回falseQuestion 5Given: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: Sy

7、stem.out.println(other); break;16. 17. What is the result?A. threeB. otherC. An exception is thrown at runtime.D. Compilation fails because of an error on line 12.E. Compilation fails because of an error on line 13.F. Compilation fails because of an error on line 15.Answer: A 就是两个Integer类型相加Question

8、 6Given:11. public static void main(String args) 12. String str = null;13. if (str = null) 14. System.out.println(null);15. else (str.length() = 0) 16. System.out.println(zero);17. else 18. System.out.println(some);19. 20. What is the result?A. nullB. zeroC. someD. Compilation fails.E. An exception

9、is thrown at runtime.Answer: D 这题真恶心 15行少个ifQuestion 7Given:10.int x=0;11.int y=10;12. do l3. y-;14. +x;15. while (x 5);16. System.out.print(x + , + y);What is the result?A. 5,6B. 5,5C. 6,5D. 6,6Answer: B (91,82,73,64,55)没啥争议Question 8Given:25.int x=12;26. while (x 10,所以直接跳出循环,输出x=12Question 9Given:

10、35. int x= 10;36. do 37. x-;38. while(x 10);How many times will line 37 be executed?A. ten timesB. zero timesC. one to me timesD. more than ten timesAnswer: D 死循环Question 10Given:11. public static void main(String args) 12. for (int i=0;i6) break;14. 15. System.out.println(i);16. What is the result?

11、A. 6B. 7C. 10D. 11E. Compilation fails.F. An exception is thrown at runtime.Answer: E 15行i超出了作用域Question 11Given:55. int x= 1, 2,3,4, 5;56. int y =x;57. System.out.println(y2);Which is true?A. Line 57 will print the value 2.B. Line 57 will print the value 3.C. Compilation will fail because of an err

12、or in line 55.D. Compilation will fail because of an error in line 56.Answer: B 没争议,考察数组下标是从0开始Question 12Which two code fragments(片段) correctly(正确) create and initialize a static array of int elements? (Choose two.)A. static final int a = 100,200 ;B. static final int a;static a=new int2; a0=100; a1

13、=200; C. static final int a = new int2 100,200 ;D. static final int a;static void init() a = new int3; a0=100; a1=200; Answer: AB c不能指定长度,d不能在init方法中赋值,要么在static代码块中Question 13Given:11. public static void main(String args) 12. Object obj = new int 1,2,3 ;13. int someArray = (int)obj;14. for (int i:

14、someArray) System.out.print(i + )15. What is the result?A. 1 2 3B. Compilation fails because of an error in line 12.C. Compilation fails because of an error in line 13.D. Compilation fails because of an error in line 14.E. A ClassCastException is thrown at runtime.Answer: A 没争议,foeach循环遍历数组Question

15、14Given:11. String elements = for, tea, too ;12. String first = (elements.length 0)? elements0 : null;What is the result?A. Compilation fails.B. An exception is thrown at runtime.C. The variable first is set to null.D. The variable first is set to elements0.Answer: DQuestion 15Given:10. public class

16、 Bar 11.static void foo(int.x) 12. / insert code here13. 14. Which two code fragments, inserted independently(独立的) at line 12, will allow the class to compile? (Choose two.)A. foreach(x) System.out.println(z);B. for(int z : x) System.out.println(z);C. while( x.hasNext() System.out.println( x.next();

17、D. for( int i=0; i x.length; i+ ) System.out.println(xi);Answer: BD x相当于一个数组 ,a明显错没有foreach,c中x没有hadNext方法Question 16A programmer(程序员) needs to create a logging method that can accept(接受) an arbitrary(随意任意) number of arguments. For example, it may be called in theseways:logIt(log message 1 );logIt(l

18、og message2”,”log message3);logIt(log message4, log message5, log message6);Which declaration(说明) satisfies(符合) this requirement(需求)?A. public void logIt(String * msgs)B. public void logIt(String msgs)C. public void logIt(String. msgs)D. public void logIt(String msg1, String msg2, String msg3)Answer

19、: C 可变长参数Question 171. public class A 2. public String doit(int x, int y) 3. return a;4. 5.6. public String doit(int. vals) 7. return b;8. 9. Given:25. A a=new A();26. System.out.println(a.doit(4, 5);What is the result?A. Line 26 prints a to System.out.B. Line 26 prints b to System.out.C. An excepti

20、on is thrown at line 26 at runtime.D. Compilation of class A will fail due to an error in line 6.Answer: A 确定参数和可变长参数同时存在的时候,优先考虑确定参数的Question 18Given a file GrizzlyBear.java:1. package animals.mammals;2.3. public class GrizzlyBear extends Bear 4. void hunt() 5. Salmon s = findSalmon();6. s.consume(

21、);7. 8. and another file, Salmon.java:1. package animals.fish;2.3. public class Salmon extends Fish 4. void consume() /* do stuff */ 5. Assume(假定) both classes are defined in the correct directories for theft packages, and that the Mammal class correctly defines the findSalmon() method. Which two ch

22、anges allow this code to compile correctly? (Choose two.)A. add public to the start of line 4 in Salmon.javaB. add public to the start of line 4 in GrizzlyBear.javaC. add import animals.mammals.*; at line 2 in Salmon.javaD. add import animals.fish.*; at line 2 in GrizzlyBear.javaE. add import animal

23、s.fish.Salmon.*; at line 2 in GrizzlyBear.javaF. add import animals.mammals.GrizzlyBear.*;at line 2 in Salmon.javaAnswer: AD 调用不同包下的类,要先导入,方法权限要设置成publicQuestion 19Given:10. package com.sun.scjp;11. public class Geodetics 12. public static final double DIAMETER = 12756.32; / kilometers13. Which two

24、correctly access(访问) the DIAMETER member of the Geodetics class? (Choose two.)A. import com.sun.scjp.Geodetics;public class TerraCarta public double halfway() return Geodetics.DIAMETER/2.0; B. import static com.sun.scjp.Geodetics;public class TerraCarta public double halfway() return DIAMETER/2.0; C

25、. import static com.sun.scjp.Geodetics. *;public class TerraCarta public double halfway() return DIAMETER/2.0; D. package com.sun.scjp;public class TerraCarta public double halfway() return DIAMETER/2.0; Answer: AC b中不能静态导入类,c中静态导入类属性,正确,d访问错误很明显Question 20Given classes defined in two different file

26、s:1. package util;2. public class BitUtils 3. private static void process(byte b) 4. 1. package app;2. public class SomeApp 3. public static void main(String args) 4. byte bytes = new byte256;5. / insert code here6. 7. What is required(必需的) at line 5 in class SomeApp to use the process methodof BitU

27、tils?A. process(bytes);B. BitUtils.process(bytes);C. app.BitUtils.process(bytes);D. util.BitUtils.process(bytes);E. import util.BitUtils. *; process(bytes);F. SomeApp cannot use the process method in BitUtils.Answer: F 私有的,不能被访问Question 21Given a class Repetition(重复):1. package utils;2.3. public cla

28、ss Repetition 4. public static String twice(String s) return s + s; 5. and given another class Demo:1. / insert code here2.3. public class Demo 4. public static void main(String args) 5. System.out.println(twice(pizza);6. 7. Which code should be inserted at line 1 of Demo.java to compile and run Dem

29、o to print “pizzapizza”?A. import utils.*;B. static import utils.*;C. import utils.Repetition.*;D. static import utils.Repetition. *;E. import utils.Repetition.twice();F. import static utils.Repetition.twice;G. static import utils.Repetition.twice;Answer: F 静态导入Question 22Given:1. package test;2.3. class Target(目标) 4. public String name = hello;5. What can directly(直接的) access and change the value of the variable(变量) name?A. any clas

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1