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

加入VIP,免费下载
 

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

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

下载须知

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

版权提示 | 免责声明

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

java认证题库.docx

1、java认证题库A. Compilation fails B. An exception is thrown at runtime. C. An instance of Forest is serialized. D. An instance of Forest and an instance of Tree are both serialized.Answer: ( B )执行时期会抛出java.io.NotSerializableExcetpion异常。Tree必须实现Serialized接口;因为Forest实现了序列化,并且引用了Tree,但是Tree没有实现序列化!当一个实现序列化的

2、类在类体里调用另外一个类的时候,那么另外一个类也要实现序列化!如果没有实现,则会报出运行时异常! 如果要实现序列化,他的成员变量也必须实现序列化.本题中Tree没有实现序列化,所以会产生java.io.NotSerializableException的运行异常!参考大纲:IO操作 对象的序列化序列化的过程就是对象写入字节流和从字节流中读取对象。见SCJP.u1. SerializableTestQUESTION 2 Which code, inserted at line 14, will allow this class to correctly serialized and desteri

3、lized? A. s.defaultReadObject (); B. this = s.defaultReadObject (); C. y = s.default (); x = s.readInt (); D. x = s.readInt(); y = s.readInt ();Answer: ( D )在反序列化方法中,从s对象中读取两个整数. 序列化是写对象,反序列化是读对象参考大纲:IO操作 对象的序列化QUESTION 3 Given the exhibit. What is the result? A. 0 B. 1 C. 4 D. Compilation fails E.

4、An exception is thrown at runtime Answer: ( D ) 产生illegal escape character 非法转意符 的编译错误split()字符切割器本题是想用空格来分割字符串,只能用“ ”或者“ s”来分割,“ s”没有这个转意字符!所以会报编译错误 tab可以用“ t”; “”可以用”表示.String的split方法用来分割字符串,这个方法接受一个正则表达式,根据表达式来分割,“s”表示空格,“s”没有这个转意字符,所以会产illegal escape character的编译错误。参考大纲:实用API String的split()方法和正则

5、表达式QUESTION 4 Given the exhibit: 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-2004 B. The value of S is Dec 14, 2000 C. An exception is thrown at runtime D. Compilation

6、fails because of an error in line 13.Answer: ( D )DateFormat用来格式日期,它放在java.text包里,它没有setLocale方法,Local.Ialy 应该为 Locale.ITALY. 代码语法有问题,编译错误!参考大纲:实用API java.util包 和java.text包 QUESTION 5 The doesFileExist method takes an array of directory names representing a path from the root filesystem and a file n

7、ame. The method returns true if the file exists, false if does not.Place the code fragments in position to complete this method.Answer: ( )public static boolean doesFileExist(String directories, String filename) String path = ;for (String dir : directories) path = path + File.separator + dir;File fi

8、le = new File(path, filename);return file.exists();参考大纲:IO操作 FileQUESTION 6Given: System.out.printf(Pi is approximately %f and E is approximately %b, Math.PI, Math.E); Place the values where they would appear in the output.Answer: ( )3.141593True -判断E是否是NULL, NULL是FALSE 否则是TRUE.Pi=3.1415926.E=2.7182

9、82Printf() 是C中常用的语法;% f 表示浮点数(小数点后6位) , %b 表示boolean, %d表示整数.%e 十进制的科学计数法表示浮点数%a 16进制表示浮点型科学计数法的整数部分,以10进制表示指数%0 以8进制表示整数%x 以16进制表示整数%s 字符串个数输出%c char型格式输出 ,提供的值应为整数型%t 输出日期时间的前置 ?参考大纲:实用API Formatter 格式化输出工具QUESTION 7 When comparing java. io. BufferedWriter to java.io.FileWriter, which capability e

10、xist as a method in only one of the two? A. closing the stream B. flushing the stream C. writing to the stream D. marking a location in the stream E. writing a line separator to the stream Answer: ( E )只有BufferedWriter具有newLine( )方法; Reader 才有mark功能。参考大纲:I/O操作 BufferWriter和FileWriterQUESTION 8 Given

