How will you override default serialization mechanism in java

Answers were Sorted based on User's Feedback



How will you override default serialization mechanism in java..

Answer / sharmila

Serializable is a marker interface. But you may wish to
control on how an object is serialized instead of using the
default mechanism. In such case add implementations of the
readObject() and/or writeObject() methods to the class being
serialized and override default serialization mechanism.

Also, instead of using Serializable interface,
Externalizable interface can be used

Is This Answer Correct ?    4 Yes 3 No

How will you override default serialization mechanism in java..

Answer / amit singh

you can inplements the Serialization interface for those
class you want to serailize
its marker interface its haven't any behaviour
but it indiacte that particular class is serializable
you can read and write particular object to convert in a
byte.
class Amit implements Serializable
{
Amit()
{
}
}
class B
{
public static void main(String []args)
{
Amit a = new Amit();
try{

}
catch{IoExcepton e)
{
}
try{
FileIntputStream f = new FileIntputStream("apoorva.txt")
OjectIntputStream o = new ObhjctInputStream(f);
o.ReadObject();
}
catch(IoException e)
{
}
}
thanks amit singh
amitsing2008@gmail.com

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More Core Java Interview Questions

What will happen if a thrown exception is not handled?

0 Answers   ABB, Akamai Technologies, Infogain,


Explain the transient field modifier?

0 Answers  


What are the advantages of exception handling?

0 Answers  


What is static binding and where it occurs?

4 Answers  


What is an example of procedure?

0 Answers  






What is consumer in java?

0 Answers  


What is the default initialized value of a boolean type variable?

3 Answers  


How would you format a date in java? I.e. In the ddmmyyy format?

0 Answers  


What is regex in java?

0 Answers  


If I have 1000 objects and my requirement is to sort them quickly, then which collection would you recommend and why?

5 Answers   KPIT,


what is the form of storage space in java?

5 Answers  


What is use of map in java?

0 Answers  


Categories