What is meant by Serialization and Externalization? Serialization is a Marker interface,so what is the use of WriteObject() anf ReadObject(), Where it is actually used? Give me some real time examples?

Showing Answers 1 - 17 of 17 Answers

tejaswee

  • May 16th, 2006
 

Dear,

 

Marker Interface is used by java runtime engine (JVM) to identify the class for special processing.

 

Sterilization is a process of converting state of an object to stream of bytes that can be sent over network or can be stored in a file or in database to be reconstructed into Object Later when required. Remember EJB spec, all EJB (Session or Entity) implements Serializable interface indirectly, in case of Statefull session bean it can be Passivated or Activated (Persisted by writing it to file system or Database this is done by container).

 

Externalization is same as Sterilization except that WriteObject() and ReadObject() method are called by JVM during sterilization an desterilization of object. One thing you can do with Externalization is that you can store extra information into object like STATIC variables and transient variables or you can add more information if you have any business need. One good example is compressing and uncompressing of data to send it through network or converting one format to other like a BMP image to JPEG or GIF format.

 

If you did not understand let me know I will give some more examples

 

Cheers

Tejaswee

  Was this answer useful?  Yes

Teju

  • May 20th, 2006
 

Your explanation was clear enough, but if you can send me more examples I will appreciate it.

Thanks

  Was this answer useful?  Yes

mohan reddy

  • Dec 12th, 2006
 

ya i am not getting corret IDEA could explain me with a coding example

Thanks&Regards

Mohan

  Was this answer useful?  Yes

HanumanthaRao

  • Mar 24th, 2007
 

I want some examples comparing Serialization and Externalization

  Was this answer useful?  Yes

harini

  • Jun 5th, 2007
 

Marker Interface is used by java run time engine (JVM) to identify the class for special processing. Sterilization is a process of converting state of an object to stream of bytes that can be sent over network or can be stored in a file or in database to be reconstructed into Object Later when required. Remember EJB spec, all EJB (Session or Entity) implements Serializable interface indirectly, in case of Stateful session bean it can be Passivated or Activated (Persisted by writing it to file system or Database this is done by container). Externalization is same as Sterilization except that WriteObject() and ReadObject() method are called by JVM during sterilization an desterilization of object. One thing you can do with Externalization is that you can store extra information into object like STATIC variables and transient variables or you can add more information if you have any business need. One good example is compressing and uncompressing of data to send it through network or converting one format to other like a BMP image to JPEG or GIF format. If you did not understand let me know I will give some more examples 

  Was this answer useful?  Yes

Chaitanya . I

  • Aug 11th, 2007
 

methodOne()
{
   try
{
        int i;
      System.out.println( i++);

          methodTwo() ;
   System.out.println(++i);


  }

  catch (Exception e)
 {
    System.out.println(e);
 }
     }

   methodTwo()
 {
     System.out.println("Something");
 }

  Questiion  :  If exception arises in methodTwo() then it will be catched in methodOne () or not ?

  Was this answer useful?  Yes

avisnk

  • Dec 19th, 2007
 

It will be caught in the methodone() catch block....ANy exception thrown will be look for a corresponding catch method...if not present, then look for the catch block in the caller method and so on....Since methodtwo() of urs doesnt have one it will be caught in the methodone() catch block......

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions