版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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 cl
2、ass Animalprivate Species species;E. interface Component Class Container implements Component (Private Component children;二 which statement is true?A. An anonymous inner class may be declared as finalB. An anonymous inner class can be declared as privateC. An anonymous inner class can implement muti
3、ple interfacesD. An anonymous inner class can access final variables in any enclosing scope (不能)E. Construction of an instance of a static inner class requires an instance of the encloing outer class构造一个静态的内部类对象需要构造包含它的外部类的对象三 . Given:1. package foo;2.3. public class Outer (4. public static class In
4、ner (5. )6. )Which statement is true?A. An instance of the Inner class can be constructed with “new Outer.Inner () ”B. An instance of the inner class cannot be constructed outside of package foo他们都是 public 的,只要在外部import 就行C. An instance of the inner class can only be constructed from within the oute
5、rclassD. From within the package bar, an instance of the inner class can be constructed with “new inner() ”四.Exhibit (展览、陈列):1 public class enclosinggone2 public class insideone3 4 public class inertest5 public static void main (String args)6 enclosingone eo = new enclosingone();7 /insert code here8
6、 Which statement at line 7 constructs an instance of the inner class?A. InsideOne ei = eo.new InsideOne(); 写程序试出来B. Eo.InsideOne ei = eo.new InsideOne();C InsideOne ei = EnclosingOne.new InsideOne();D.EnclosingOne InsideOne ei = eo.new InsideOne();五1) interface Foo2) int k=0;3) 4) public class Test
7、implements Foo5) public static void main(String args)6) int i;7) Test test=new Test();8) i=test.k;9) i=Test.k;10) i=Foo.k;11) 12) What is the result?A. Compilation succeeds.B. An error at line 2 causes compilation to fail.C. An error at line 9 causes compilation to fail.D. An error at line 10 causes
8、 compilation to fail.E. An error at line 11 causes compilation to fail.六/point Xpublic class Foopublic static void main(String args)PrintWriter out=new PrintWriter(newjava.io.OutputStreamWriter(System.out),true);out.println("Hello");which statement at point X on line 1 allows this code to
9、compile and run?在 point X 这个位置要填入什么代码才能使程序运行A.import java.io.PrintWriter B.include java.io.PrintWriterC.import java.io.OutputStreamWriter D.include java.io.OutputStreamWriterE.No statement is needed本来两个都要import ,但是后者 OutputStreamWriter 指定了包结构java.io.OutputStreamWriter七 what is reserved words in java
10、? 保留字而非关键字A. runB. defaultC. implementD. import八 . which three are valid declaraction of a float?(float 作为整数是可以的,其余几个都是double )A. float foo=-1;B. float foo=1.0;C. float foo=42e1;D. float foo=2.02f;E. float foo=3.03d;F. float foo=0x0123;九 . Given:8. int index = 1;false)9. boolean test = new boolean3;
11、 (数组作为对象缺省初始化为10. boolean foo= test index;What is the result?A. foo has the value of 0B. foo has the value of nullC. foo has the value of trueD. foo has the value of falseE. an exception is thrownF. the code will not compile十 . Given:1. public class test(2. public static void main(Stringargs)3. Stri
12、ng foo = args 1;4. String foo = args 2;5. String foo = args 3;6. 7. And the command line invocation:Java TestWhat is the result?A. baz has the value of “”8. baz has the value of null9. baz has the value of “red ”10. baz has the value of “blue ”11. bax has the value of “green”12. the code does not co
13、mpile13. the program throws an exception(此题题目出错了,重复定义了变量foo,如果没有重复的话,应选 G,因为只传递了 0-2 三个数组元素,而题目中需要访问 args 3 ,所以会抛出数组越界异常) int index=1;int foo=new int3;int bar=fooindex; /bar=0int baz=bar+index; /baz=1 what is the result?A. baz has a value of 0B. baz has value of 1C. baz has value of 2D. an exception
14、 is thrownE. the code will not compile1) public class Foo2) public static void main(String args)3) String s;4) System.out.println("s="+s);5) 6) what is the result?A. The code compiles and “s= ” is printed.B. The code compiles and “s=null ” is printed.C. The code does not compile because st
15、ring s is not initialized.D. The code does not compile because string s cannot be referenced.E. The code compiles, but a NullPointerException is thrown when toString is called.十三 . Which will declare a method that forces a subclass to implement it?(谁声明了一个方法,子类必须实现它)A. public double methoda();B. stat
16、ic void methoda (double d1) C. public native double methoda();D. abstract public void methoda();E. protected void methoda (double d1)十四 .You want subclasses in any package to have access to members of a superclass.Which is the most restrictive access modifier that will accomplish this objective?(你希望
17、子类在任何包里都能访问父类, 为完成这个目的, 下列哪个是最严格的访问权限)A. PublicB. PrivateC. ProtectedD. TransientE. No access modifier is qualified十五 . Given:1. abstract class abstrctIt 2. abstract float getFloat ();3. )4. public class AbstractTest extends AbstractIt 5. private float f1= 1.0f;6. private float getFloat () return f1
18、;7. What is the result?A. Compilation is successful.8. An error on line 6 causes a runtime failure. (抛出实时异常)9. An error at line 6 causes compilation to fail.10. An error at line 2 causes compilation to fail.(子类覆盖父类方法的时候,不能比父类方法具有更严格的访问权限)十六 . Click the exhibit button:1. public class test2. public in
19、t aMethod()3. static int i=0;4. i+;5. return I;6. 7. public static void main (String args)8. test test = new test();9. test.aMethod();10. int j = test.aMethod();11. System.out.printIn(j);12. 13. (局部变量不能声明为静态)What is the result?A. Compilation will fail.B. Compilation will succeedandtheprogram willpri
20、nt“0 ”.C. Compilation will succeedandtheprogram willprint“1 ”.D. Compilation will succeedandtheprogram willprint“2”.十七 .1) class Super2) public float getNum()return 3.0f;3) 4)5) public class Sub extends Super6)7) which method, placed at line 6, will cause a compiler error?A. public float getNum()return 4.0f;B. public void getNum() 返回值类型不同不足以构成方法的重载C. public void getNum(double d)D. public double getNum(float d)return 4.0d;十八 . Which declaration prevents creating a subclass of an outer class?A.static class FooBarB.pivate class FoobarC.abstract class FooBarD.final public class FooBarE.final
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 学校保证书中的学生权益维护
- 企业宣传册印刷服务合同
- 供货与采购合同
- 摄影镜头采购协议
- 高效劳务分包合同设计
- 方案招标文件实践
- 地理环境与社会发展考核试卷
- 农村房屋施工合同范例
- 农村打横井合同范例
- 工程合作定金合同范例
- 软件平台施工组织方案
- 2024年部编版高一上学期期末语文试卷及解答参考
- 2024年新人教版四年级数学下册《第9单元 数学广角-鸡兔同笼》教学课件
- 11.20世界慢阻肺日认识你的肺功能慢阻肺防治科普课件
- 2024秋期国家开放大学《西方行政学说》一平台在线形考(任务一至四)试题及答案
- 检验科生物安全工作总结
- 《ESPEN重症病人营养指南(2023版)》解读课件
- 2024年广东省广州市南沙区纪委监委招聘1人历年高频难、易错点500题模拟试题附带答案详解
- 追觅科技笔试在线测评题
- 第六单元测量(大单元教学设计)-2024-2025学年二年级上册数学北师大版
- Unit6《Is he your grandpa?》-2024-2025学年三年级上册英语单元测试卷(译林版三起 2024新教材)
评论
0/150
提交评论