1.下面的程序中定义了一个java接口,其中包含()处错误。
public interface Utility{
private int MAX_SIZE=20;
int MIN_SIZE=10;
void use(){
System.out.println("using it");
}
private int getSize();
void setSize(int i);
}
A.1
B.2
C.3
D.4
2.给定如下Java代码,可以填入下划线处的语句是()。(选三项)
public interface Utility{
class Fourwheeler implements Utility{}
class Car extends Fourwheeler{}
class Bus extends Fourwheeler{}
public class Test{
public static void main(String[] args) {
________
}
}
}
A. Utility car=new Utility();
B.Fourwheeler bus=new Bus();
C.Utility ut=new Utility();
D.Bus bus=new Fourwheeler();
E.Fourwheeler fw=new Fourwheeler();
3.以下()修饰符用于声明一个类的变量,且该变量的值在运行期始终保持不变。
A.static
B.final
C.static final
D.final static
4.给定下面的Java代码,可以填入下划线处的语句是()。
public interface Constants{
int MAX=50;
int MIN=1;
}
public class Test{
public static void main(String[] args) {
______
}
}
A.Constants con=new Constants();
B.Constants.MAX=100
C.int i=Constants.MAX-Constants.MIN
D.Constants.MIN>0;
5.将公有成员变量MAX是一个int型值,变量的值保持常数值100。在类Constants中,可以使用以下()声明语句来定义这个变量。
A.public int MAX=100;
B.final int MAX =100;
C.public static int MAX=100;
D.public final int MAX=100;
ACCP教程网的参考答案:
1.C
2.ABF
3.CD
4.AC
5.D

评论加载中....