11、 the exhibit: 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; /String 中只有”+”表示连接,但是无”-”;产生poerator-can not be applied to java.lang.String的编译错误B. StringBuffer s = new StringBuffer (1234567

12、89); s.delete (0,3) .replace(1,3,24). delete (4,6); /delete(0,3)表示从0下标开始删除到3下标以前C. StringBuffer s = new StringBuffer (123456789); s.substring (3,6).delete(1,3). insert (1, 24). Substring()回传的是一个String而不是StringBuffer,String没有delete方法,产生cannot find symbol的编译错误D. StringBuilder s = new StringBuilder (12

13、3456789); s.substring (3,6) delete (1,2). insert (1, 24) 错误同上E. StringBuilder s = new StringBuilder (123456789); s.delete (0,3) replace(1,3,”). delete (2,5). insert (1, 24)Answer: ( B, E )A, String没有“-” 运算符; String不能修改!B, 正确 4247C, S.substring返回的是String, String没有delete()方法D, S.substring返回的是StringE,

14、正确 4247参考大纲:实用API String、StringBuffer线程安全的适用于多线程、StringBuilder线程不安全,适合单线程,但是性能高.StringBuffer StringBuilder的用法一样QUESTION 9Answer: ( B, D, E )A 错误,聚合中的对象实现了serializable就能被序列化 一个类包含另外一个类就是聚合.A的描述和对象是否支持序列化没有直接关系B 正确 java是跨平台的,序列化的工作也统一交给各个平台的jvm来处理C 错误,不是volatile而是transient; 有这个transient瞬态关键字的话,就不能序列化了

15、! Volatile这个修饰符的变量,实现的和多线程同步的方法类似,但是不是很好用!D 正确 transient 瞬态的对象是不支持序列化的E 正确,只要子类实现serializable, 不用考虑父类有无实现serializable参考大纲:IO操作 对象的序列化QUESTION 10Given the exhibit:What is the result? A. short Long B. SHORT LONG C. Compilation fails D. An exception is thrown at runtimeAnswer: ( C ) 向上就近原则.第20行的go(z)将会

16、依序找go(int i), go(long l),go(float f), go(double d) 或go(Integer i)方法.但是并不会自动向上转型Long然后再呼叫go(Long n),这种依顺序向上找的特性只会发生在对应端基本资料型别的情况下,参考大纲:面向对象 重载; 实用API 自动封包、拆包QUESTION 11Given the exhibit: * d is valid , non-null Date object * df is a valid, non-null DateFormat object set to the current local What outp

17、uts the current locals country name and the appropriate version of Ds date? A. Locale loc = Locale.getLocal ( ); System.out printIn (loc.getDisplayCountry ( ) B. Locale loc = Locale.getDefault ( ); System.out printIn (loc.getDisplayCountry ( ) + +df. format (d) ); C. Locale loc = Locale.getLocal ( )

18、; System.out printIn (loc.getDisplayCountry ( ) + +df. setDateFormat (d) ); D. Locale loc = Locale.getDefault ( ); System.out printIn (loc.getDisplayCountry ( ) + +df.seDateFormat (d) );Answer: ( B )A Locale类没有getLocal()方法,编译错误B 正确C 错误Locale类没有getLocal( )方法 DateFormat没有setDateFormat( )方法,编译错误D DateF

19、ormat没有setDateFormat( )方法 编译错误参考大纲:实用API java.util包 和java.text包 QUESTION 12Given the exhibit: What is the result? A. Compilation fails. B. An exception is thrown at runtime C. The code executes and prints running D. The code executes and prints runningrunning E. The code executes and prints runningr

20、unninigrunningAnswer: ( E )t.run()调用main主线程去执行2-4行的run(),就是一次普通的方法调用 ;t.start()表示起用thread线程负责去执行2-4行的run(); 把2-4行的代码改为:public void run() String threadName=Thread.currentThread().getName();System.out.println(threadName+”:running”);这样就可以看出是谁调用了run()了,显示如下:main : runningmain : runningThread-o : running

21、参考大纲:多线程QUESTION 13-仔细看看Exhibit:Which two are possible results? (choose two) A. 0,2,4,4,6,8,10,6, B. 0,2,4,6,8,10,2,4,C. 0,2,4,6,8,10,12,14, D. 0,0,2,2,4,4,6,6,8,8,10,10,12,12,14,14, E. 0,2,4,6,8,10,12,14,0,2,4,6,8,10,12,14,Answer: ( A, C)A 第一个线程循环到第三遍使得x等于4,并执行完第8句后挂起(此时current也是4);第二个线程开始执行,执行完以后第

22、一个线程接着执行最后一次循环,打印6C 两个线程依次执行参考大纲:多线程QUESTION 14Given the exhibit: Which statement is true? A. This code may throw an InterruptedException B. This code may throw an IllegalStateExcepion C. This code may throw a TimeOutException after ten minutes D. This code will not compile unless obj.wait ( ) is re

23、placed with ( Thread) obj) .wait ( ) E. Reversing the order of obj.wait ( ) and obj. notify ( ) may vcause this method to complete normally Answer: ( A ) 首先编译通不过, 第5行:void waitForSignal() throws InterruptedException.第6行: Object obj=new Object();obj=Thread.currentThread();第7行应该是:synchronized(obj);-在写

