


版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、1. Which two demonstrate an is a relationship? (Choose Two)A. public interface Person public class Employee extends Person B. public interface Shape public class Employee extends Sha pe C. public interface Color public class Employee extends Color D. public class Species public class Animalprivate S
2、pecies species;E. interface Component Class Container implements Component (Private Component children;Answer:de2. Given:1. package foo;2.2. public class Outer (3. public static class Inner (5-)6. )Which statement is true?A. An instance of the Inner class can be constructed with new Outer.lnner ()B.
3、 An instance of the inner class cannot be constructed outside of package fooC. An instance of the inner class can only be constructed from within the outer classD. From within the package bar, an instance of the inner class can be constructed with new inner 。Answer:c3. Exhibit :1 public class enclos
4、inggone2 public class insideone34 public class inertest5 public static void main (String args)6 enclosingone eo = new enclosingone();7 /insert code here8Which statement at line 7 constructs an instance of the inner class?A. InsideOne ei = eo.new lnsideOne();B. B. Eo.InsideOne ei = eo.new lnsideOne()
5、;C InsideOne ei = EnclosingOne.new lnsideOne();D.EnclosingOne InsideOne ei = eo.new lnsideOne();Answer:aC. 4.D. 1) class SuperE. 2) public float getNum()return 3.Of;F. 3) G. 4)H. 5) public class Sub extends SuperI. 6)J. 7) K. which method, placed at line 6, will cause a compiler error?L. A. public f
6、loat getNum()return 4.Of;M. B. public void getNum()N. C. public void getNum(double d)O. D. public double getNum(float d)return 4.0d;Answer:B5.1) public class Foo2) public static void main(String args)3) tryreturn;4) finally System.out.println(Finally);5) 6) what is the result?A. The program runs and
7、 prints nothing.B. The program runs and prints Tinally.C. The code compiles, but an exception is thrown at runtime.D. The code will not compile because the catch block is missing.Answer:b6./point X public class Foopublic static void main(String args)Printwriter out=new PrintWriter(new java.io.Output
8、StreamWriter(System.out),true);out.println(Hello);which statement at point X on line 1 allows this code to compile and run?A. import java.io.PrintwriterB.includeC. import java.io.OutputStreamWriter D.includeE. No statement is neededAnswer:a7. which three are valid declaraction of a float?A. float fo
9、o=-1;B. float foo=1.0;C. float foo=42e1;D. float foo=2.02f;E. float foo=3.03d;F. float foo=0x0123;Answer:adfint index=1; int foo=new int3; int bar=fooindex;int baz=bar+index; what is the result?A. baz has a value of 0B. baz has value of 1C. baz has value of 2D. an exception is thrownE. the code will
10、 not compileAnswer:b9.1) int i=1,j=10;2) do3) if(i+-j) continue; 192837464) while(ij)continue;j; while(+i6); what are the vale of i and j?A. i=6,j=5B. i=5,j=5C. i=6,j=4D. i=5,j=6E. i=6,j=6Answer: A20.byte array 1 ,array2 byte array3 byte array4if each has been initialized, which statement will cause
11、 a compile error?A. array2 = array 1;B. array2 = array3;C. array2 = array4;D. both A and BE. both A and CF. both B and CAnswer: a21.which four types of objects can be thrown use throws?A. ErrorB. EventC. ObjectD. ExcptionE. ThrowableF. RuntimeExceptionAnswer: A,D,E, F22.1) public class Test2) public
12、 static void main(String args)3) unsigned byte b=0;4) b-;5)5) 6) what is the value of b at line 5?A. -1 B.255 C.127 D.compile fail E.compile succeeded but run errorAnswer: d23.public class ExceptionTestclass TestExcepti on exte nds Excepti onpublic void runTest() throws TestExceptionpublic void test
13、() /* point x */ runTest();At point x, which code can be add on to make the code compile?A. throws ExceptionB. catch (Exception e)C. throws RuntimeExceptionD. catch (TestException e)E. no code is necessaryAnswer: A24.String foo=blue;boolean bar=new boolean1;if(barO) foo=green;what is the value of fo
14、o?A. B.null C.blue D.greenAnswer: C25.which two are equivalent?3/2323*43?23*2A3?10&methodB(1);10. b=i10&methodB(2);11. 14.12. public static void main(String args) 13. methodA(O);17.14. 15. What is the value of j at line 17?A. 0B. 1C. 2D. 3E. The code will not compile.Answer: B43.public class Testpub
15、lic static void main(String args) String foo=blue;4) String bar=foo;5) foo=green;6) System.out.println(bar);what is the result?A. An exception is thrown.B. The code will not compile.C. The program prints null.D. The program prints blue.E. The program prints green.Answer: D44.class Apublic int getNum
16、ber(int a)return a+1;class B extends Apublic int getNumber(int a, char c)return a+2;public static void main(String args)B b=new B();14) System.out.println(b.getNumber(0);what is the result?A. compilation succeeds and 1 is printedB. compilation succeeds and 2 is printedC. An error at line 8 cause com
17、pilation to failD. An error at line 14 cause compilation to failAnswer: a45.You are assigned the task of building a Panel containing a TextArea at the top, a Labbel directly bellow it, and a Button directly bellow the Label. If the three components added directly to the Panel, which layout manager c
18、an the Panel use to ensure that the TextArea absorbs all of the free vertical space when the Panel is resized?A.GridLayoutB.CardLayoutC.FIowLayoutD.BorderLayoutE.GridbagLayoutAnswer: e46.which two are true to describe an entire encapsulation class?A. member data have no access modifiersB. member dat
19、a can be modified directlyC. the access modifier for methods is protectedD. the access modifier to member data is privateE. methods provide for access and modification of dataAnswer: d,e47.public class X implements Runnablepublic static void main(String args)3) /insert codepublic void run()int x=0,y
20、=0;for(;)x+;Y+;System.out.println(x=+x+,y=+y);You want to cause execution of the run method in a new thread of execution.Which line(s) should be added to the main method at line 3?A. X x=new X();x.run();B. X x=new X();new Thread(x).run();C. X x=new X();new Thread(x).start();D. Thread t=new Thread(x)
21、.run();E. Thread t=new Thread(x).start();Answer: a,c48.which gets the name of the parent directory of file file.txt?A. String name=File.getParentName(file.txt);B. String name=(new File(file.txt).getParent();C. String name=(new File(file.txt).getParentName();D. String name=(new File(file.txt).getPare
22、ntFile();E. Diretory dir=(new File(file.txt).getParentDir();String name=dir.getName();Answer: b49.The file file.txt exists on the file system and contains ASCII text. tryFile f=new File(file.txt);Outputstream out=new FileOutputStream(f);catch (lOException e)A. the code does not compileB. the code ru
23、ns and no change is made to the fileC. the code runs and sets the length of the file to 0D. An exception is thrown because the file is not closedE. the code runs and deletes the file from the file systemAnswer: c50.The file file.txt exists on the file system and contains ASCII text. Given:38. try 39
24、. File f = new File( file.txt);40. Outputstream out = new FileOutputStream(f, true);41. 42. catch (lOException) What is the result?A. The code does not compile.B. The code runs and no change is made to the file.C. The code runs and sets the length of the file to 0.D. An exception is thrown because t
25、he file is not closed.E. The code runs and deletes the file from the file system.Answer:A51.import java.io.lOException;public class ExceptionTestpublic static void main(String args)trymethodA();catch(IOException e)System.out.println(Caught Exception);public void methodA()throw new IOException();what
26、 is the result?A. The code will not compileB. The output is Caught ExceptionC. The output is Caught lOExceptionD. The program executes normally without printing a messageAnswer: a52.Which two can directly cause a thread to stop executing? (Choose Two)A. Exiting from a synchronized block.B. Calling t
27、he wait method on an object.C. Calling the notify method on an object.D. Calling the notifyAII method on an object.E. Calling the setPriority method on a thread object.Answer: B, E53.You need to store elements in a collection that guarantees that no duplicates are stored and all elements can be access in nature order, which interace provides that capability?A.B.C.D. java.utiLSortedSetE.F. java.utiLCollectionAnswer: B54.which two cannot directly cause a thread to stop executing?A. calling the yield methodB
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 东南大学成贤学院《中国古代文学6》2023-2024学年第二学期期末试卷
- 长春师范高等专科学校《核科学与技术前沿》2023-2024学年第二学期期末试卷
- 安阳职业技术学院《企业大数据技术与应用》2023-2024学年第二学期期末试卷
- 江苏海洋大学《机器学习实验》2023-2024学年第二学期期末试卷
- 动画人物设计全流程解析
- 2024年印花纹理项目资金需求报告代可行性研究报告
- 2025年四川自贡市城投医疗健康产业发展有限公司招聘笔试参考题库含答案解析
- 埃及金字塔教学设计
- 2025年江苏南通市新城园林绿化有限公司招聘笔试参考题库附带答案详解
- 2025年广东湛江市水务投资集团有限公司招聘笔试参考题库附带答案详解
- DBJ04∕T 416-2020 农村宅基地自建住房技术指南(标准)
- 归档范围和保管期限(8号令)讲解课件
- 瓦斯抽放泵培训PPT课件
- GA 1517-2018 金银珠宝营业场所安全防范要求
- 施工设计方案客土喷播
- 疑似预防接种异常反应(AEFI)监测与处理PPT课件
- 德森印刷机常见问题点维修参考手册
- 输电线反时限零序电流保护_图文
- 强对阵图模板(共1页)
- 最新三级安全教育考试卷(防水工)带答案
- 民营医院市场部业务员业绩提成制度
评论
0/150
提交评论