下列标注行中,( )行代码有错。 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
A: 1
B: 2
C: 3
D: 4
举一反三
- 下列代码中,( )行代码有错。 interface Com{ int Max; //1 public void stop(); //2 void start(); //3 abstract void loop();//4 } A: 1 B: 2 C: 3 D: 4
- 程序填空: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();
- 下列代码的输出结果是( )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.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( );
- 阅读程序题(给出【代码】注释标注的代码的输出结果)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); //【代码】}}