题目内容

以下程序的运行结果是()class Base {protected String var = "父类变量";public static void staticMethod(){System.out.println("父类静态方法");}}class Sub extends Base {public String var="子类变量";public static void staticMethod(){System.out.println("子类静态方法");}}public class Test{public static void main(String[] args){System.out.println(new Sub().var);Base b = new Sub();b. staticMethod()}}

A. 不能通过编译
B. 父类变量
C. 子类变量

查看答案
更多问题

以下哪个接口的定义是正确的?()

A. interface B
B. abstract interface B
C. abstract interface B extends A1,A2 //A1、A2为已定义的接口

下面的程序中定义了一个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

给定如下Java代码,不可以填入下划线处的语句是()public interface Shape{}class TwoDemension implements Shape{}class Circle extends TwoDemension {}class Triangle extends TwoDemension {}public class Test{public static void main(String[] args) {________}}

A. Shape shape=new Shape();
B. TwoDemension circle =new Circle ();
C. Shape shape =new TwoDemension();
D. TwoDemension triangle =new Triangle ();

下面的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

答案查题题库