JavaSE综合考试题.doc_第1页
JavaSE综合考试题.doc_第2页
JavaSE综合考试题.doc_第3页
JavaSE综合考试题.doc_第4页
JavaSE综合考试题.doc_第5页
已阅读5页,还剩9页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

中软国际无锡ETC (绝密文件,泄露追究)考试准则:1、 该试卷考试共120分钟。2、 考生应讲诚信并自觉服从监考员等考试工作人员管理,不得以任何理由妨碍监考 员等考试工作人员履行职责,不得扰乱考场及其他考试工作地点的秩序。2、考生须在每科开考前15分钟进入考场,迟到30分钟则不准参加当科考试。3、考生接到试题(卷)后,首先核对试题,若遇到疑问,举手要求更换。4、考生在考场内必须保持安静,不准吸烟;不准喧哗;不准交头接耳、左顾右盼、 打手势、做暗号;不准夹带、旁窥、抄袭或有意让他人抄袭;不准传抄或交换试 题(卷)、答题卡;不准将试题(卷)、答题卡和草稿纸带出或传出考场。中软国际无锡(ETC)实训鉴定考试卷 (第二阶段) 一、选择题(共50分,每题2分)(注意:存在不定项选择)Question NO:1(2分)1public class Test 2. static boolean foo(char c) 3. System.out.print(c);4. return true;5.6. public static void main( String argv ) 7. int i =0;8. for ( foo(A); foo(B)&(i2); foo(C)9. i+ ;10. foo(D);12. 13. 14. What is the result? A. ABDCBDCBB. ABCDABCDC. Compilation fails.D. An exception is thrown at runtime.Question NO:2(2分)1. public class Outer2. public void someOuterMethod() 3. / Line 34. 5. public class Inner6. public static void main( Stringargv ) 7. Outer o = new Outer();8. / Line 89. 10. Which instantiates an instance of Inner? A. new Inner(); / At line 3B. new Inner(); / At line 8C. new o.Inner(); / At line 8D. new Outer().new Inner(); / At line 8 Question NO:3(2分)public class test public static void main(String args) Integer a1 = new Integer(20); Integer a2 = new Integer(20); if(a1= =a2) System.out.println(a1= =a2); if(a1.equals(a2) System.out.println(equals); ; A.equals B.a1= =a2 C.什么都不输出 D.程序错误Question NO:4(2分)下列哪个说法是错误的。 A.程序员可以定义新的异常类 B.Exception 可以用 try/catch 进行捕获处理 C.Exception 可以递交给上一级调用方处理 D.类似像 IOException 等异常 , 程序可以忽略不进行捕获和处理Question NO:5(2分)欲构造 ArrayList 类的一个实例,下列哪个方法是正确的 ? A. ArrayList myList=new Object(); B. List myList=new ArrayList(); C. ArrayList myList=new List(); D. List myList=new List();Question NO:6(2分)(多选)欲构造 使用泛型的ArrayList 类的一个实例,下列哪个方法编译时出错(E)?下列哪个方法运行时出错(D)?A. List list = new ArrayList();B. List list = new ArrayList();C. List list = new ArrayList();D. List list = new ArrayList();E. List list = new ArrayList();F. Collection list = new HashSet();Question NO:7 (2分)public class Example String str=new String(good); charch=a,b,c; public static void main(String args)Example ex=new Example(); ex.change(ex.str,ex.ch); System.out.print(ex.str+ and ); Sytem.out.print(ex.ch); public void change(String str,char ch)str=test ok; ch0=g; What is the result? A.good and abcB. good and gbcC. test ok and abcD. test ok and gbcQuestion NO:8 (2分)1.public class threadTest implements Runnable2. private int x; /1353. public int getData()4. synchronized(this)5. x=123;6. x=x+12;7. 8. return x;9. 10. public void run()11. System.out.println(getData()+ );12. 13. 14. public static void main(String args)15. ThreadTest test=new TheadTest();16. Thread th1= new Thread(test);17. Thread th2= new Thread(test);18. th1.start();19. th2.start();20. 21. What is the result? A)output 123 and 135 on the consoleB)output 123 or 135 recurrence without rule. C)output 135 and 135 on the consoleD) Compilation fails.Question NO:9 (2分)(多选)1.interface myI x=0;3.int Mymethod(int x);4.5.class myImplementation implements myInterface6. public int myMethod(int x)7. return super.x;89.10.public class MyTest11. public static void Main(String args)12. myInterface mi = new myImplementation();13. System.out.println(mi.myMethod(10);14. 15.A.0B.10(在Line 7 的return super.x改成x)C. An exception is thrown at runtime.D. Compilation fails.Question NO:10(2分)下面程序运行之后,变量x的值是()./swap方法的声明public static void swap(int a,int b)int t=a;a=b;b=t;/main方法public static void main(String args)int x=2;int y=3;swap(x,y);A、2 B、3 C、4 D、6Question NO:11(2分)编译并运行下面的Java程序:class Aint var1=1;int var2;public static void main(String args)int var3=3;A a = new A();System.out.println(a.var1+a.var2+var3);将产生()结果。A0B4C3D代码无法编译,因为var2根本没有被初始化Question NO:12(2分)已知A类被打包在packageA , B类被打包在packageB ,且B类被声明为public ,且有一个成员变量x被声明为protected控制方式 。C类也位于packageA包,且继承了B类 。则以下说话正确的是()AA类的实例不能访问到B类的实例 )BA类的实例能够访问到B类一个实例的x成员CC类的实例可以访问到B类一个实例的x成员DC类的实例不能访问到B类的实例Question NO:13(2分)分析下面的Java程序:public class YY public static void main(String args) throws Exception try throw new Exception(); catch(Exception e) System.out.print(Caught in main(); System.out.println(Nothing);输出结果为()。ACaught in main() NothingBCaught in main()CnothingD没有任何输出Question NO:14(2分)分析下面的Java程序:public class YY public static void main(String args) throws Exception System.out.println( method() );private static int method()tryint value = 12/0;return value;catch(Exception e)/System.exit(0);retrun 6;finallyreturn -1;输出结果为()。A0B6C2D-1Question NO:15(2分)运行下列程序, 会产生什么结果public class X extends Thread implements Runnablepublic void run()System.out.println(this is run(); public static void main(String args) Thread t = new Thread(new X(); t.start(); A. 第一行会产生编译错误 B. 第六行会产生编译错误 C. 第六行会产生运行错误 D. 程序会运行和启动 Question NO:16(2分)要从文件 file.dat文件中读出第10个字节到变量C中,下列哪个方法适合? A. FileInputStream in=new FileInputStream(file.dat); in.skip(9);int c=in.read(); B. FileInputStream in=new FileInputStream(file.dat); in.skip(10); int c=in.read(); C. FileInputStream in=new FileInputStream(file.dat); int c=in.read(); D. RandomAccessFile in=new RandomAccessFile(file.dat); in.skip(9); /peek();int c=in.readByte(); Question NO:17(2分)(多选)1、String str = “abcd”;2、String str2 = “a”+”b”+”c”+”d”;3、String str3 = new String(“abcd”);请问第一行产生多少个字符串对象(A)?请问第二行产生多少个字符串对象(D)?请问第三行产生多少个字符串对象(B)?说明:单独每行独立分析上面三行的结果:A. 1B. 2C. 3D. 4Question NO:18(2分)输出结果为:class Parentprivate void method1()System.out.println(Parents method1();public void method2()System.out.println(Parents method2();method1();class Child extends Parentpublic void method1()System.out.println(Childs method1();public static void main(String args)Parent p = new Child();p.method2(); A. compile time errorB. run time errorC. prints: parents method2() parents method1()D. prints: parents method2() childs method1()Question NO:19(2分)当Frame的大小被改变时Frame中的按钮的位置可能被改变时使用的哪一个布局管理器?A. BorderLayoutB. FlowLayoutC. CardLayoutD. GridLayoutQuestion NO:20(2分)哪一个是DataOutputStream的构造方法?A. New DataOutputStream(“in.txt”);B. New DataOutputStream(new file(“in.txt”);C. New DataOutputStream(new writer(“in.txt”);D. New DataOutputStream(new FileWriter(“in.txt”);E. New DataOutputStream(new InputStream(“in.txt”);F. New DataOutputStream(new FileOutputStream(“in.txt”);Question NO:21(2分)怎么样待会线程执行后的结果?A.ThreadB. RunnableC. FutureD. CallableQuestion NO:22(2分)分析下面的Java程序,有几个错误?( )public class Test public static void main(String args) throws Exception System.out.println( method() );private void method()trySystem.out.println(“hello world!”);finallySystem.out.println(“good bye!”);输出结果为()。A0B1C2D3Question NO:23(2分)下面使用文件流是错误的?()A. FileInputStream fis = new FileInputStream (test.txt)B. File file = new File(test.txt);C. File file = new File(c:); File file1 = new File(file,test.txt); FileOutputStream fos = new FileOutputStream(file1);D. FileOutputStream FIS=new FileOutputStream(c:,test.txt);Question NO:24(2分)运行下面程序段: Calendar c = Calendar.getInstance(); c.set(Calendar.YEAR, 2008); c.set(Calendar.MONTH, 1); c.set(Calendar.DATE, 32); SimpleDateFormat sdf = new SimpleDateFormat(yyyy/M/dd); System.out.println(sdf.format(c.getTime();控制台输出的结果是()A. 2008/1/01 B. 2008/3/03 C. 2008/2/01 D. 2008/3/01 E. 这个真不会,但我很厚道Question NO:25(2分)(多选)调用下面的测试代码()。 public static void main(String args) throws Exception EmpService empService = new EmpService(); empService.checkEmp(); 控制台提示如下异常信息: Exception in thread main three.ServiceException: 服务异常 at three.EmpService.checkEmp(EmpService.java:9) at three.CoreTest.main(CoreTest.java:16) Caused by: three.DAOException: 数据访问失败 at three.EmpDAO.getEmp(EmpDAO.java:7) at three.EmpService.checkEmp(EmpService.java:7) . 1 more 下列正确的推断的是()A. ServiceExcepiton一定是RuntimeException的子类 B. ServiceException一定不是RuntimeException的子类 C. EmpService的checkEmp方法抛出异常ServiceException 的原因是由于其调用的EmpDAO的getEmp方法抛出了DAOException D. EmpDAO的getEmp方法抛出异常DAOException 的原因是由于其调用的EmpService的checkEmp方法抛出了ServiceException E. 这个真不会,但我很厚道 二、程序阅读题(共20分):Question NO:1(5分)class Super int i = 10;Super () print();i = 20;void print() System.out.println(Super = + i);public class SubClass extends Super int i = 30;SubClass() print();i = 40;void print() System.out.println( SubClass = + I );public static void main( String args) System.out.println( new SubClass().i );请分析上面Java程序的执行结果 ?20+i,40Question NO:2(5分)1.public class Test2.String para1;3.StringBuffer para2;4.public void method1(String param)5.para1 = param.replace(j,l);6.7.public void method2(StringBuffer param)8.para2 = param.append(c);9.10.public static void main(String args)11.Test obj = new Test();12.obj.method1(new String(java);13.obj.method2(new StringBuffer(java);14.System.out.println(obj.para1);15.System.out.println(obj.para2.toString();16.17.请分析上面Java程序的执行结果 ? Question NO:3(5分)1.Super: 2.package test; 3.public class FatherClass 4.public FatherClass() 5.System.out.println(FatherClass Create); 6. 7. SubClass: 8.package test; 9.import test.FatherClass; 10.public class ChildClass extends FatherClass 11.public ChildClass() 12.System.out.println(ChildClass Create); 13.14.public static void main(String args) 15.FatherClass fc = new FatherClass(); 16.ChildClass cc = new ChildClass(); 17.18.请分析上面Java程序的执行结果 ? Question NO:4(5分)public class Testpublic static void main(String args) File file = new File(C:test);File files = file.listFiles();String str = .tmp;deleteFile(files, str);private static void deleteFile(File files, final String str) / TODO Auto-generated method stubfor (File file : files) if (file.isFile() if (file.getName().indexOf(str) != -1) file.delete(); else deleteFile(file.listFiles(),str); 请分析上面Java程序的执行结果 ?三、问答题(共20分):(第四题和第五题任选一作答)1、 抽象类与接口的区别有哪些?(5分)答:2、 多线程有几种实现方式?(1分)线程通信方法都是什

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论