controlling serialization
<p>I was going through an article which states..If Super Class of a Class already implements Serializable interface in Java then its already serializable in Java, since you can not unimplemented an interface its not really possible to make it Non Serializable class but yes there is a way to avoid serialization of new class. To avoid java serialization you need to implement writeObject () and readObject () method in your Class and need to throw NotSerializableException from those method. This is another benefit of customizing java serialization process as described in above question and normally it asked as follow-up question as interview progresses.</p>

<p>for ex .. there is a superclass ..</p>

<pre><code>class Animal implements Serializable
 { 
int weight = 42;
}

and there is a subclass...

class Dog extends Animal
{
    private void writeObject(ObjectOutputStream o)   
                           throws IOException, ClassNotFoundException  
    {  
       //throw nonserializable exception
    }  

  private void readObject(ObjectInputStream o)   
        throws IOException, ClassNotFoundException  
    {  
            //throw nonserializable exception
    }  

}
</code></pre>

<p>Could you please advise me as seen above in Dog class inside readobject() and writeobject() , How could i write the code that indicates to throw the nonserilizable exception..is it like throws non seriliable exception...please advise..</p>
