• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can I judge if a class is serializable or not?

 
Gong James
Ranch Hand
Posts: 77
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question 7.
A Vector class in jdk 1.2
1.is public
2.is final
3.implements java.util.List
4.is serializable
has only One constructor

ans:1.3.4
--------------------------------------------------------------------------------
Question 8.
A String Class
1.is final
2.is public
3.is serializable
4.has a constructor which takes a StingBuffer Object as an Argument
ans:1.2.3.4.
In the jdk-doc ,it deosn't specify the feature if a class/interface is subclass of the serializable interface,such as the class String.How can I judge wheathe a class is serializable??
How can I judge if a class is serializable or not?
 
Guoqiao Sun
Ranch Hand
Posts: 317
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, James:
A class mark itself as Serializable by either implementing Serializable or Externalizable. The former one is just a mark interface with no method defined. The latter is the sub-interface of the former one.
Hope it helps,

------------------
Guoqiao Sun
Sun Certified Programmer for Java™ 2 Platform
try my mock exam¹²³ at my homepage.
 
Gong James
Ranch Hand
Posts: 77
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

As is well know that Vector is serializable ,but when i look up the jdk-doc ,I can't find the key-word such as "implements serializable "or"implements exserializable ".

Can you give me a explaination about it ,thank you very much ,I am beginner!!
 
Guoqiao Sun
Ranch Hand
Posts: 317
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How come? JDC in my side says
public class Vector
extends AbstractList
implements List, Cloneable, Serializable.
Check it again!
Regards

------------------
Guoqiao Sun
Sun Certified Programmer for Java™ 2 Platform
try my mock exam¹²³ at my homepage.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic