wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes doubt in serializatiion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "doubt in serializatiion" Watch "doubt in serializatiion" New topic
Author

doubt in serializatiion

arulraj michaelraj
Greenhorn

Joined: Mar 07, 2007
Posts: 14
if you want to have the state of object for a class, we go for serializtion concept. It means that we just implent serializable interface for our class.

Generally we don't implemment it in a class. Even if it is not implemented, the state of object(serialized)is serialized.


how it is possible?

How will take care of it?

How it is possible for java bean?


Can you please explan it...
Sunil Vasudevan
Ranch Hand

Joined: Mar 05, 2007
Posts: 107
java.io.Serializable is a marker interface. A marker interface is an interface which do not declare any methods in it.

By implementing this class, we let the JVM know that this class needs to be treated differently and can be serialized.


Sunil.V<br />SCJP2, SCWCD1.4, SCBCD1.3
arulraj michaelraj
Greenhorn

Joined: Mar 07, 2007
Posts: 14
Thanks for reply.


If we don't implement serializable interface, what will it happen?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36514
    
  16
If we don't implement serializable interface, what will it happen?
Easy question to answer: you can't serialize the object. Most people producing code for use in the "real world" would implement the Serializable interface on spec, because you can get a NonSerializableException if you try to serialize an instance whose fields are not all serializable.

There is another mechanism for (long-term) object persistence: use of JavaBeans. I hardly know anything about them
arulraj michaelraj
Greenhorn

Joined: Mar 07, 2007
Posts: 14
1. Can we provide our own serialize concept by overriding method "writeObject(java.io.ObjectOutputStream)" in a class?

2. what about java-bean? sould we implement serializable interface for java bean to store the object of that bean?
Sunil Vasudevan
Ranch Hand

Joined: Mar 05, 2007
Posts: 107
1. Can we provide our own serialize concept by overriding method "writeObject(java.io.ObjectOutputStream)" in a class?


You can provide your own serialize concept. But on a practical assignment you would rarely need to do it.

2. what about java-bean? sould we implement serializable interface for java bean to store the object of that bean?


Java bean is a java class that adheres to Java Bean specification. http://java.sun.com/products/javabeans/docs/spec.html

Yes, java bean classes should also implement Serializable interface.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: doubt in serializatiion
 
Similar Threads
How to identify whether the object is serialized or not?
What is Serialization?
new to java... about serialization...
What is the need for marker interface ?
Persistent state java object