• 2021-04-14
    下面的代码段的输出结果为? int count = 0; for (int i ....out.println(count);
  • 6

    内容

    • 0

      写出下列程序的输出结果 public class Test { public static void main(String&#91;&#93; args) { Count myCount = new Count(); int times = 0; for(int i=0;i<100;i++) increment(myCount , times); System.out.println(“count is” + myCount.count); System.out.println(“time is”+ times); } public static void increment(Count c , int times) { c.count++; times++; } } class Count { public int count; Count(int c) { count =c; } Count() { count =1; } }

    • 1

      48. 以下Java代码片段编译运行的结果是。 int &#91;&#93; a = {1,2,3,4,5}; for (int count = 0 ; count<5; count ++) System.out.print(a&#91;count++&#93;) int &#91;&#93; a = {1,2,3,4,5}; for (int count = 0 ; count<5; count ++) System.out.print(a&#91;count++&#93;)

    • 2

      代码中myCount.count的值为(A)?public class Test { public static void main(String&#91;&#93; args) { Count myCount = new Count(); int times = 0; for (int i=0; i&lt;100; i++) increment(myCount, times); System.out.println("myCount.count = " + myCount.count); } public static void increment(Count c, int times) { c.count++; times++; }} class Count { int count; Count(int c) { count = c; } Count() { count = 1; }} A: 101 B: 100 C: 99 D: 98

    • 3

      下列程序的运行结果是()。 public class Test public static void main ( String [ ] args ) int count = 0 for( int i = 1 i < 5 i = 2) for( int j = 1 j< = 10 j = 3) count System .out .print (count ) _

    • 4

      println 语句执行了多少次? for (int i = 0; i < 10;i++) for (int j = 0;j < i;j++) System .out.println(i * j)