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

上传人:油条 文档编号:116335208 上传时间:2019-11-16 格式:DOC 页数:18 大小:352.50KB
返回 下载 相关 举报
武汉智远软件有限责任公司_第1页
第1页 / 共18页
武汉智远软件有限责任公司_第2页
第2页 / 共18页
武汉智远软件有限责任公司_第3页
第3页 / 共18页
武汉智远软件有限责任公司_第4页
第4页 / 共18页
武汉智远软件有限责任公司_第5页
第5页 / 共18页
点击查看更多>>
资源描述

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

1、选择题 1: Whatwillbetheresultofexecutingthefollowingcode? /Filename;SuperclassX.java packagepackageX; publicclassSuperclassX protectedvoidsuperclassMethodX() intsuperclassVarX; /FilenameSubclassY.java 1.packagepackageX.packageY; 2. 3.publicclassSubclassYextendsSuperclassX 4. 5.SuperclassXobjX=newSubcla

2、ssY(); 6.SubclassYobjY=newSubclassY(); 7.voidsubclassMethodY() 8. 9.objY.superclassMethodX(); 10.inti; 11.i=objY.superclassVarX; 12. 13. Choices:What will be the result of executing the following code? / Filename; SuperclassX.javapackage packageX; public class SuperclassXprotected void superclassMet

3、hodX()int superclassVarX; / Filename SubclassY.java1.package packageX.packageY;2.3.public class SubclassY extends SuperclassX4.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. Choic

4、es:A.Compilation error at line 5 B.Compilation error at line 9 C.Runtime exception at line 11 D.None of these 2: ThefollowingcodeisentirecontentsofafilecalledExample.java,causespreciselyoneerrorduringcompilation: classSubClassextendsBaseClass classBaseClass() Stringstr; publicBaseClass() System.out.

5、println(“ok”); publicBaseClass(Strings) str=s; publicclassExample publicvoidmethod() SubClasss=newSubClass(“hello”); BaseClassb=newBaseClass(“world”); Whichlinewouldbecausetheerror?The following code is entire contents of a file called Example.java,causes precisely one error during compilation: clas

6、s 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? A.9 B.10 C.11

7、 D.12 3:鉴于Java的特点,它最适合的计算环境是 A.并行计算环境 B.分布式计算环境 C.高强度计算环境 D.开放式计算环境 4: Whatwillbeprintedwhenyouexecutethefollowingcode? classX Yb=newY(); X() System.out.print(X); classY Y() System.out.print(Y); publicclassZextendsX Yy=newY(); Z() System.out.print(Z); publicstaticvoidmain(Stringargs) newZ(); Choices

8、: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:A.Z B.YZ C.XYZ D.YXYZ 5: Giventhefollowin

9、gclassdefinition: classA protectedinti; A(inti) this.i=i; whichofthefollowingwouldbeavalidinnerclassforthisclass? Selectvalidanswer:Given the following class definition:class Aprotected int i;A(int i)this.i=i;which of the following would be a valid inner class for this class?Select valid answer: A.c

10、lass B B.class B extends A C.class B extends A B()System.out.println(“i=”+i); D.class B class A 6: 下述程序代码中有语法错误的行是()。 inti,ia10,ib10;/*第一行*/for(i=0;i=9;i+)/*第2行*/iai=0;/*第3行*/ib=ia;/*第4行*/下述程序代码中有语法错误的行是( )。int i,ia10,ib10; /*第一行*/for (i=0;i=9;i+) /*第2行*/ iai=0; /*第3行*/ib=ia; /*第4行*/A.第1行 B.第2行 C.第3

11、行 D.第4行 7: Givethisclassoutline: classExample privateintx; /restofclassbody AssumingthatxinvokedbythecodejavaExample,whichstatementcanmadexbedirectlyaccessibleinmain()methodofExample.java?Give this class outline:class Exampleprivate int x;/rest of class bodyAssuming that x invoked by the code java E

12、xample, which statement can made x be directly accessible in main() method of Example.java?A.Change private int x to public int x B.change private int x to static int x C.Change private int x to protected int x D.change private int x to final int x 8:假定a和b为int型变量,则执行下述语句组后,b的值为 a=1; b=10; do b-=a; a+; while (b-0); A.9 B.-2 C.-1 D.8

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 中学教育 > 其它中学文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号