• 2021-04-14
    下列 A 类中【代码 1】~【代码 4】哪个是错误的?
    class Tom {
    private int x = 120;
    protected int y = 20;
    int z = 11;
    private void f() {
    x = 200;
    System.out.println(x);
    }
    void g() {
    x = 200;
    System.out.println(x);
    }
    }
    public class A {
    public static void main(String args[]) {
    Tom tom = new Tom();
    tom.x = 22; //【代码 1】
    tom.y = 33; //【代码 2】
    tom.z = 55; //【代码 3】
    tom.g(); //【代码 4】
    }
    }
  • 【代码 1】

    内容

    • 0

      以下代码的输出结果为( ) public class Pass{ static int j = 20; public void amethod(int x){ x = x*2; j = j*2; } public static void main(String args[]){ int i = 10; Pass p = new Pass(); p.amethod(i); System.out.println(i+" and "+j); } }

    • 1

      class Tom { int x = 5,y; void f() { int x = 10; y = x+x; } 请问y的值是多少? A: 10 B: 15 C: 20

    • 2

      智慧职教: 以下给出代码运行后的结果是? public class Example { public static void main(String[] args) { int x=1; int y=~x+1; System.out.println(x+" "+y); } }

    • 3

      分析以下C#代码,其运行结果是______ using System;class Test{ public static void Main() { int x = 5; int y = x++; y=++x; Console.Write (y); }}

    • 4

      智慧职教: 下列代码执行之后,变量x的值为(   ) public class Test { public static void main (String[] args) { int x=5; int m=0; x+=x+++(x+++m); System.out.println(x); } }