武汉智远软件有限责任公司.doc

上传人:wj 文档编号:2514355 上传时间:2023-05-03 格式:DOC 页数:18 大小:352.50KB
下载 相关 举报
武汉智远软件有限责任公司.doc_第1页
第1页 / 共18页
武汉智远软件有限责任公司.doc_第2页
第2页 / 共18页
武汉智远软件有限责任公司.doc_第3页
第3页 / 共18页
武汉智远软件有限责任公司.doc_第4页
第4页 / 共18页
武汉智远软件有限责任公司.doc_第5页
第5页 / 共18页
武汉智远软件有限责任公司.doc_第6页
第6页 / 共18页
武汉智远软件有限责任公司.doc_第7页
第7页 / 共18页
武汉智远软件有限责任公司.doc_第8页
第8页 / 共18页
武汉智远软件有限责任公司.doc_第9页
第9页 / 共18页
武汉智远软件有限责任公司.doc_第10页
第10页 / 共18页
武汉智远软件有限责任公司.doc_第11页
第11页 / 共18页
武汉智远软件有限责任公司.doc_第12页
第12页 / 共18页
武汉智远软件有限责任公司.doc_第13页
第13页 / 共18页
武汉智远软件有限责任公司.doc_第14页
第14页 / 共18页
武汉智远软件有限责任公司.doc_第15页
第15页 / 共18页
武汉智远软件有限责任公司.doc_第16页
第16页 / 共18页
武汉智远软件有限责任公司.doc_第17页
第17页 / 共18页
武汉智远软件有限责任公司.doc_第18页
第18页 / 共18页
亲,该文档总共18页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

武汉智远软件有限责任公司.doc

《武汉智远软件有限责任公司.doc》由会员分享,可在线阅读,更多相关《武汉智远软件有限责任公司.doc(18页珍藏版)》请在冰点文库上搜索。

武汉智远软件有限责任公司.doc

选择题

1:

What will be the result of executing the following code?

   

  

// Filename; SuperclassX.java  

  

package packageX;   

  

public class SuperclassX  

  

{  

  

protected void superclassMethodX()  

  

{  

  

}  

  

int superclassVarX;  

  

}   

  

   

  

// Filename SubclassY.java  

  

1.package packageX.packageY;  

  

2.  

  

3.public class SubclassY extends SuperclassX  

  

4.{  

  

5.SuperclassX objX = new SubclassY();  

  

6.SubclassY objY = new SubclassY();  

  

7.void subclassMethodY()  

  

8.{  

  

9.objY.superclassMethodX();  

  

10.int i;  

  

11.i = objY.superclassVarX;  

  

12.}  

  

13.}   

  

Choices:

  

Whatwillbetheresultofexecutingthefollowingcode?

//Filename;SuperclassX.java

packagepackageX;

publicclassSuperclassX

{

protectedvoidsuperclassMethodX()

{

}

intsuperclassVarX;

}

//FilenameSubclassY.java

1.packagepackageX.packageY;

2.

3.publicclassSubclassYextendsSuperclassX

4.{

5.SuperclassXobjX=newSubclassY();

6.SubclassYobjY=newSubclassY();

7.voidsubclassMethodY()

8.{

9.objY.superclassMethodX();

10.inti;

11.i=objY.superclassVarX;

12.}

13.}

Choices:

A.Compilationerroratline5

B.Compilationerroratline9

C.Runtimeexceptionatline11

D.Noneofthese

2:

The following code is entire contents of a file called Example.java,causes precisely one error during compilation:

  

 class SubClass extends BaseClass{  

 }  

 class BaseClass(){  

 String str;  

 public BaseClass(){  

 System.out.println(“ok”);}  

 public BaseClass(String s){  

 str=s;}}  

 public class Example{  

 public void method(){  

 SubClass s=new SubClass(“hello”);  

 BaseClass b=new BaseClass(“world”);  

 }  

 }  

  

Which line would be cause the error?

   

ThefollowingcodeisentirecontentsofafilecalledExample.java,causespreciselyoneerrorduringcompilation:

classSubClassextendsBaseClass{

}

classBaseClass(){

Stringstr;

publicBaseClass(){

System.out.println(“ok”);}

publicBaseClass(Strings){

str=s;}}

