Whatwillbewrittentothestandardoutputwhenthefollowingprogramisrun?()publicclassQd803{publicstaticvoidmain(Stringargs[]){Stringword="restructure";System.out.println(word.substring(2,3));}}A.estB.esC.strD.stE.s

题目
Whatwillbewrittentothestandardoutputwhenthefollowingprogramisrun?()publicclassQd803{publicstaticvoidmain(Stringargs[]){Stringword="restructure";System.out.println(word.substring(2,3));}}

A.est

B.es

C.str

D.st

E.s


相似考题
更多“Whatwillbewrittentothestandardoutputwhenthefollowingprogramisrun?()publicclassQd803{publicstaticvoidmain(Stringargs[]){Stringword="restructure";System.out.println(word.substring(2,3));}} ”相关问题
  • 第1题:

    IfthissourcecodeiscontainedinafilecalledSmallProg.java,whatcommandshouldbeusedtocompileitusingtheJDK?()publicclassSmallProg{publicstaticvoidmain(Stringargs[]){System.out.println("Goodluck!");}}

    A.javaSmallProg

    B.avacSmallProg

    C.javacSmallProg.java

    D.javaSmallProgmain


    参考答案:C

  • 第2题:

    publicclassTest{publicstaticvoidaMethod()throwsException{try{thrownewException();}finally{System.out.println(finally”);}}publicstaticvoidmain(Stringargs[]){try{aMethod();}catch(Exceptione){System.out.println(exception”);}System.out.println(finished”);}}Whatistheresult?()

    A.finally

    B.exceptionfinished

    C.finallyexceptionfinished

    D.Compilationfails.


    参考答案:C

  • 第3题:

    阅读下列代码: public class Test{ public static void main(String args[])[ System. out.println(89>>1 ); } }

    A.44

    B.45

    C.88

    D.90


    正确答案:A

  • 第4题:

    classA{publicA(){System.out.println(hellofroma”);}}classBextendsA{publicB(){System.out.println(hellofromb”);super();}}publicclassTest{publicstaticvoidmain(Stringargs[]){Aa=newB();}}Whatistheresultwhenmainisexecuted?()

    A.Compilationfails.

    B.hellofroma

    C.hellofromb

    D.hellofrombhellofroma

    E.hellofromahellofromb


    参考答案:A
    Calltosupermustbefirststatementinconstructor.

  • 第5题:

    阅读下面程序 public class Increment { public static void main( String args[] ){ int c; c=5; System.out.println(C) ; System.out.println(c++); System.out.println(C) ; } }

    A.5 6 6

    B.5 5 6

    C.6 7 7

    D.6 6 6


    正确答案:B
    解析:本题考查的是Java增量运算符“++”。增量运算符“++”是对操作数加1,如果对浮点数进行增量操作,则结果为加1.0。++op和op++的结果都为op=op+1。但是,如果将增量运算表达式再作为其他表达式的操作数使用时,x++和++x,它们是有区别的:x++是先使用后加1。首先使用x的值进行表达式的计算,然后才对x的值加1。++x是先加1后使用。首先对x的值加1,然后使用x的值进行表达式的计算。本题源程序代码很简单,首先生成一个整型变量c,其初始值为5。第一条输出语句输出c的初始值,即5。然后,第二条输出表达式c++的结果。根据上述介绍的增量运算符的用法,先输出c的值,然后才对c的值加1。因此,第二条输出语句输出的是5,输出后c的结果才为6。最后一条输出语句显然输出结果为6。因此,本题的正确答案为B。