24、wait()和notify()方法时,除了要写在synchronized区段,.还需要撰写InterruptedException异常的try-catch. 本题就算写了try-catch,也可能会在执行的时候产生current thread not owner的IllegalMonitorStateException 的异常.参考大纲:多线程 同步处理QUESTION 15Given the exhibit: What can be a result?A. Compilation fails B. An exception is thrown at runtime C. The code e

25、xecutes and prints StartedComplete D. The code executes and prints StartedComplete0123 E. The code executes and prints Started0123CompleteAnswer: ( E )Join()方法使得某个线程加入到正在执行的线程(本题是main线程)中,执行完该线程才继续执行main线程.本程序中第5行由main线程执行,6行因为下达了join(),所以mian的执行将被暂停,等t做完run()方法的全部工作之后,才论到main继续执行未完成的工作!参考大纲:多线程 QUE

26、STION 16Which two code fragments will execute the method doStuff ( ) in a separate thread? (choose two) A. new Thread ( ) public void run ( ) doStuff ( ); ; B. new Thread ( ) public void start ( ) doStuff ( ); ; C. new Thread ( ) public void run ( ) doStuff ( ); .run ( ); D. new Thread ( ) public vo

27、id run ( ) doStuff ( ); .start ( ); E. new Thread (new Runable ( ) public void run ( ) doStuff ( ); ). run ( ) ; F. new Thread (new Runnable ( ) public void run ( ) doStuff ( ); ).start ( );Answer: ( D、F )D 匿名类别中复写run方法,并调用start()方法启动线程F 利用匿名实现runnable接口中的run方法,并调用start()启动线程参考大纲:多线程QUESTION 17Which

28、 three will compile and run without exception? (choose three) A. private synchronized object o; B. void go ( ) synchronized ( ) /* code here */ C. public synchronized void go ( ) /* code here */ D. private synchronized (this) void go ( ) /* code here */ E. void go ( ) synchronized (Object.class) /*

29、code here */ F. void go ( ) synchronized (o) /* code here */ Answer: ( C, E, F )A 错误synchronized不可以成为属性/变量的修饰符B 错误synchronized ( )中的括号中要加入欲锁定的物件或类型 / synchronized(this)C 正确 利用synchronized来修饰对象instance方法,锁定的物件将会是this,D 错误 修饰方法时,this不用特别在synchronized ()中指明E 正确 合法的 class literals synchronized /针对某个类同步F

30、 正确 合法的 instance block synchronized /针对某个对象同步参考大纲:多线程 线程同步QUESTION 18Exhibit: What is the result? A. The code will deadlock B. The code may run with no output C. An exception is thrown at runtime D. The code may run with output 0 6 E. The code may run with output 2 0 6 4 F. The code may run with output 0 2 4 6 Answer: ( F )情况1 run方法运行以后运行 再调用getResult();情况2先调用getResult(),挂起,等待run()方法修改isComplete的值线程0, 线程1, 线程2, 线程3, main 共有5个线程,中间线程执行的顺序如上面所说的,但是最后的结果是main的for(Compu

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

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