单项选择题
现有:
class Top {
static int X=l;
public Top() { x*=3; }
}
class Middle extends Top {
public Middle() {x+=l; }
public static void main(String [] args) {
Middle m=new Middle();
System.out.println (x);
}
}
结果是什么?()
A. 2
B. 3
C. 4
D.编译失败
点击查看答案&解析
相关考题
-
单项选择题
现有: 1. abstract class Color2 { 2. //insert code here 3. } 4. 5. public class Blue2 extends Color2 { 6.public String getRGB() { return "blue"; } 7. } 和4个声明: public abstract String getRGB(); abstract String getRGB(); private abstract String getRGB(); protected abstract String getRGB(); 分别插入到第2行,有多少行可以编译?()
A. 0
B. 1
C. 2
D. 3 -
单项选择题
现有: 1. abstract class Color { 2.protected abstract String getRGB(); 3. } 4. 5. public class Blue extends Color { 6. //insert code here 7. } 和四个声明: public String getRGB() { return "blue"; } String getRGB() { return "blue"; ) private String getRGB() { return "blue"; } protected String getRGB() { return "blue"; ) 分别插入到第6行,有几个可以通过编译?()
A. 0
B. 1
C. 2
D. 3 -
单项选择题
现自: 1. interface Color { } 2. interface Weight { } 3. //insert code here 和以下足六个声明: class Boat extends Color, extends Weight { } class Boat extends Color and Weight { } class Boat extends Color, Weight { } class Boat implements Color, implements Weight { } class Boat implements Color and Weight { } class Boat implements Color, Weight { } 分别插入到第3行,有多少行可以编译? ()
A. 0
B. 1
C. 2
D. 3
