下面的程序中定义了一个Java接口,其中包含()处错误。 public interface Utility { [br][/br] private int MAX_SIZE = 20; int MIN_SIZE = 10; void use(){ System.out.print("using it"); } private int getSize(); void setSize(int i); }
A: 1
B: 2
C: 3
D: 4
A: 1
B: 2
C: 3
D: 4
举一反三
- 若有如下接口A的定义,下列哪些类下确实现了该接口[br][/br]interface A {[br][/br]void method1(int i);[br][/br]void method2(int j);[br][/br]} A: class B: implements A{<br>void method1( ) { }<br>void method2( ) { }<br>}<br> <br><br>class B {<br>void method1(int i ) { }<br>void method2(int j ) { }<br>} C: class B implements A {<br>void method1(int i ) { }<br>void method2(int j ) { }<br>} D: class B implements A{<br>public void method1(int x ) { }<br>public void method2(int y ) { }<br>}
- 在下面的类中,合法重载的方法是( ) public class Q1{ public void method(int i){} } A: private void method(int i){} B: public void method(int k){} C: public int method(int i){} D: private float method(float f){}
- 【多选题】已知代码如下 class Rectangle { private int width, height; public void setSize(int width, int height) { this.width = width; this.height = height; } } 下面哪些代码重载 setSize 方法 (10.0分) A. protected void setSize(int width, int height) { this(width, height) } B. public void setSize(int width, float height) { this.width = width; this.height = (int)height; } C. protected void setSize(int width) { this.width = width; } D. public void setSize(int height, int width) { this.width = width; this.height = height; }
- 下列程序的运行结果是()。 public class Test public static void main ( String [ ] args ) int count = 0 for( int i = 1 i < 5 i = 2) for( int j = 1 j< = 10 j = 3) count System .out .print (count ) _
- 下列标注行中,( )行代码有错。 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