问题描述:
类Teacher和Student是类Person的子类
Person p;
Teacher t;
Student s;
//p,t and s are all non-null.
if(t instanceof Person) { s = (Student)t; }
最后一句语句的结果是:
A、 将构造一个Student对象;
B、 表达式是合法的;
C、表达式是错误的;
D、编译时正确,但运行时错误.
Person p;
Teacher t;
Student s;
//p,t and s are all non-null.
if(t instanceof Person) { s = (Student)t; }
最后一句语句的结果是:
A、 将构造一个Student对象;
B、 表达式是合法的;
C、表达式是错误的;
D、编译时正确,但运行时错误.
问题解答:
我来补答展开全文阅读