• 2022-05-28
    说出下列B类中【代码1】,【代码2】的输出结果 class A { public int getNumber(int a) { return a+1; } } class B extends A { public int getNumber (int a) { return a+100; } public static void main (String args[]) { A a =new A(); System.out.println(a.getNumber(10)); //【代码1】 a = new B(); System.out.println(a.getNumber(10)); //【代码2】 } }
  • 11  110

    内容

    • 0

      下列代码的输出结果是( )interface Com{ int M=100; int on();}class A implements Com{ public int on(){ return Com.M; }}public class E{ public static void main(String args[]){ Com com=new A(); int m=com.on(); System.out.println(m); }}

    • 1

      请写出下列程序的输出结果。class A{public int f(int x) {return x+1;}}class B extends A{public int f(int x){return x*x;}}public class E{public static void main(String args[]){A a=new B();int m=a.f(10);System. out. println(m) ;}}

    • 2

      5.请说出E类中[代码1],[代码2]的输出结果依次是______ ,______ 。 interface Com { int add(int a,int b); }abstract class A { abstract int add(int a,int b);int g(int a,int b) { return a+b; }}class B extends A implements Com{ public int add(int a,int b) { return a+b; } int g(int a,int b) { return a*b; }}public class E {public static void main(String args[]) { B b = new B(); Com com = b; System.out.println(com.add(10,5)); //[代码1] A a = b; System.out.println(a.g(10,5)); }} //[代码2]

    • 3

      public class E4_1{ public static void main(String args[]) { int a = 1; int b = 2; int c = 3; a += 5; b *= 4; c += a * b; c %= 6; System.out.println("a = " + a); //代码1 System.out.println("b = " + b); //代码2 System.out.println("c = " + c); //代码3 }}运行结果,代码1______ ,代码2______ ,代码3______ 。

    • 4

      给出下列代码的输出结果:public class E{public static void main(String args[]){System.out.println((int)'a');}}