更多“顺序执行下列两条语句,输出结果是______。String s="You are a pretty boy!";System.out.println( ”相关问题
  • 第1题:

    下列程序的输出结果是( )。 public class Test { public static void main (String[] args) { String s="hello"; s.replace ('r','m'); System.out.println(s); } }

    A.hello

    B.HELLO

    C.hemmo

    D.HEMMO


    正确答案:A
    解析:String类的replace (char oldChar,char newChar)函数的作用是返回一个新的字符串,它是通过用newChar替换此字符串中出现的所有oldChar而生成的。返回的是新字符串,但是原字符串变量的值并未发生改变。因此,输出的是“hello”而不是“hemmo”。如果替换语句换为: s=s.replace('l','m');,则输出“hemmo”。

  • 第2题:

    执行如下语句之后,输出的结果是______。 public class ex36 { public static void main(String[] args) { int x=-6, y=6; x=x+y--; System.out.println (x); } }

    A.-12

    B.12

    C.-1

    D.0


    正确答案:D

  • 第3题:

    顺序执行以下两个语句的输出结果是: 。 String s = "广东海洋大学"; System.out.println(s.length());


    String s='我喜欢学习Java!';System.out.prinfin(s.length()); Strings='我喜欢学习Java!';System.out.prinfin(s.length());

  • 第4题:

    执行如下语句之后,输出的结果是______。 public class ex24 { public static void main(String[] args) { int x=5,y=3; x+=X-- *--y; System.out.println{x); } }

    A.0

    B.1

    C.true

    D.false


    正确答案:C

  • 第5题:

    下列程序执行后的输出结果是()。includeincludemain(){char arr[2][4]; str

    下列程序执行后的输出结果是( )。 #include<stdio.h> #include <string.h> main() { char arr[2][4]; strcpy(arr[0],"you");strcpy(arr[1],"me"); arr[0][3]='&'; Printf("%s\n",arr); }

    A.you&me

    B.you

    C.me

    D.err


    正确答案:A
    解析:函数strcpy的功能是字符串拷贝,函数原型为char*strcpy(char*strl,char*str2),作用是将字符串2复制到字符串1中去。二维数组可以看做是一种特殊的一维数组,它的每一个元素又是一个一维数组。本题arr可看做是一个具有两个元素arr[0]和arr[1]的一维数组,每个元素又是一个包含四个元素的一维数组。