指出下列程序运行的结果public class Example{ String str=newString("good"); char[]ch={'a','b','c'}; public static voidmain(String args[]){ Example ex=new Example();ex.change(ex.str,ex.ch); System.out.print(ex.str+" and ");Sytem.out.print(ex.ch); } public void change(S

题目

指出下列程序运行的结果public class Example{ String str=newString("good"); char[]ch={'a','b','c'}; public static voidmain(String args[]){ Example ex=new Example();ex.change(ex.str,ex.ch); System.out.print(ex.str+" and ");Sytem.out.print(ex.ch); } public void change(String str,charch[]){ str="test ok"; ch[0]='g'; } } ( )

AA good and abc

Bgood and gbc

Ctest ok and abc

Dtest ok and gbc


相似考题
参考答案和解析
参考答案B
更多“指出下列程序运行的结果public class Example{ String str=newString("good"); c ”相关问题
  • 第1题:

    下列程序运行的结果为:

    public class Example{

    String str=new String("good");

    char[] ch={'a','b','c'};

    public static void main(String args[]){

    Example ex=new Example();

    ex.change(ex.str,ex.ch);

    System.out.print(ex.str+" and ");

    Sytem.out.print(ex.ch);

    }

    public void change(String str,char ch[]){

    str="test ok";

    ch[0]='g';

    }

    }

    A. good and abc

    B. good and gbc

    C. test ok and abc

    D. test ok and gbc


    正确答案:B

  • 第2题:

    【判断题】(10-8)运行下面程序,输出结果是true。 public class Demo6 { public static void main(String[] args) { String str1="good"; String str2="good"; System.out.println(str1==str2); } }

    A.Y.是

    B.N.否


    D 该题首先给二维数组赋值a[3][4]={{1,3,5,7}{9,11,13,15}{17,19,21,23}};(*P)[4]=a指针P指向二维数组a的首地址,接下来执行for循环,首先i=0,j=0时k=k+*(}(P+O)+0)=1(a[O][0]);然后i_0,j=1时k=k+}(}(P+0)+1)=4(a[0][1]);然后j=2时,跳出j的循环,执行i的循环i=1,j=0时k=k+*(*(P+1)+O)=13(a[1][0]);依次类推一直到i-3时跳出全部循环。循环语句在这里的功能是累加二维数组第1列和第2列的元素,累加结果为60。

  • 第3题:

    下列程序段执行结果是___________。 x = 1 print(type(x)) x = 1.0 print(type(x)) x = '1.0' print(type(x)

    A.<class 'int'> <class 'float'> <class 'str'>

    B.<class 'float'> <class 'int'> <class 'str'>

    C.<class 'str'> <class 'float'> <class 'int'>

    D.<class 'str'> <class 'int'> <class 'float'>


    C.循环执行1次

  • 第4题:

    下列程序段的运行结果是() String str1 = “Good”; String str2 = “morning”; String str3 = str1.toLowerCase()+str2.toUpperCase(); System.out.println(str3);

    A.Goodmorning

    B.gOODmORNING

    C.goodmorning

    D.goodMORNING


    goodMORNING

  • 第5题:

    00330038003000301585067361821下列程序段执行结果是___________。 x = 1 print(type(x)) x = 1.0 print(type(x)) x = '1.0' print(type(x)

    A.<class 'int'> <class 'float'> <class 'str'>

    B.<class 'float'> <class 'int'> <class 'str'>

    C.<class 'str'> <class 'float'> <class 'int'>

    D.<class 'str'> <class 'int'> <class 'float'>


    A