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

加入VIP,免费下载
 

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

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

下载须知

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

版权提示 | 免责声明

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

JAVA认证历年真题SCJP考试真题和解析1.docx

1、JAVA认证历年真题SCJP考试真题和解析1 JAVA认证历年真题:SCJP考试真题和解析1JAVA认证历年真题:SCJP考试真题和解析1JAVA认证历年真题:SCJP考试真题和解析1 例题1: choose the three valid identifiers from those listed below. a. idolikethelongnameclass b. $byte c. const d. _ok e. 3_case 解答:a, b, d 点评:java中的标示符必须是字母、美元符($)或下划线(_)开头。关键字与保留字不能作为标示符。选项c中的const是java的保留字,

2、所以不能作标示符。选项e中的3_case以数字开头,违反了java的规则。 例题2: how can you force garbage collection of an object? a. garbage collection cannot be forced b. call system.gc(). c. call system.gc(), passing in a reference to the object to be garbage collected. d. call runtime.gc(). e. set all references to the object to ne

3、w values(null, for example). 解答:a 点评:在java中垃圾收集是不能被强迫立即执行的。调用system.gc()或runtime.gc()静态方法不能保证垃圾收集器的立即执行,因为,也许存在着更高优先级的线程。所以选项b、d不正确。选项c的错误在于,system.gc()方法是不接受参数的。选项e中的方法可以使对象在下次垃圾收集器运行时被收集。 例题3: consider the following class: 1. class test(int i) 2. void test(int i) 3. system.out.println( i am an int

4、. ); 4. 5. void test(string s) 6. system.out.println( i am a string. ); 7. 8. 9. public static void main(string args) 10. test t=new test(); 11. char ch= y 12. t.test(ch); 13. 14. which of the statements below is true?(choose one.) a. line 5 will not compile, because void methods cannot be overridde

5、n. b. line 12 will not compile, because there is no version of test() that rakes a char argument. c. the code will compile but will throw an exception at line 12. d. the code will compile and produce the following output: i am an int. e. the code will compile and produce the following output: i am a

6、 string. 解答:d 点评:在第12行,16位长的char型变量ch在编译时会自动转化为一个32位长的int型,并在运行时传给void test(int i)方法。例题4: which of the following lines of code will compile without error? a. int i=0; if (i) system.out.println( hi ); b. boolean b=true; boolean b2=true; if(b=b2) system.out.println( so true ); c. int i=1; emonstrate a

7、 has a relationship? (choose two) a. public interface person public class employee extends person b. public interface shape public interface rectandle extends shape c. public interface colorable public class shape implements colorable d. public class species public class animalprivate species specie

8、s; e. interface component class container implements component private component children; 解答:d, e 点评: 在java中代码重用有两种可能的方式,即组合( has a 关系)和继承( is a 关系)。 has a 关系是通过定义类的属性的方式实现的;而 is a 关系是通过类继承实现的。本例中选项a、b、c体现了 is a 关系;选项d、e体现了 has a 关系。 例题6: which two statements are true for the class java.util.treese

9、t? (choose two) a. the elements in the collection are ordered. b. the collection is guaranteed to be immutable. c. the elements in the collection are guaranteed to be unique. d. the elements in the collection are accessed using a unique key. e. the elements in the collection are guaranteed to be syn

10、chronized 解答:a, c 点评:treeset类实现了set接口。set的特点是其中的元素惟一,选项c正确。由于采用了树形存储方式,将元素有序地组织起来,所以选项a也正确。例题7: true or false: readers have methods that can read and return floats and doubles. a. ture b. false 解答:b 点评: reader/writer只处理unicode字符的输入输出。float和double可以通过stream进行i/o. 例题8: what does the following paint()

11、method draw? 1. public void paint(graphics g) 2. g.drawstring( any question , 10, 0); 3. a. the string any question? , with its top-left corner at 10,0 b. a little squiggle coming down from the top of the component. 解答:b 点评:drawstring(string str, int x, int y)方法是使用当前的颜色和字符,将str的内容显示出来,并且最左的字符的基线从(x,

12、y)开始。在本题中,y=0,所以基线位于最顶端。我们只能看到下行字母的一部分,即字母 y 、 q 的下半部分。 例题9: what happens when you try to compile and run the following application? choose all correct options. 1. public class z 2. public static void main(string args) 3. new z(); 4. 5. 6. z() 7. z alias1 = this; 8. z alias2 = this; 9. synchronized(

13、alias1) 10. try 11. alias2.wait(); 12. system.out.println( done waiting ); 13. 14. catch (interruptedexception e) 15. system.out.println( interr upted ); 16. 17. catch (exception e) 18. system.out.println( other exception ); 19. 20. finally 21. system.out.println ( finally ); 22. 23. 24. system.out.

14、println( all done ); 25. 26. a. the application compiles but doesnt print anything. b. the application compiles and print done waiting c. the application compiles and print finally d. the application compiles and print all done e. the application compiles and print interrupted 解答:a 点评:在java中,每一个对象都有

