• 2022-06-19
    ‌程序填空:‏‌interface Com{ int M=200; int f(); } class ImpCom implements Com{ ___________________________; }‏
    A: public int f(){retrun 100+M;}
    B: int f() {return 100;}
    C: public double f(){return 2.6;}
    D: public abstract inf f();
  • A

    举一反三

    内容

    • 0

      请写出下列程序的输出结果。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) ;}}

    • 1

      下列标注行中,( )行代码有错。 interface Com{ int MAX=100; //1 void f(); } abstract class Animal implements Com{ int MIN; //2 } class Dog extends Animal{ public void f(){ MIN=10; //3 MAX=200; //4 } } A: 1 B: 2 C: 3 D: 4

    • 2

      E类中System.out.println的输出结果是__________、________________。interface Com{int add(int a,int b);}abstract class A{abstract int add(int a,int b);}class B extends A implements Com{public int add(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(12,6));A a=b;System.out.println(a.add(10,5));}}

    • 3

      阅读程序题(给出【代码】注释标注的代码的输出结果)interface Com {int add( int a, int b);}abstract class People {abstract int add( int a, int b);}class Student extends People implements Com{public int add(int a,int b) {return a + b;}}public class 习题5_阅读3 {public static void main(String args[ ]) {Student stu = new Student ();Com com = stu;int m = com.add(12,6);People p = stu;int n = p.add(12,8);System.out.printf("%d:%d",m,n); //【代码】}}

    • 4

      阅读程序题(给出【代码】注释标注的代码的输出结果)interface Com {int add(int a, int b);public static int get(int n){return n;}public default int see( int n){return n;}public default int look( int n) {return n;}}class A implements Com{public int add( int a, int b) { return a + b;}public int see(int n){ return n + 1;}}public class 习题5_阅读4{public static void main( String args[ ]) {A a = new A();int m = a.add(12,6);int n = Com.get( 12);int t = a.see(6);int q = a.look(6);System.out.printf("%d:%d:%d:%d",m,n, t,q); //【代码】 }}}