publicclassExample{

publicvoidmethod(){

SubClasss=newSubClass(“hello”);

BaseClassb=newBaseClass(“world”);

}

}

Whichlinewouldbecausetheerror?

A.9

B.10

C.11

D.12

3:

鉴于Java的特点,它最适合的计算环境是

A.并行计算环境

B.分布式计算环境

C.高强度计算环境

D.开放式计算环境

4:

What will be printed when you execute the following code?

   

  

class X   

{  

  Y b = new Y();  

  X()   

 {   

   System.out.print("X");   

  }  

}   

  

class Y   

{  

    Y()   

   {   

     System.out.print("Y");   

   }  

}   

  

public class Z extends X   

{  

   Y y = new Y();   

  Z()   

 {   

    System.out.print("Z");   

  }   

   public static void main(String[] args)   

  {  

               new Z();  

  }  

}   

  

Choices:

  

Whatwillbeprintedwhenyouexecutethefollowingcode?

classX

{

Yb=newY();

X()

{

System.out.print("X");

}

}

classY

{

Y()

{

System.out.print("Y");

}

}

publicclassZextendsX

{

Yy=newY();

Z()

{

System.out.print("Z");

}

publicstaticvoidmain(String[]args)

{

newZ();

}

}

Choices:

A.Z

B.YZ

C.XYZ

D.YXYZ

5:

Given the following class definition:

  

class A{  

protected int i;  

A(int i){  

this.i=i;  

}  

}  

which of the following would be a valid inner class for this class?

  

Select valid answer:

   

Giventhefollowingclassdefinition:

classA{

protectedinti;

A(inti){

this.i=i;

}

}

whichofthefollowingwouldbeavalidinnerclassforthisclass?

Selectvalidanswer:

A.classB{}

B.classBextendsA{}

C.classBextendsA{B(){System.out.println(“i=”+i);}}

D.classB{classA{}}

6:

下述程序代码中有语法错误的行是(  )。

  

int i,ia[10],ib[10];      /*第一行*/  

for (i=0;i<=9;i++)        /*第2行*/  

  ia[i]=0;          /*第3行*/  

ib=ia;    /*第4行*/  

下述程序代码中有语法错误的行是()。

inti,ia[10],ib[10];/*第一行*/

for(i=0;i<=9;i++)/*第2行*/

ia[i]=0;/*第3行*/

ib=ia;/*第4行*/

A.第1行

B.第2行

C.第3行

D.第4行

7:

Give this class outline:

  

class Example{  

private int x;  

//rest of class body…  

}  

Assuming that x invoked by the code java Example, which statement can made x be directly accessible in main() method of Example.java?

  

Givethisclassoutline:

classExample{

privateintx;

//restofclassbody…

}

AssumingthatxinvokedbythecodejavaExample,whichstatementcanmadexbedirectlyaccessibleinmain()methodofExample.java?

A.Changeprivateintxtopublicintx

B.changeprivateintxtostaticintx

C.Changeprivateintxtoprotectedintx

D.changeprivateintxtofinalintx

8:

假定a和b为int型变量,则执行下述语句组后,b的值为

a=1;

b=10;

do

{

b-=a;

a++;

}while(b--<0);

A.9

B.-2

C.-1

D.8

9:

public class OuterClass {  

private double d1 = 1.0;  

//insert code here  

}  

You need to insert an inner class declaration at line 3. Which two inner class declarations are  

valid?

  

publicclassOuterClass{

privatedoubled1=1.0;

//insertcodehere

}

Youneedtoinsertaninnerclassdeclarationatline3.Whichtwoinnerclassdeclarationsare

valid?

A.classInnerOne{publicstaticdoublemethoda(){returnd1;}}

B.publicclassInnerOne{staticdoublemethoda(){returnd1;}}

C.privateclassInnerOne{doublemethoda(){returnd1;}}

D.staticclassInnerOne{protecteddoublemethoda(){returnd1;}}

10:

WhicharenotJavakeywords?

A.TRUE

B.const

C.super

D.void

11:

Inthefollowingpiecesofcode,whichonewillcompilewithoutanyerror?

A.StringBuffersb1="abcd";

B.Booleanb=newBoolean("abcd");

C.C:

byteb=255;

D.floatfl=1.2;

12:

public class X{  

  

