Java认证模考试题(七)

文章作者 100test 发表时间 2007:03:14 17:02:45
来源 100Test.Com百考试题网


Question: 38


The Person, Student and Teacher are class names. These classes have the following inheritance relation as shown below:

Person

|

---------------

| |

Student Teacher

There is the following expression in a Java source file:

Person p = new Teacher().

Which of the following expressions return true?


A. p instanceof Teacher

B. p instanceof Student

C. p instanceof Person

D. None of them returns true

Explanation:


The instanceof operator is used to test the type of an object. Because the reference p refers to a Teacher object and the Teacher is a subclass of the Person class the expressions in answer A and C will return true.

Correct Answer: A,C 38 of 60



相关文章


了解Java密码扩展的基础
Java认证模考试题(十)
java基础--JAVA字符集
Java认证模考试题(八)
Java认证模考试题(七)
JAVA基础:Java启动器如何查找类
Java程序设计知识与技能(五)
LineNumberReader提供更好的出错消息
Java认证模考试题(六)
澳大利亚华人论坛
考好网
日本华人论坛
华人移民留学论坛
英国华人论坛