3下面程序段的输出结果为( )。 mblic class Test public static void main(String args[]) { boolean a,b,c; a=(3<5); b=(a==true); System.out.println("a="+a+"b="+b); c=(b=false); System.out.println("b="+b+"c="+c); } }A.a=true b=false b=true c=falseB.a=true b=false b=true c=

题目

3下面程序段的输出结果为( )。 mblic class Test public static void main(String args[]) { boolean a,b,c; a=(3<5); b=(a==true); System.out.println("a="+a+"b="+b); c=(b=false); System.out.println("b="+b+"c="+c); } }

A.a=true b=false b=true c=false

B.a=true b=false b=true c=true

C.a=true b=true b=true c=false

D.a=false b=false b=true c=false


相似考题
更多“3下面程序段的输出结果为( )。mblic class Test public static void main(String args[]){boolean ”相关问题
  • 第1题:

    下面程序段的输出结果是( )。 public class Test { public static void main (String[] args) { int j=2,i=5; while (j<i--) j++; System.out.println(j);} }

    A.2

    B.3

    C.4

    D.5


    正确答案:C
    解析:循环时,首先判断结束条件,25,然后i=4,j=3,继续循环,i=3,j=4,结果条件ji为假,退出循环,因此j=4。所以选C。

  • 第2题:

    关于下面程序,( )的结论是正确。

    publicclassJ_Test{

    publicstaticvoidmain(String[]args){

    int[]a=newint[5];

    boolean[]b=newboolean[5];

    System.out.println(a[4]);

    System.out.println(b[5]);

    }

    }

    A、程序可以通过编译并正常运行,结果输出“0false”

    B、程序可以通过编译并正常运行,结果输出“1true”

    C、程序无法通过编译

    D、程序可以通过编译,但无法正常运行


    正确答案:D

  • 第3题:

    设有以下程序,其运行输出结果为? class Test{ Test(int i) { System.out.println("Test(" +i +")"); } } public class Q12 { static Test t1 = new Test(1); Test t2 = new Test(2); static Test t3 = new Test(3); public static void main(String[ ] args){ Q12 Q = new Q12(); } }

    A.Test(1) Test(2) Test(3)

    B.Test(3) Test(2) Test(1)

    C.Test(2) Test(1) Test(3)

    D.Test(1) Test(3) Test(2)


    7

  • 第4题:

    请阅读下面程序 publicclassExampleStringBuffer{ publicstaticvoidmain(String[]args){ StringBuffersb=newStringBuffer("test"); System.out.println("buffer-,"+sb); System.out.println("longth="+sb.1ength());}} 程序运行结果中在“length”后输出的值是( )。

    A.10

    B.4

    C.20

    D.30


    正确答案:B
    解析: 本题对StfingBuffer(String str)构造方法,用str给出字符串的初始值,并分配16个字符的缓存。因此,字符串sb的初始值是“test”,并且包含16个字符的缓存。leng出()方法用来获得字符申长度,不包含缓存。故程序运行结果中在“length=”后输出的值应该是字符串sb的长度,即4。

  • 第5题:

    阅读以下说明和Java程序,填写程序中的空(1)~(6),将解答写入答题纸的对应栏内。
    【说明】
    以下Java代码实现一个简单绘图工具,绘制不同形状以及不同颜色的图形。部分接口、类及其关系如图5-1所示。




    【Java代码】
    interface?DrawCircle?{? //绘制圆形 public(1) ;}class?RedCircle?implements?DrawCircle?{? ?//绘制红色圆形???????public?void?drawCircle(int?radius,intx,?int?y)??{????????????System.out.println("Drawing?Circle[red,radius:"?+?radius?+",x:"?+?x?+?",y:"?+y+?"]");???????}}class?GreenCircle?implements?DrawCircle?{????//绘制绿色圆形??????public?void?drawCircle(int?radius,?int?x,int?y)?{???????????System.out.println("Drawing?Circle[green,radius:"?+radius+",x:?"?+x+?",y:?"?+y+?"]");??????}}abstract?class?Shape?{????//形状? protected? ? (2)???;? ? public?Shape(DrawCircle?drawCircle)?{? ?this.drawCircle=?drawCircle;? ? ? public?abstract?void?draw();}class?Circle?extends?Shape?{? //圆形? ?private?int?x,y,radius;? public?Circle(int?x,int?y,intradius,DrawCircle?drawCircle)?{? ?(3)???;? this.x?=?x;? ? ? this.y?=?y;? ?this.radius?=radius;? }? ? ?public?void?draw()?{? ? drawCircle.? ?(4)? ?;? ? ? }}public?class?DrawCircleMain?{? public?static?void?main(String[]?args)?{? Shape?redCircle=new?Circle(?100,100,10,? (5) );//绘制红色圆形? Shape?greenCircle=new?Circle(200,200,10,(6) );//绘制绿色圆形? ?redCircle.draw(); greenCircle.draw();? ?}}


    答案:
    解析:
    (1)void drawCircle (int radius,int x,int y)
    (2)DrawCircle drawCircle
    (3)super.drawcircle=drawcircle
    (4)drawCircle(radius,x,y)
    (5)new RedCircle()
    (6)new GreenCircle()【解析】
    第一空是填接口里面的方法,在接口的实现里面找,可以发现应该填void drawCircle (int radius,int x,int y)。
    第二空可以根据后面this drawCircle=drawCircle判断,这里应该有一个drawCircle属性,因此应该填)DrawCircle drawCircle。
    第三空这里用super,用super. drawcircle来引用父类的成员。
    第四空调用drawCircle(radius,x,y)方法。
    第五、六空分别创建一个红色圆形对象和一个绿色圆形对象作为Circle里面的实参。

  • 第6题:

    main方法是Java应用程序执行的入口点,下面main方法的方法头合法的是()

    A.public static void main()

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

    C.public static void Main(String[] args)

    D.public static int main(String[] args)


    public static void main( String[] args )