A: public int f(){retrun 100+M;}
B: int f() {return 100;}
C: public double f(){return 2.6;}
D: public abstract inf f();
举一反三
- 下列选项中,( )代码替换源文件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( );
- 将下列(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/>【代码】}
- 将下列(A,B,C,D)哪个代码替换下列程序中的【代码】不会导致编译错误。 A.public int f(){return 100+M;} B.int f(){return 100;} C.public double f(){return 2.6;}。 D.public abstract int f(); interface Com { int M = 200; int f(); } class ImpCom implements Com { 【代码】 }
- 下列代码的输出结果是( )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); }}
- 对于下列Com接口(Com.java)类,哪个叙述是正确的? interface Com {int MAX = 100;int f(); } A: Com是一个public接口。 B: 编译器认为int MAX = 100;就是 public static final int MAX = 100; C: 编译器认为int f();就是abstract int f(); D: 编译器认为int MAX = 100;就是 public final int MAX = 100;
内容
- 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); //【代码】 }}}