SCJP考试试题解析九

我的QQ号:2535279 


www.javaedu.com.cn

Which three statements concerning the use of the java.io.serializable interface are true?(choose three)

A.Object from classes that use aggreagtion cannot be serialized.

B.An object serialized on one JVM can be successfully desterilized on a different JVM.

C.The values in fields with the Volatile modifier will NOT survive serialization and deserialization

D.The values if field with the transient modifier will NOT survive serialization and deserialization

E.It is legal to seialize an object of a type that has a supertype that does NOT implement java.io.Serializable

我先说一下答案:B,D,E

下面我来说一下为什么是这几个答案.

当我们需要跨JVM使用一个对象时,我们就需要使用到序列化这个技术,这也是Java中使用序列化的一个目的,这是一个常识.所以,答案B是正确的

关于选项D.比方说,我们现在有一个类User的对象user,这个对象中包含一个password属性,我们不希望序列化出去,也就是说,我们不希望别人看到这个属性,为了把这个属性隐藏起来,我们使用transient关键字.所以,这个也是正确的选项.

选项E,我另有一篇帖子<<继承对序列化的影响>>解释过这个问题,已经发在论坛上,如果大家想了解,可以找来看看.