1.publicclassA{2.3.privateintcounter=0;4.5.publicstaticintgetInstanceCount(){6.returncounter;7.}8.9.publicA(){10.counter++;11.}12.13.}GiventhiscodefromClassB:25.Aa1=newA();26.Aa2=newA();27.Aa3=newA();28.System.out.printIn(A.getInstanceCount());Whatistheresult?()A.CompilationofclassAfails.B.Line28printsthevalue3toSystem.out.C.Line28printsthevalue1toSystem.out.D.Aruntimeerroroccurswhenline25executes.E.Compilationfailsbecauseofanerroronline28.
1.publicclassA{2.3.privateintcounter=0;4.5.publicstaticintgetInstanceCount(){6.returncounter;7.}8.9.publicA(){10.counter++;11.}12.13.}GiventhiscodefromClassB:25.Aa1=newA();26.Aa2=newA();27.Aa3=newA();28.System.out.printIn(A.getInstanceCount());Whatistheresult?()
A.CompilationofclassAfails.
B.Line28printsthevalue3toSystem.out.
C.Line28printsthevalue1toSystem.out.
D.Aruntimeerroroccurswhenline25executes.
E.Compilationfailsbecauseofanerroronline28.
相关考题:
下列语句输出结果为 。public class A{public static void main(String[]args){byte b=0xa;System.out.println(b);}}() A.0xaB.aC.1D.10
根据下面的代码,可以确定类A与类B之间存在()关系。publicclassA{privateBtheB;publicvoidaMethod(){theB.doSomthing();}} A、关联B、泛化C、实现D、包含
publicclassSomeException{}Classa:publicclassa{publicvoiddoSomething(){}}Classb:publicclassbextendsa{publicvoiddoSomething()throwsSomeException{}}Whichistrueaboutthetwoclasses?() A.Compilationofbothclasseswillfail.B.Compilationofbothclasseswillsucceed.C.Compilationofclassawillfail.Compilationofclassbwillsucceed.D.Compilationofclassawillfail.Compilationofclassawillsucceed.
publicclassA{2.publicvoiddoit(){3.}4.publicStringdoit(){5.returna”;6.}7.publicdoubledoit(intx){8.return1.0;9.}10.}Whatistheresult?() A.Anexceptionisthrownatruntime.B.Compilationfailsbecauseofanerrorinline7.C.Compilationfailsbecauseofanerrorinline4.D.CompilationsucceedsandnoruntimeerrorswithclassAoccur.
publicclassA{2.voidA(){3.System.out.println(ClassA”);4.}5.publicstaticvoidmain(String[]args){6.newA();7.}8.}Whatistheresult?() A.ClassAB.Compilationfails.C.Anexceptionisthrownatline2.D.Anexceptionisthrownatline6.E.Thecodeexecuteswithnooutput.
编译和运行以下程序结果为:public class A {static int k=3;static int m;public static void main(String[] args) {k++;if (m==0)System.out.println(k);elseSystem.out.println(B.k);k++;}}class B {static int k=6;} A. 3B. 4C.5D.编译错误E.6
下面的代码使用了面向对象的什么特性?() public class A{ public void DoSomething(){} } public class B : A{ new public void DoSomething(){ base.DoSomething();} }A.继承性B.多态性C.封装性D.关联性
下列哪些是合法的类定义语句A.public class A {}B.class A extends Exception,I0Exception {}C.public class 1A extends ObjectD.public class String {}
若要使用两个泛型类型来声明一个名为A的类,请使用A.public class A<E> { ... }B.public class A<E, F> { ... }C.public class A(E) { ... }D.public class A(E, F) { ... }