SCJP题库 带达内考点分析⑤_⑧答案.doc_第1页
SCJP题库 带达内考点分析⑤_⑧答案.doc_第2页
SCJP题库 带达内考点分析⑤_⑧答案.doc_第3页
SCJP题库 带达内考点分析⑤_⑧答案.doc_第4页
SCJP题库 带达内考点分析⑤_⑧答案.doc_第5页
全文预览已结束

下载本文档

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

文档简介

ANSWERModule 51.BCD 2. E 3.BDE 4.C 5.D 6.D 7.D 8.B 拖拽题1. Answer:String path = ;for(String dir : directories)path = path + File.separator + dir;File file = new File(path, filename);return file.exists();2. Answer: reader=new BufferedReader(new FileReader(in);writer=new BufferedWriter(new PrintWriter(new FileWriter(out);或 writer=new PrintWriter(new BufferedWriter(new FileWriter(out);3. Answer:tryString temp;while(temp=buffReader.readLine()!=null)System.out.println(temp);catch(IOException e)e.printStackTrace();4. Answer:import java.io.*;public class ReadFile public static void main(String args) tryFile x1 = new File(MyText.txt);feredReader x4 = new BufferedReader(x2);String x3 = null;while(x3 = x4.readLine() != null)System.out.println(x3);x4.close();catch(Exception ex)ex.printStackTrace();Module 61.D 2.BC 3.A 4.D 5.C 6.D 7.C 8.B 9.A 10.C 11.BE 12.D 13.A 14.E 15.CF 16.B 17.FG 18.D 19.B 20.C 21.D 22.B 23.D拖拽题1. Answer:Pi is approximately 3.141593 and E is approximately true2. Answer:while(scanner.hasNext()if(scanner.hasNextBoolean()System.out.println(scanner.nextBoolean() + ); else scanner.next();Module 71.A 2.B 3.A 4.C 5.D 6.D 7.D 8.F 9.B 10.B 11.B 12.B 13.AD 14.B 15.A 16.CE 17.A 18.B 19.AC 20.B 21.D 22.G 23.C 24.C 25.C 26.ACF 27.CDG 28.D 29.ABDE 30.ADE 31.DF 32.A拖拽题1. Answer:allows access to elements by their integer index-java.util.Listdefines the method V get(Object key)-java.util.Mapis designed for holding elements prior to processing-java.util.Queuecontains no pair of elements e1 and e2, such that e1.equals(e2)-java.util.Set2. Answer:public class NumberNamesprivate HashMapmap=new HashMap;public void put(String name,int value)map.put(name,value);public Set getNames()return map.keySet();3. Answer: m1(listA); Compiles and runs without errorm2(listA); Compiles and runs without errorm1(listB); Compiles and runs without errorm2(listB); Compilation failsm1(listO); Compilation failsm2(listO); Compilation fails4. Answer: import java.util.*;public class MyInt implements Comparablepublic static void main(String args) ArrayList list=new ArrayList();list.add(new MyInt(2);list.add(new MyInt(1);Collections.sort(list);System.out.println(list);private int i;public MyInt(int i)this.i=i;public String toString()return Integer.toString(i);public int compareTo(Object o) MyInt i2=(MyInt)o;return i-i2.i;5. Answer:public void takeList(ArrayList list) -Compilation succeedspublic void takeList(ArrayList list) -Compilation succeedspublic void takeList(ArrayList list) -Compilation failspublic void takeList(ArrayList list)-Compilation succeedspublic void takeList(ArrayList list)-Compilation succeedspublic void takeList(ArrayList list) -Compilation fails6. Answer:public class GenericBpublic T foo;public void setFoo(T foo)this.foo = foo;public T getFoo()return foo;7. Answer:ArrayList x1=new ArrayList();foo(x1); /Compilation of the first statement succeeds, but compilation failsdue to an error in the second statementArrayList x2=new ArrayList();foo(x2); /Compilation fails due to an error in the first statement.ArrayList x3=new ArrayList();foo(x3); /Compilation succeedsArrayList x4=new ArrayList();foo(x4); /Compilation succeeds8. Answer:public class Genprivate T object;public Gen(T object)this.object = object;public T getObject()return object;9. Answer:list.add(Foo); Compilation failslist = new ArrayList(); Compilation succeedslist = new ArrayList(); Compilation failsString s = list.get(0); Compilation succeedsObject o = list; Compilation succeeds10. Answer:import java.util.*;public class _166 public static void main(String args) List list=new LinkedList();list.add(one);list.add(two);System.out.println(list.get(0).length();Module 81.DF 2.B 3.E 4.AC 5.B 6.C 7.DE 8.D 9.C 10.E 11.F 12.A 13.E 14.G 15.ACE 16.EG 17.AD 18.CEF 19.E 20.ABE拖拽题1. Answer:startedraninterruptingendedno more output2. Answer:t.run();t.join();t.doIt();3. Answer:public class Flags2 private boolean isReady=false;public synchronized void produce()isReady=true;notifyAll();public synchronized void consume(

温馨提示

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

评论

0/150

提交评论