杭州翰天网络科技.doc

上传人:b****2 文档编号:1553423 上传时间:2022-10-23 格式:DOC 页数:9 大小:324.50KB
下载 相关 举报
杭州翰天网络科技.doc_第1页
第1页 / 共9页
杭州翰天网络科技.doc_第2页
第2页 / 共9页
杭州翰天网络科技.doc_第3页
第3页 / 共9页
杭州翰天网络科技.doc_第4页
第4页 / 共9页
杭州翰天网络科技.doc_第5页
第5页 / 共9页
点击查看更多>>
下载资源
资源描述

杭州翰天网络科技.doc

《杭州翰天网络科技.doc》由会员分享,可在线阅读,更多相关《杭州翰天网络科技.doc(9页珍藏版)》请在冰豆网上搜索。

杭州翰天网络科技.doc

选择题

1:

关于垃圾收集的哪些叙述是对的。

A.程序开发者必须自己创建一个线程进行内存释放的工作。

B.垃圾收集将检查并释放不再使用的内存。

C.垃圾收集允许程序开发者明确指定并立即释放该内存。

D.垃圾收集能够在期望的时间释放被java对象使用的内存。

2:

1.String s=”Example String”;Which operation is not legal?

  

Strings=”ExampleString”;Whichoperationisnotlegal?

A.inti=s.length();

B.s[3]=”x”;

C.Stringshort_s=s.trim();

D.Stringt=”root”+s;

3:

Whatiswrittentothestandardoutputgiventhefollowingstatement:

System.out.println(4|7);

Selecttherightanswer:

A.4

B.5

C.6

D.7

4:

Whichdeclaresfornativemethodinajavaclasscorrected?

A.publicnativevoidmethod(){}

B.publicnativevoidmethod();

C.publicnativemethod();

D.publicvoidnativemethod();

5:

1.What happens when you try to compile and run the following program?

  

2.class Mystery{  

3.String s;  

4.public static void main(String[] args){  

5.Mystery m=new Mystery();  

6.m.go();  

7.}  

8.void Mystery(){  

9.s=”constructor”;  

10.}  

11.void go(){  

12.System.out.println(s);  

13.}  

14.}  

Whathappenswhenyoutrytocompileandrunthefollowingprogram?

classMystery{

Strings;

publicstaticvoidmain(String[]args){

Mysterym=newMystery();

m.go();

}

voidMystery(){

s=”constructor”;

}

voidgo(){

System.out.println(s);

}

}

A.thiscodecomplilesbutthrowsanexceptionatruntime

B.thiscoderunsbutnothingappearsinthestandardoutput

C.thiscoderunsand“constructor”inthestandardoutput

D.thiscoderunsandwrites”null”inthestandardoutput

6:

publicclassParent{

  intchange(){…}

}

classChildextendsParent{

}

WhichmethodscanbeaddedintoclassChild?

A.publicintchange(){}

B.abstractintchang(){}

C.privateintchange(){}

D.none

7:

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

   

2.  

3.public class Static  

4.  

5.{  

6.  

7.static  

8.  

9.{  

10.  

11.int x = 5;  

12.  

13.}   

14.  

15.static int x,y;  

16.  

17.public static void main(String args[])  

18.  

19.{  

20.  

21.       x--;  

22.  

23.       myMethod();  

24.  

25.       System.out.println(x + y + ++x);  

26.  

27.}   

28.  

29.public static void myMethod()  

30.  

31.{  

32.  

33.y = x++ + ++x;  

34.  

35.}  

36.  

37.}   

38.  

39.Choices:

  

Whatwillhappenwhenyouattempttocompileandrunthefollowingcode?

publicclassStatic

{

static

{

intx=5;

}

staticintx,y;

publicstaticvoidmain(Stringargs[])

{

x--;

myMethod();

System.out.println(x+y+++x);

}

publicstaticvoidmyMethod()

{

y=x+++++x;

}

}

Choices:

A.prints:

2

B.prints:

3

C.prints:

7

D.prints:

8

8:

Aclassdesignrequiresthataparticularmembervariablemustbeaccessiblefordirectaccessbyanysubclassesofthisclass.butotherwisenotbyclasseswhicharenotmembersofthesamepackage.Whatshouldbedonetoachievethis?

A.Thevariableshouldbemarkedpublic

B.Thevariableshouldbemarkedprivate

C.Thevariableshouldbemarkedprotected

D.Thevariableshouldhavenospecialaccessmodifier

9:

1.Give the following code:

  

2.public class Example{  

3.public static void main(String args[] ){  

4.int l=0;  

5.do{  

6.System.out.println(“Doing it for l is:

”+l);  

7.}while(--l>0)  

8.System.out.println(“Finish”);  

9.}  

10.}  

11.Which well be output:

   

Givethefollowingcode:

publicclassExample{

publicstaticvoidmain(Stringargs[]){

intl=0;

do{

System.out.println(“Doingitforlis:

”+l);

}while(--l>0)

System.out.println(“Finish”);

}

}

Whichwellbeoutput:

A.Doingitforlis3

B.Doingitforlis1

C.Doingitforlis2

D.Doingitforlis0

10:

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

a=1;

b=10;

do

{

b-=a;

a++;

}while(b--<0);

A.9

B.-2

C.-1

D.8

11:

WhichfragmentsarenotcorrectinJavasourcefile?

A.packagetestpackage;publicclassTest{//dosomething...}

B.importjava.io.*;packagetestpackage;publicclassTest{//dosomething...}

C.importjava.io.*;classPerson{//dosomething...}publicclassTest{//dosomething...}

D.importjava.io.*;importjava.awt.*;publicclassTest{//dosomething...}

12:

1.Give this class outline:

  

2.class Example{  

3.private int x;  

4.//rest of class body…  

5.}  

6.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

13:

Inth

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

当前位置:首页 > 职业教育 > 其它

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1