   public Object m(){  

  

      Object o = new Float(3.14F);//line 3  

  

      Object [] oa = new Object[1];//line 4  

  

      oa[0] = o;//line 5  

  

      o=null;//line 6  

  

      return oa[0];//line 7  

  

     }  

  

}  

When is the Float object, created in line 3,eligible for garbage collection?

  

publicclassX{

publicObjectm(){

Objecto=newFloat(3.14F);//line3

Object[]oa=newObject[1];//line4

oa[0]=o;//line5

o=null;//line6

returnoa[0];//line7

}

}

WhenistheFloatobject,createdinline3,eligibleforgarbagecollection?

A.justafterline5.

B.justafterline6

C.justafterline7(thatis,asthemethodreturns)

D.neverinthismethod

13:

Give the following java source fragement:

  

//point x  

public class Interesting{  

//do something  

}  

Which statement is correctly Java syntax at point x?

   

Givethefollowingjavasourcefragement:

//pointx

publicclassInteresting{

//dosomething

}

WhichstatementiscorrectlyJavasyntaxatpointx?

A.publicclassMyClass{//dootherthing…}

B.staticintPI=3.14

C.classMyClass{//dosomething…}

D.none

14:

Whichofthefollowingstatementsarenotlegal?

A.longl=4990;

B.inti=4L;

C.doubled=34.4;

D.doublet=0.9F.

15:

What will happen when you attempt to compile and run the following code?

   

  

int Output = 10;  

  

boolean b1 = false;   

  

if((b1 == true) && ((Output += 10) == 20))  

  

{  

  

   System.out.println("We are equal " + Output);  

  

}   

  

else  

  

{  

  

   System.out.println("Not equal!

 " + Output);  

  

}   

  

Choices:

  

Whatwillhappenwhenyouattempttocompileandrunthefollowingcode?

intOutput=10;

booleanb1=false;

if((b1==true)&&((Output+=10)==20))

{

System.out.println("Weareequal"+Output);

}

else

{

System.out.println("Notequal!

"+Output);

}

Choices:

A.Compilationerror,attemptingtoperformbinarycomparisononlogicaldatatype

B.Compilationandoutputof"Weareequal10".

C.Compilationandoutputof"Notequal!

20".

D.Compilationandoutputof"Notequal!

10".

16:

What will be the result of executing the following code?

   

 boolean a = true;  

 boolean b = false;  

 boolean c = true;  

 if (a == true)  

 if (b == true)  

 if (c == true)    System.out.println("Some things are true in this world");  

 else       System.out.println("Nothing is true in this world!

");  

  else if (a && (b = c))  System.out.println("It's too confusing to tell what is true and what is false");  

  else   System.out.println("Hey this won't compile");   

  

Choices:

  

Whatwillbetheresultofexecutingthefollowingcode?

booleana=true;

booleanb=false;

booleanc=true;

if(a==true)

if(b==true)

if(c==true)System.out.println("Somethingsaretrueinthisworld");

elseSystem.out.println("Nothingistrueinthisworld!

");

elseif(a&&(b=c))System.out.println("It'stooconfusingtotellwhatistrueandwhatisfalse");

elseSystem.out.println("Heythiswon'tcompile");

Choices:

A.Thecodewon'tcompile

B."Somethingsaretrueinthisworld"willbeprinted

C."Heythiswon'tcompile"willbeprinted

D.Noneofthese

17:

给出下面的代码片断。

下面的哪些陈述为错误的?

  

1) public void create() {  

2)    Vector myVect;  

3)    myVect = new Vector();  

4) }  

给出下面的代码片断。

下面的哪些陈述为错误的?

1)publicvoidcreate(){

2)VectormyVect;

3)myVect=newVector();

4)}

A.第二行的声明不会为变量myVect分配内存空间。

B.第二行语句创建一个Vector类对象。

C.第三行语句创建一个Vector类对象。

D.第三行语句为一个Vector类对象分配内存空间

18:

Whichstatementaboutlisteneristrue?

A.Mostcomponentallowmultiplelistenerstobeadded.

B.Ifmultiplelistenerbeaddtoasinglecomponent,theeventonlyaffectedonelistener.

C.Componentdon?

tallowmultiplelistenerstobeadd.

D.none

19:

Select valid identifier of Java:

  

Selectvalididentifi

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 党团工作 > 入党转正申请

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2