15、锁。任何时候,该锁都至多由一个线程控制。由于alias1与alias2指向同一对象z,在执行第11行前,线程拥有对象z的锁。在执行完第11行以后,该线程释放了对象z的锁,进入等待池。但此后没有线程调用对象z的notify()和notifyall()方法,所以该进程一直处于等待状态,没有输出。例题10: which statement or statements are true about the code listed below? choose three. 1. public class mytextarea extends textarea 2. public mytextarea(i

16、nt nrows, int ncols) 3. enableevents(awtevent.text_ event_mask); 4. 5. 6. public void processtextevent (textevent te) 7. system.out.println( processing a text event. ); 8. 9. a. the source code must appear in a file called mytextarea.java b. between lines 2 and 3, a call should be made to super(nrow

17、s, ncols) so that the new component will have the correct size. c. at line 6, the return type of processtextevent() should be declared boolean, not void. d. between lines 7 and 8, the following code should appear: return true. e. between lines 7 and 8, the following code should appear: super.process

18、textevent(te). 解答:a, b, e 点评:由于类是public,所以文件名必须与之对应,选项a正确。如果不在2、3行之间加上super(nrows,ncols)的话,则会调用无参数构建器textarea(), 使nrows、ncols信息丢失,故选项b正确。在java2中,所有的事件处理方法都不返回值,选项c、d错误。选项e正确,因为如果不加super.processtextevent(te),注册的listener将不会被唤醒。1.which statement about the garbage collection mechanism are true? a. garba

19、ge collection require additional programe code in cases where multiple threads are running. b. the programmer can indicate that a reference through a local variable is no longer of interest. c. the programmer has a mechanism that explicity and immediately frees the memory used by java objects. d. th

20、e garbage collection mechanism can free the memory used by java object at explection time. e. the garbage collection system never reclaims memory from objects while are still accessible to running user threads. 1。b、e java的垃圾回收机制是通过一个后台系统级线程对内存分配情况进行跟踪实现的,对程序员来说是透明的,程序员没有任何方式使无用内存显示的、立即的被释放。而且它是在程序运行

21、期间发生的。 答案b告诉我们程序员可以使一个本地变量失去任何意义,例如给本地变量赋值为 null ;答案e告诉我们在程序运行期间不可能完全释放内存。 2. give the following method: 1) public void method( ) 2) string a,b; 3) a=new string( hello world ); 4) b=new string( game over ); 5) system.out.println(a+b+ ok ); 6) a=null; 7) a=b; 8) system.out.println(a); 9) in the absen

22、ce of compiler optimization, which is the earliest point the object a refered is definitely elibile to be garbage collection. a. before line 3 b.before line 5 c. before line 6 d.before line 7 e. before line 9 2。d 第6行将null赋值给a以后,a以前保存的引用所指向的内存空间就失去了作用,它可能被释放。所以对象a可能最早被垃圾回收是在第7行以前,故选择d选项。 3. in the cl

23、ass java.awt.awtevent,which is the parent class upon which jdk1.1 awt events are based there is a method called getid which phrase accurately describes the return value of this method? a. it is a reference to the object directly affected by the cause of the event. b. it is an indication of the natur

24、e of the cause of the event. c. it is an indication of the position of the mouse when it caused the event. d. in the case of a mouse click, it is an indication of the text under the mouse at the time of the event. e. it tells the state of certain keys on the keybord at the time of the event. f. it i

25、s an indication of the time at which the event occurred.3。b 请查阅java类库。getid方法的返回值是 event type 。在认证考试中,总会有类似的书本以外的知识,这只能靠多实践来增长知识了。4. which statement about listener is true? a. most component allow multiple listeners to be added. b. if multiple listener be add to a single component, the event only af

26、fected one listener. c. component don?t allow multiple listeners to be add. d. the listener mechanism allows you to call an addxxxxlistener method as many times as is needed, specifying as many different listeners as your design require. 4。a、d 控件可以同时使用多个 addxxxxlistener 方法加入多个监听器。并且当多个监听器加入到同一控件中时,事

27、件可以响应多个监听器,响应是没有固定顺序的。 5.give the following code: public class example public static void main(string args ) int l=0; do system.out.println( doing it for l is: +l); while(-l 0) system.out.println( finish ); which well be output: a. doing it for l is 3 b. doing it for l is 1 c. doing it for l is 2 d.

28、 doing it for l is 0 e. doing it for l is ?c1 f. finish 5。d、f 本题主要考察考生对流程控制的掌握情况。这是当型循环,条件为真执行,条件为假则退出。循环体至少执行一次,故会输出d。循环体以外的语句总会被执行,故输出f。6. give the code fragment: 1) switch(x) 2) case 1:system.out.println( test 1 );break; 3) case 2: 4) case 3:system.out.println( test 2 );break; 5) default:system.o

29、ut.println( end ); 6) which value of x would cause test 2 to the output: a. 1 b. 2 c. 3 d. default 6。b.c 在开关语句中,标号总是不被当做语句的一部分,标号的作用就是做为条件判断而已,一旦匹配成功,就执行其后的语句,一直遭遇break语句为止。(包括default语句在内)7. give incompleted method: 1) 2) if(unsafe()/do something 3) else if(safe()/do the other 4) the method unsafe()

30、 well throe an ioexception, which completes the method of declaration when added at line one? a. public ioexception methodname() b. public void methodname() c. public void methodname() throw ioexception d. public void methodname() throws ioexception e. public void methodname() throws exception 7。d、f ioexception异常类是exception的子类。根据多态性的定义,ioexception对象也可以被认为是exception类型。还要注意在方法声明中抛出异常应用关键字 throws 。 8. give the code fragment

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

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