• 2022-05-30 问题

    中国大学MOOC: class NumTest{ final int id = 1; int id2 = 1; NumTest(int id,int id2){ this.id = id; this.id2 = id2; } void printId(){ System.out.print(id+id2+ ); } public static void main(String[] args) { NumTest a = new NumTest(1,2); NumTest b = new NumTest(2,1); NumTest c = new NumTest(0,0); a.printId(); b.printId(); c.printId(); }}

    中国大学MOOC: class NumTest{ final int id = 1; int id2 = 1; NumTest(int id,int id2){ this.id = id; this.id2 = id2; } void printId(){ System.out.print(id+id2+ ); } public static void main(String[] args) { NumTest a = new NumTest(1,2); NumTest b = new NumTest(2,1); NumTest c = new NumTest(0,0); a.printId(); b.printId(); c.printId(); }}

  • 2022-05-30 问题

    class NumTest{ final int id = 1; int id2 = 1; NumTest(int id,int id2){ this.id = id; this.id2 = id2; } void printId(){ System.out.print(id+id2+" "); } public static void main(String[] args) { NumTest a = new NumTest(1,2); NumTest b = new NumTest(2,1); NumTest c = new NumTest(0,0); a.printId(); b.printId(); c.printId(); }} A: 3 3 0 B: 1 2 0 C: 2 1 0 D: 编译报错

    class NumTest{ final int id = 1; int id2 = 1; NumTest(int id,int id2){ this.id = id; this.id2 = id2; } void printId(){ System.out.print(id+id2+" "); } public static void main(String[] args) { NumTest a = new NumTest(1,2); NumTest b = new NumTest(2,1); NumTest c = new NumTest(0,0); a.printId(); b.printId(); c.printId(); }} A: 3 3 0 B: 1 2 0 C: 2 1 0 D: 编译报错

  • 1