




已阅读5页,还剩8页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
极客营十营第四、五周考试试卷总分:100分 时间:140分钟 (14:00至16:20)单选题 ( 共25题)第1题(分值:2分)当试图编译并运行下面程序时会出现什么结果?class Apublic int getNumber(int a)return a+1;class B extends A public int getNumber(int a, char c)return a+2;public static void main(String args)B b=new B();System.out.println(b.getNumber(0);A:编译错误B:运行错误C:1D:2第2题(分值:2分)下面程序在fun()方法当出现数组下标超过界限的情况下的输出结果是:()public void test()try fun(); System.out.print(“情况1”);catch(ArrayIndexOutOfBoundsException e) System.out.print(“情况2”);catch(Exception e)System.out.print(“情况3”);finally System.out.print(“finally”);A:情况1B:情况2C:情况2finallyD:情况3finally第3题(分值:2分)当编译并运行下面程序时会发生什么结果?public class Bground extends Threadpublic static void main(String argv)Bground b = new Bground();b.start();public void run()for(int i = 0;i10;i+)System.out.println(值为: i=+i);public void start()for (int i = 10; i 20; i+)System.out.println(Value of i = + i);A:编译错误,指明run方法没有定义B:运行错误,指明run方法没有定义C:编译通过并输出0到9D:编译通过并输出10到19第4题(分值:2分)当编译并运行下面程序时会发生什么结果?public class Bground extends Thread public static void main(String argv)Bground b = new Bground();b.run(); public void start() for (int i = 0; i 10; i+)System.out.println(Value of i = + i); A:编译错误,指明run方法没有定义B:运行错误,指明run方法没有定义C:编译通过并输出0到9D:编译通过但无输出第5题(分值:2分)Java中,以下( )接口以键_值对的方式存储对象。A:java.util.CollectionB:java.util.MapC:java.util.ListD:java.util.Set第6题(分值:2分)给出下面程序:23. Object myObjects = 24. new integer(12),25. new String(”foo”),26. new integer(5),27. new Boolean(true)28. ;29. Arrays.sort(myObjects);30. for( int i=0; i2)?4:5); 其运行结果是()A:2B:3C:4D:5第23题(分值:2分)Given: 10. interface Avoid x(); 11. class B implements Apublic void x() public void y() 12. class C extends Bpublic void x()And: 20. java.util.List list = new java.util.ArrayList(); 21. list.add(new B(); 22. list.add(new C(); 23. for(A a : list) 24. a.x(); 25. a.y(); 26. What is the result?A. The code runs with no output.B. An exception is thrown at runtime.C. Compilation fails because of an error in line 20.D. Compilation fails because of an error in line 21.E. Compilation fails because of an error in line 23.F. Compilation fails because of an error in line 25.第24题(分值:2分)Given: 1. import java.util.*; 2. public class WrappedString 3. private String s; 4. public WrappedString(String s)this.s = s; 5. public static void main(String args) 6. HashSet hs = new HashSet(); 7. WrappedString ws1 = new WrappedString(aardvark); 8. WrappedString ws2 = new WrappedString(aardvark); 9. String s1 = new String(aardvark); 10. String s2 = new String(aardvark); 11. hs.add(ws1); hs.add(ws2); hs.add(s1); hs.add(s2); 12. System.out.println(hs.size(); What is the result?A. 0B. 1C. 2D. 3E. 4F. Compilation fails.G. An exception is thrown at runtime.第25题(分值:2分)Given: 3. import java.util.*; 4. public class Mapit 5. public static void main(String args) Set set = new HashSet(); 6. 7. Integer i1 = 45; 8. Integer i2 = 46; 9. set.add(i1); 10. set.add(i1); 11. set.add(i2); System.out.print(set.size() + ); 12. set.remove(i1); System.out.print(set.size() + ); 13. i2 = 47; 14. set.remove(i2); System.out.print(set.size() + ); 15. 16. What is the result?A. 2 1 0B. 2 1 1C. 3 2 1D. 3 2 2E. Compilation fails.F. An exception is thrown at runtime.不定项选题 ( 共5题)第26题(分值:3分)abstract public class Employee protected abstract double getSalesAmount(); public double getCommision() return getSalesAmount() * 0.15; class Sales extends Employee 17./ insert method here哪段代码填入第17行是正确的? ()A: double getSalesAmount() return 1230.45; B: public double getSalesAmount() return 1230.45; C:private double getSalesAmount() return 1230.45; D:protected double getSalesAmount() return 1230.45; 第27题(分值:3分)以下对自定义异常描述正确的是。( )A:自定义异常必须继承ExceptionB:自定义异常可以继承自ErrorC:自定义异常可以更加明确定位异常出错的位置和给出详细出错信息D:程序中已经提供了丰富的异常类,使用自定义异常没有意义第28题(分值:3分)以下关于对象序列化描述正确的是()A:使用FileOutputStream可以将对象进行传输B:使用PrintWriter可以将对象进行传输C:使用ObjectOutputStream类完成对象存储,使用ObjectInputStream类完成对象读取D:对象序列化的所属类需要实现Serializable接口第29题(分值:3分)(异常的捕获和抛出)有如下代码import java.io.*;import java.sql.*;class TestExceptionpublic static void main(String args)tryma();/codingcatch(Exception e)public static void ma() throws IOException 下面哪些代码放在coding处可以编译通过?A:catch(NullPointerException npe)B:catch(IOException ioe)C:catch(SQLException sqle)D:catch(Throwable e)第30题(分值:3分)假设每个类中都有setCountry方法.10. public class Money 11. private String country, name;12. public getCountry() return country; 13.and:24.class Yen extends Money 25. public String getCountry() return super.country; 26.28.class Euro extends Money 29. public String getCountry(String timeZone) 30. return super.getCountry();31. 32.下面哪个描述是正确的? ( )A:A. 类Yen 中getCountry()方法是正确的B:类Euro中getCountry()方法是正确的C:程序运行时会抛出一个异常D:类Yen 和 Euro 的getCountry()方法都是正确的E:编译异常,由于25行抛出异常F:编译异常,由于30行抛出异常填空题 ( 共3题)第31题(分值:3分)请阅读下列程序代码,写出程序的执行结果。publicclassthrowsExceptionstaticvoidProc(intsel) throwsArithmeticException,ArrayIndexOutOfBoundsExceptionSystem.out.println(InSituation+sel);if(sel = 0) System.out.println(noExceptioncaught); return;elseif(sel = 1) intiArray=newint4; iArray1=3;publicstaticvoidmain(Stringargs)try Proc(0); Proc(1);catch(ArrayIndexOutOfBoundsExceptione) System.out.println(Catch+e);finally System.out.println(inProcfinally);执行结果:_第32题(分值:3分)public class Unchecked public static void main(String args) try method(); catch (Exception e) System.out.print(A); finally System.out.print(B); static void method() try wrench(); System.out.print(C); catch (ArithmeticException e) System.out.print(D); finally System.out.print(E); System.out.print(F); sta
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年方大炭素新材料科技股份有限公司招聘127人笔试参考题库附带答案详解
- 2025年国网新源集团有限公司高校毕业生招聘(第二批)调剂笔试参考题库附带答案详解
- 2025年合肥公交集团有限公司驾驶员招聘180人笔试参考题库附带答案详解
- 2025年中国烟草总公司辽宁省公司人员招聘168人笔试参考题库附带答案详解
- 危险运输安全培训
- 2025内蒙古中材科技(锡林郭勒)风电叶片有限公司招聘32人笔试参考题库附带答案详解
- 危险品安全管理培训
- 地球运动与气候
- 危化安全员培训记录课件
- 嘉兴油车港安全生产培训课件
- 上海市静安区2022-2023学年高一下学期期末数学试题(解析版)
- TPM管理知识培训
- 2023年国家公务员考试申论真题及答案解析(地市级)
- 关于无梁楼盖和梁板式楼盖经济性的比较
- 第十四杂环化合物
- RB/T 306-2017汽车维修服务认证技术要求
- 《数学软件》课程教学大纲
- 《细胞工程学》考试复习题库(带答案)
- 粤教花城版小学音乐歌曲《哈哩噜》课件
- 第六讲:RCEP服务贸易与投资解读课件
- 展筋丹-中医伤科学讲义-方剂加减变化汇总
评论
0/150
提交评论