网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
publicclassBase{publicstaticfinalStringFOO=foo”;publicstaticvoidmain(String[]args){Baseb=newBase();Subs=newSub();System.out.print(Base.FOO);System.out.print(Sub.FOO);System.out.print(b.FOO);System.out.print(s.FOO);System.out.print(((Base)s).FOO);}}classSubextendsBase{publicstaticfinalStringFOO=bar;}Whatistheresult?()
A.foofoofoofoofoo
B.foobarfoobarbar
C.foobarfoofoofoo
D.foobarfoobarfoo
E.barbarbarbarbar
F.foofoofoobarbar
G.foofoofoobarfoo
参考答案
更多 “ publicclassBase{publicstaticfinalStringFOO=foo”;publicstaticvoidmain(String[]args){Baseb=newBase();Subs=newSub();System.out.print(Base.FOO);System.out.print(Sub.FOO);System.out.print(b.FOO);System.out.print(s.FOO);System.out.print(((Base)s).FOO);}}classSubextendsBase{publicstaticfinalStringFOO=bar;}Whatistheresult?()A.foofoofoofoofooB.foobarfoobarbarC.foobarfoofoofooD.foobarfoobarfooE.barbarbarbarbarF.foofoofoobarbarG.foofoofoobarfoo ” 相关考题
考题
classFlow{publicstaticvoidmain(String[]args){try{System.out.print(before);doRiskyThing();System.out.print(after);}catch(Exceptionfe){System.out.print(catch);}System.out.println(done);}publicstaticvoiddoRiskyThing()throwsException{//thiscodereturnsunlessitthrowsanException}}可能会产生下面哪两项结果?()A.beforeB.beforecatchC.beforeafterdoneD.beforecatchdone
考题
classWaitingimplementsRunnable{booleanflag=false;publicsynchronizedvoidrun(){if(flag){flag=false;System.out.print(1);try{this.wait();}catch(Exceptione){}System.out.print(2);}else{flag=true;System.out.print(3);try{Thread.sleep(2000);}catch(Exceptione){}System.out.print(4);notify();}}publicstaticvoidmain(String[]args){Waitingw=newWaiting();newThread(w).start();newThread(w).start();}}以下哪两项是正确的?()
考题
classOrderimplementsRunnable{publicvoidrun(){try{Thread.sleep(2000);}catch(Exceptione){}System.out.print(in);}publicstaticvoidmain(String[]args){Threadt=newThread(newOrder());t.start();System.out.print(pre);try{t.join();}catch(Exceptione){}System.out.print(post);}}可产生哪两项结果?()A.inpreB.preinC.inprepostD.preinpost
考题
classBeta{publicstaticvoidmain(String[]args){Integerx=newInteger(6)*7;if(x!=42){System.out.print(42);}elseif(x.equals(42)){System.out.print(dot=);}else{System.out.print(done);}}}结果为:()A.42B.doneC.dot=D.编译失败
考题
classFlibitz{publicstaticvoidmain(String[]args){intgrop=7;newFlibitz().go(grop);System.out.print(grop);}voidgo(intgrop){if(++grop〉7)grop++;System.out.print(grop);}}结果为:()
A.77B.79C.97D.99
考题
classBirds{publicstaticvoidmain(String[]args){try{thrownewException();}catch(Exceptione){try{thrownewException();}catch(Exceptione2){System.out.print(inner);}System.out.print(middle);}System.out.print(outer);}}结果为:()A.innerB.innerouterC.middleouterD.innermiddleouter
考题
classBitStuff{BitStuffgo(){System.out.print(bits);returnthis;}}classMoreBitsextendsBitStuff{MoreBitsgo(){System.out.print(more);returnthis;}publicstaticvoidmain(String[]args){BitStuff[]bs={newBitStuff(),newMoreBits()};for(BitStuffb:bs)b.go();}}结果为:()A.bitsbitsB.bitsmoreC.moremoreD.编译失败
考题
classPasser{staticfinalintx=5;publicstaticvoidmain(String[]args){newPasser().go(x);System.out.print(x);}voidgo(intx){System.out.print(++x);}}结果是什么?()
A.55B.56C.65D.66
考题
classNumber{publicstaticvoidmain(String[]args){try{System.out.print(Integer.parseInt(forty));}catch(RuntimeExceptionr){System.out.print(runtime);}catch(NumberFormatExceptione){System.out.print(number);}}}结果是什么?()A.fortyB.numberC.runtimeD.编译失败
考题
classBird{staticvoidtalk(){System.out.print(chirp);}}classParrotextendsBird{staticvoidtalk(){System.out.print(hello);}publicstaticvoidmain(String[]args){Bird[]birds={newBird(),newParrot()};for(Birdb:birds)b.talk();}}结果为:()A.chirpchirpB.chirphelloC.hellohelloD.编译失败
考题
现有:classBirds{publicstaticvoidmain(String[]args){try{thrownewException();}catch(Exceptione){try{thrownewException();}catch(Exceptione2){System.out.print(inner);}System.out.print(middle);}System.out.print(outer);}}结果是()A.innerouterB.middleouterC.innermiddleouterD..编译失败
考题
现有classBeverage{Beverage(){System.out.print(beverage);}}classBeerextendsBeverage{publicstaticvoidmain{string[]args){Beerb=newBeer(14);}publicintBeer(intx){this();System.out.print(beerl);}publicBeer(){System.out.print(beer2);}}结果是什么?()A.beerlbeverageB.beer2beverageC.beveragebeer2beerlD.编译失败
考题
classFoo{privateintx;publicFoo(intx){this.x=x;}publicvoidsetX(intx){this.x=x;}publicintgetX(){returnx;}}publicclassGamma{staticFoofooBar(Foofoo){foo=newFoo(100);returnfoo;}publicstaticvoidmain(String[]args){Foofoo=newFoo(300);System.out.print(foo.getX()+-);FoofooFoo=fooBar(foo);System.out.print(foo.getX()+-);System.out.print(fooFoo.getX()+-);foo=fooBar(fooFoo);System.out.print(foo.getX()+-);System.out.prmt(fooFoo.getX());}}Whatistheoutputofthisprogram?()
考题
publicclassThreads4{publicstaticvoidmain(String[]args){newThreads4().go();}publicvoidgo(){Runnabler=newRunnable(){publicvoidrun(){System.out.print(”foo”);}};Threadt=newThread(r);t.start();t.start();}}Whatistheresult?()A.Compilationfails.B.Anexceptionisthrownatruntime.C.Thecodeexecutesnormallyandprints?foo”.D.Thecodeexecutesnormally,butnothingisprinted.
考题
staticvoidtest()throwsRuntimeException{try{System.out.print(”test);thrownewRuntimeException();}catch(Exceptionex){System.out.print(”exception);}}publicstaticvoidmain(String[]args){try{test();}catch(RuntimeExceptionex){System.out.print(”runtime);}System.out.print(”end);}Whatistheresult?()A.testendB.Compilationfails.C.testruntimeendD.testexceptionendE.AThrowableisthrownbymainatruntime.
考题
publicclassTest{publicenumDogs{collie,harrier,shepherd};publicstaticvoidmain(String[]args){DogsmyDog=Dogs.shepherd;switch(myDog){casecollie:System.out.print(”collie);casedefault:System.out.print(”retriever);caseharrier:System.out.print(”harrier);}}}Whatistheresult?()A.harrierB.shepherdC.retrieverD.Compilationfails.E.retrieverharrierF.Anexceptionisthrownatruntime.
考题
publicclassBootchy{intbootch;Stringsnootch;publicBootchy(){this(”snootchy”);System.out.print(”first);}publicBootchy(Stringsnootch){this(420,snootchy”);System.out.print(”second);}publicBootchy(intbootch,Stringsnootch){this.bootch=bootch;this.snootch=snootch;System.out.print(”third);}publicstaticvoidmain(String[]args){Bootchyb=newBootchy();System.out.print(b.snootch++b.bootch);}}Whatistheresult?()A.snootchy420thirdsecondfirstB.snootchy420firstsecondthirdC.firstsecondthirdsnootchy420D.thirdsecondfirstsiiootchy420E.thirdfirstsecondsnootchy420F.firstsecondfirstthirdsnootchy420
考题
classOne{publicOne(){System.out.print(1);}}classTwoextendsOne{publicTwo(){System.out.print(2);}}classThreeextendsTwo{publicThree(){System.out.print(3);}}publicclassNumbers{publicstaticvoidmain(String[]argv){newThree();}}Whatistheresultwhenthiscodeisexecuted?()A.1B.3C.123D.321E.Thecoderimswithnooutput.
考题
publicclassX{publicstaticvoidmain(String[]args){try{badMethod();System.out.print(A”);}catch(RuntimeExceptionex){System.out.print(B”);}catch(Exceptionex1){System.out.print(C”);}finally{System.out.print(D”);}System.out.print(E”);}publicstaticvoidbadMethod(){thrownewRuntimeException();}}Whatistheresult?()A.BDB.BCDC.BDED.BCDEE.ABCDEF.Compilationfails.
考题
publicclassX{publicstaticvoidmain(String[]args){try{badMethod();System.out.print(A”);}catch(Exceptionex){System.out.print(B”);}finally{System.out.print(C”);}System.out.print(D”);}publicstaticvoidbadMethod(){thrownewRuntimeException();}}Whatistheresult?()A.ABB.BCC.ABCD.BCDE.Compilationfails.
考题
publicclassX{publicstaticvoidmain(String[]args){try{badMethod();System.out.print(A”);}catch(Exceptionex){System.out.print(B”);}finally{System.out.print(C”);}System.out.print(D”);}publicstaticvoidbadMethod(){}}Whatistheresult?()A.ACB.BDC.ACDD.ABCDE.Compilationfails.
考题
classBase{Base(){System.out.print(Base”);}}publicclassAlphaextendsBase{publicstaticvoidmain(String[]args){newAlpha();newBase();}}Whatistheresult?()
A.BaseB.BaseBaseC.Compilationfails.D.Thecoderunswithnooutput.E.Anexceptionisthrownatruntime.
考题
publicclassDelta{staticbooleanfoo(charc){System.out.print(c);returntrue;}publicstaticvoidmain(String[]argv){inti=0;for(foo(‘A’);foo(‘B’)(i2);foo(‘C’)){i++;foo(‘D’);}}}Whatistheresult?()
A.ABDCBDCBB.ABCDABCDC.Compilationfails.D.Anexceptionisthrownatruntime.
考题
给定以下JAVA代码,这段代码编译运行后输出的结果是( )publicclassTest{publicstaticintaMethod(inti)throwsException{try{returni/10;}catch(Exceptionex){thrownewException("exceptioninaaMothod");}finally{System.out.print("finally");}}publicstaticvoidmain(String[]args){try{aMethod(0);}catch(Exceptionex){System.out.print("exceptioninmain");}System.out.print("finished");}}A、finallyexceptioninmainfinishedB、exceptioninmainfinallyC、finallyfinishedD、finallyexceptioninmainfinished
考题
public class Base { public static final String FOO = “foo”; public static void main(String[] args) { Base b = new Base(); Sub s = new Sub(); System.out.print(Base.FOO); System.out.print(Sub.FOO); System.out.print(b.FOO); System.out.print(s.FOO); System.out.print(((Base)s).FOO); } } class Sub extends Base {public static final String FOO=bar;} What is the result?() A、 foofoofoofoofooB、 foobarfoobarbarC、 foobarfoofoofooD、 foobarfoobarfooE、 barbarbarbarbarF、 foofoofoobarbarG、 foofoofoobarfoo
考题
class Foo { private int x; publicFoo(intx) {this.x=x; } public void setX( int x) { this.x = x; } public int getX() { return x; } } public class Gamma { static Foo fooBar( Foo foo) { foo = new Foo( 100); return foo; } public static void main( String[] args) { Foo foo = new Foo( 300); System.out.print( foo.getX() + “-“); Foo fooFoo = fooBar( foo); System.out.print( foo.getX() + “-“); System.out.print( fooFoo.getX() + “-“); foo = fooBar( fooFoo); System.out.print( foo.getX() + “-“); System.out.prmt( fooFoo.getX()); } } What is the output of this program?()A、 300-100-100-100-100B、 300-300-100-100-100C、 300-300-300-100-100D、 300-300-300-300-100
考题
单选题public class Base { public static final String FOO = “foo”; public static void main(String[] args) { Base b = new Base(); Sub s = new Sub(); System.out.print(Base.FOO); System.out.print(Sub.FOO); System.out.print(b.FOO); System.out.print(s.FOO); System.out.print(((Base)s).FOO); } } class Sub extends Base {public static final String FOO=bar;} What is the result?()A
foofoofoofoofooB
foobarfoobarbarC
foobarfoofoofooD
foobarfoobarfooE
barbarbarbarbarF
foofoofoobarbarG
foofoofoobarfoo
热门标签
最新试卷