• 2022-06-09
    下面代码的运行结果是_____________。publicclassTest{publicstaticvoidmain(String[]args){int[]a=newint[3];int[]b=newint[]{1,2,3,4,5};a=b;for(inti=0;i<b.length;i++){System.out.print(a[i]+"");}}}[/i]
    A: 程序报错
    B: 123
    C: 12345
    D: 000
  • C

    内容

    • 0

      以下程序的输出结果是【 】。 class Program { public static void Main(string&#91;&#93; args) { int&#91;&#93; a = new int&#91;3&#93; { 1, 2, 3 }; for (int i = 0; i < 3; i++) Console.Write("{0} ", a[i]); Console.WriteLine(); int&#91;&#93; b = a; for (int i = 0; i < 3; i++) b[i] = 2 * b[i]; for (int i = 0; i < 3; i++) Console.Write("{0} ", a[i]); Console.WriteLine(); Console.Read(); } }[/i][/i][/i][/i]

    • 1

      下面代码的运行结果是。 public class Test { public static void main(System&#91;&#93; args){ int&#91; &#93; a ={10,20,30}; int&#91; &#93; b ={1,2,3,4,5}; a=b; for (int i=0;i<a.length;i++){ System.out.print(a[i]+” ”); } } }[/i]

    • 2

      int&#91;&#93;&#91;&#93;a=newint&#91;&#93;&#91;3&#93;;是合法的

    • 3

      下面代码的输出是什么? int &#91;&#93;&#91;&#93; array = {{1, 2},{3, 4},{5,6}}; int sum = 0; for(int i = 0; i < array.length; i++) sum = sum + array[i]&#91;0&#93;; System.out.println(sum);[/i]

    • 4

      关于二维数组的创建,以下做法正确的是:(1)int a&#91;&#93;&#91;&#93; =new int&#91;4&#93;&#91;5&#93;(2)int a&#91;&#93;&#91;&#93; =new int&#91;4&#93;&#91;&#93;; a&#91;0&#93;=new int&#91;10&#93;; a&#91;1&#93;=new int&#91;20&#93;;(3)int a&#91;&#93;&#91;&#93;; a=new int&#91;3&#93;&#91;&#93;; a&#91;0&#93;=new int&#91;3&#93;; a&#91;1&#93;={1,2};a&#91;2&#93;={1,2,3}; A: (1)(2)(3) B: (1)(2) C: (1)(3) D: (1)