File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes How can I judge if a class is serializable or not? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "How can I judge if a class is serializable or not?" Watch "How can I judge if a class is serializable or not?" New topic
Author

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

Gong James
Ranch Hand

Joined: Oct 15, 2001
Posts: 77
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

Joined: Jul 18, 2001
Posts: 317
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.


Guoqiao Sun<br />SCJP2 SCWCD2<br />Creator of <a href="http://www.jiris.com/" target="_blank" rel="nofollow">www.jiris.com</a>, Java resource, mock exam, forum
Gong James
Ranch Hand

Joined: Oct 15, 2001
Posts: 77

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

Joined: Jul 18, 2001
Posts: 317
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How can I judge if a class is serializable or not?
 
Similar Threads
inner classes
Quiz
mock question
Questions from abHilash's mockexam
abilash mock exam