题目内容

一个类中,用static修饰的方法称静态方法:

A. 该类中其它方法不能调用它;
B. 它不能直接调用类中其它不用static修饰的方法;
C. 没有用类创建对象之前,类外无法调用该方法;
D. 类外调用该方法的方式必须是:对象名.方法名(实参数据)。

查看答案
更多问题

若有如下接口A的定义,下列哪些类下确实现了该接口interface A {void method1(int i);void method2(int j);}

A. class B implements A{void method1( ) { }void method2( ) { }}
B. class B {void method1(int i ) { }void method2(int j ) { }}
C. class B implements A {void method1(int i ) { }void method2(int j ) { }}
D. class B implements A{public void method1(int x ) { }public void method2(int y ) { }}

在Java中,有如下两个类Student和Person。如果Student是Person的子类,则下列声明对象x的语句中错误的是()。

A. Personx=newStudent()
B. Personx=newPerson()
C. Studentx=newPerson()
D. Studentx=newStudent()

关于以下程序叙述正确的是:class Base {Base(int i){System.out.print(“Base ”);}}class Test extends Base{Test ( ){System.out.print(“Test ”);}public static void main(String[] args){Test b = new Test();}}

A. 程序运行出错,因为Base类未定义构造方法;
B. 程序运行正常,输出Base ;
C. 程序运行正常,输出Base Test ;
D. 程序运行正常,但无输出 。

如果Triangle类继承自Shape类,那么Shape类中的哪些变量可以用于Triangle类中?()

A. Shape类中所有声明为static的变量
B. Shape类中的所有变量
C. Shape类中所有public和protected变量
D. Shape类中所有public和private变量

答案查题题库