阅读以下程序:classAA{doublex=1.1;doublemethod(){returnx;}}classBBextendsAA{doublex=2.2;doublemethod(){returnx;}publicstaticvoidmain(Stringargs[]){AAa=newBB();System.out.println(a.x);}}程序的输出结果是:()
A. 1.1
B. 2.2
C. 0
D. 编译出错
查看答案
阅读以下程序代码:classAA{doublex=1.1;doublemethod(){returnx;}}classBBextendsAA{doublex=2.2;doublemethod(){returnx;}publicstaticvoidmain(Stringargs[]){AAa=newBB();System.out.println(a.method());}}程序的输出结果是()。
A. 1.1
B. 2.2
C. 0
D. 编译出错
使用下列哪个关键字,可以判断一个变量的具体类型()?
A. as
B. is
C. instanceof
D. extends
运用所学有关“多态”的编程知识,分析程序:public class Pencil {public void write(String content) {System.out.println("Write" + content);}public static void main(String[] args) {Pencil pen=new Pencil();(( RubberPencil) pen).write( "Hello");}}class RubberPencil extends Pencil {public void write(String content) {System.out.println("Rubber Write" + content);}public void erase(String content) {System.out.println("Erase " + content);}}执行以上程序代码的结果是()?
A. Write Hello
B. Rubber Write Hello
C. 运行时抛出异常
D. 编译失败
阅读以下代码:class TestA {public void start() { System.out.println("TestA"); }}public class TestB extends TestA{public void start() { System.out.println("TestB"); }public static void main(String[] args) {((TestA)new TestB()).start();}}运行结果是哪项()?
A. TestA
B. TestB
C. 编译失败
D. 运行时抛出异常