• 2022-05-28
    下列代码的输出结果是( )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); }}
  • 100

    举一反三

    内容

    • 0

      下列选项中,( )代码替换源文件Com.java中的【代码】不会导致编译错误。public interface com{int M=200;int f();}class ImpCom implements Com{【代码】} A: public int f( ){return 100+M;} B: int f( ){return 100;} C: public double f( ){return 2.6;} D: public abstract int f( );

    • 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

      将下列(A,B,C,D)哪个代码替换下列程序中的【代码】不会导致编译错误。(<br/>) A: public<br/>int f(){return 100+M;} B: int<br/>f(){return 100;} C: public<br/>double f(){return 2.6;}。 D: public<br/>abstract int f();<br/>interface Com {<br/>int M = 200;<br/>int f();}<br/>class ImpCom implements Com {<br/>【代码】}

    • 3

      public class test { public static void main(String args[]) { int m=0; for ( int k=0;k<2;k++) method(m++); System.out.println(m); } public static void method(int m) { System.out.print(m); } }

    • 4

      给出下列【代码】注释标注的代码的输出结果。abstract class A {abstract int get(int a,int b);}public class E {public static void main(String args&#91;&#93;) {A a=new A() {public int get(int a,int b){return a+b;}};int m = a.get(2,5);a=new A() {public int get(int a,int b){return a*b;}};int n = a.get(2,5);System.out.printf("%d:%d",m,n);//【代码】}}