1) 在Java中,如果父类中的某些方法不包含任何逻辑,并且需要有子类重写,应该使用(c)关键字来申明父类的这些方法。
a) Finalc
b) Static
c) Abstract
d) Void
2) 给定两个java程序,如下:
public interface Face{
int counter = 40;
}
public class Test implements Face{
private static int counter;
public static void main(String[ ]args){
System.out.println(++counter);
}
}
Test.java 的编译运行结果是(d)。
a) 40
b) 41
c) 0
d) 1
3) 给定java代码,如下:
public class Test{
static int i;
public int aMethod( ){
i++;
return i;
}
public static void main(String [] args){
Test test = new Test( );
test.aMethod( ); 1
System.out.println(test.aMethod( )); 2
}
}
编译运行后,输出结果是( c)。
a) 0
b) 1
c) 2
d) 3
4) 给定java代码,如下:
abstract class Shape
{
abstract void draw( );
}
要创建Shape类的子类Circle,以下代码正确的是(b,d)。
a) class Circle extends Shape{
int draw( ){}
}