JAVA试题英文版_第1页
JAVA试题英文版_第2页
JAVA试题英文版_第3页
已阅读5页,还剩2页未读 继续免费阅读

下载本文档

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

文档简介

1、 Wh i ch two demonstrate an is a” re I ationship? (Choose Two)A. pub Iic interface Person )pub Iic interface Shape )pub Iic interface Color Jpubl ic cI ass Species pub Iic class Animalpr ivate Species species;)E. interface Component CI ass Container imp I ements Component (Pr i vate Component childr

2、en;.wh i ch stat emen t i:s true?A.Ananonymousi nnerc I assmaybe dec Iaredas finalB.Ananonymousi nnerclasscanbe declaredas pr ivateC.Ananonymousi nnerclasscanimpIement mut i pIe i nterfacesD.Ananonymousi nnerclasscan access finalvar iables in anyscope(不能)enclosingE. Cons true t i on of an i nst ance

3、 of a stat i c i nner c I ass requ i res an i nst ance of the encIoing outer cI ass 构造一个静态的内部类对象需要构造包含它的外部类的对象三.G i ven:package foo;2.3. public class Outer (4. publ ic static class Inner (5. )6. )Which statement is true?A. An instance of the Inner cI ass can be construeted with new ()nB. An instance

4、 of the i nner c I ass cannot be cons true ted out s i de of package foo他们都是publ ic的,只要在外部import就行C An instance of the inner c I ass can only be cons trucked from wit h i n the outer cI assD. From with i n the package bar, an i nstance of the i nner cI ass can be constructed with new inner ()n(展览、陈列

5、):Exhibit.四1 publ ic cI ass encI osinggone 2 public cI ass insideone)3 )4 public class inertest5 public static void main (Str ing args) 6 encI os i ngone eo = new encI os i ngone ();7 I ns i deOne e i = I ns i deOne 0 ;写程序试出来B. e i = I ns i deOne ():C InsideOne e i = InsideOne();I ns i deOne e i = I

6、 ns i deOne ();五.2)3) 14) pub I i c5)6)7)=new Test ();8)9)10)11)12)1) interface Foo cI ass Test imp I ements Foo pub I ic static void ma i n (Stri ng args) int i ;Test testWhat is the result?A. Comp i I ation succeeds.B.AnerroratI i ne2causescomp i I ationto fail.c.AnerroratI i ne9causescomp i I ati

7、onto fail.D.AnerroratI i ne10causescomp i I ationto fail.E.AnerroratI i ne11causescomp i I ationto fail.B. defau 11C. imp I ementD. impor t八. wh i ch three are valid dec Iaraction of a fIoat?(float作为整数是可以的,其余几个都是double)A. float fooT;B. float foo*C. f I oat foo42e1;D. float foofE. float fooF. float f

8、oo0x0123;九.Given:8. i nt i ndex = 1 ;9. boo I ean test = new boo I ean 3;(数组作为对象缺省初始化为 fa I se)10. boolean foo= test index;What i j the resuIt?A.foohastheva I ueof0B.foohastheva I ueofnu I Ic.foohastheva I ueoft rueD.foohasthevalueoffa I sE an exception is thrownF. the code wi I I not compi le+Given

9、:1.pub I iccI ass test(2.pub I icstatic voidmain(Str ingargs) 3.Str i ngfoo = args1;4.Str i ngfoo = args;5.Str i ng foo = args3;6.)7. 1And the command Iine invocation:Java TestWhiat i j the resuIt?A.bazhasthevaI ueofB.bazhasthevaI ueofnu I Ic.bazhasthevaI ueof“red”D.bazhasthevaI ueof“blue”E.baxhasth

10、evaI ueofgreenF.thecode does notcompileG.theprogramthirows anexcept i on(此题题目出错了,重复定义了变量f。,如果没有重复的话,应选G,因为只传 递了 0-2三个数组元素,而题目中需要访问args 3,所以会抛出数组越界异 常)Hint indexh;int foo=new int3:int bar=fooindex; baz has a value of 0B. baz has vaIue of 1C. baz has vaIue of 2D. an exception is thrownE. the code wi I

11、 I not compi Ie十二.1) pub Iic class Foo 2) pub I ic static void ma i n (Stri ng args) 3) Str ing s;4) s=+s);5) 6) what is the resuIt?A.B.c.D.TheTheTheThecode code code codecompiIes comp i Ies does not does nots二” i s pr i nted. Us=nulIn is printed.E The code comp i I es,i s ca I I ed.andandcompi Ie b

12、ecause str ing s is not initialized compi Ie because string s cannot be referenced but a Nu I I Po int erExcep tion is t hr own when toString十三.Wh i ch wi I I dec I are a met hod that forces a subc I ass to impleme nt it? (谁声明了一个方法,子类必须实现它)A. publ ic double methoda ():B. static void methoda (double

13、d1) )C publ ic nat ive doubIe methoda ():D. abstract pub I ic void methoda ();E. protected void methoda (doubIe d1) )十四You want subcI asses i n any package to have access to members of a supercI ass Which i s the most restrietive access mod i f i er that wi I I accompI i sh thi s objective?(你希望子类在任何

14、包里都能访问父类,为完成这个目的,下列哪个是最严格的 访问权限)A. Pub I i cB. PrivateC. ProtectedD. Trans i entE. No access mod i f i er i s qua I i f i ed十五.Given:abstract cI ass abstret It 2. abstract float getFloat 0;3. )4. publ ic cI ass AbstractTest extends Abstractit 5. pr i vate fIoat f1二;6. pr i va te floa t get Floa t ()

15、 re turn f 1 ;)7. What is the result?A. Comp i I ationi s successfulB. AnerroronI ine6causesa runtime fai Iure(抛岀实时异常)CAnerroratline6causescomp iI ationtofaiI.D.Anerroratline2causescomp iI ationtofaiI.(子类覆盖父类方法的时候,不能比父类方法具有更严格的访问权限)1.pub I ic cI ass test2.pub I i c i nt aMethod () 3.static int i二0;4

16、.i+;5.return I;6.)7.pub I i c static vo i d ma i n8.test test = new test ();9.0;10.i nt j 二();11.12.)13.)十六.Click the exhibit button:(String args) (局部变量不能声明为静态)What i s the resu11?A. Comp i I at i on will fail.B. Compi lation wi I I succeed and the program wi I I pr int 0” C Comp i I ation wi I I su

17、cceed and the program wi I I pr i nt 1” D.Compi I at ion wi I I succeed and the program wi I I pr i nt u2n 十七 1) class Super 2) pub I ic float getNumO return ; 3)4)5) pub I ic cI ass Sub extends Super 6)6) wh i ch method, pIaced at line 6, wi I I cause a comp i I er error?A. pub I ic f loat getNum()

18、 return ;)B. pub I ic void getNumO )返回值类型不同不足以构成方法的重载C. publ ic void getNum(double d) )D. publ ic double getNum(float d) return ;十八 Which dec I ara tion preven ts creat i ng a subc I ass of an outer c I ass? c I ass FooBar )c I ass Foobar )c I ass FooBar )pub I i c c I ass FooBar )abstrac t c I ass FooBar )抽象类不能声明为 final十九.byte arrayl. array

温馨提示

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

评论

0/150

提交评论