inheritance « serialize « Java I/O Q&A





1. Making Child classes as Non Serializable in java    stackoverflow.com

I have a class which implements Serializable. Now I extends this class and I want this extended class to be non Serializable. So how to do it? For example. I have

 ...

2. Best way to mark an inherited class as NOT serializable    stackoverflow.com

If I inherit from a class that is serializable but I specifically do not want my class to be serializable; what's the best way to strictly prevent serialization? If there was ...

3. Deserializing a random derived class of a known superclass    stackoverflow.com

I'm new to serialization, so this might be a simple question, but my google-fu is weak today. Suppose you have the following classes:

public class Base implements Serializable {
    // ...

4. How to make a class inheriting of serializable class not serializable ever?    stackoverflow.com

Let's consider the following code:

public class MyPanel extends JPanel {

    private long secretInfo = ...

}
JPanel is Serializable. However, MyPanel should not be Serializable ever, because it contains sensitive ...

5. Serializable object inheritance    coderanch.com

6. Serializable in inheritance    coderanch.com

Originally posted by William Brogden ------------------------------------------ My guess is that your derived class should have a writeObject method that throws NotSerializableException. Probably the same for readObject. ------------------------------------------ Well, I think thats about the only way with the caveat that your subclass should implement Externalizable in which case the writeObject and readObject would be called on your implementation (in the ...

7. is Serialization Inherited    coderanch.com

hi, If the super class implements serialiable interface, its a best practice to declare in the subclass that it also implements the same interface. This way if some one just reads the subclass he will have the complete picture. This is more of a best practice, not a compulsion. Best regards Ayub.

8. How Inheritance Affects Serialization    coderanch.com

Am preparing for SCJP 1.5 exam. I have a doubt Serialization chapter, In that you can find How Inheritance Affects Serialization Just see the following code and i will ask my doubt at the end. import java.io.*; class SuperNotSerial { public static void main(String [] args) { Dog d = new Dog(35, "Fido"); System.out.println("before: " + d.name + " "+ d.weight); ...

9. Serialization with inheritance    coderanch.com

Originally posted by Lucky J Verma: ...all the books ,say if object of B is using some of variables of A,to restore A's state correctly while deserialzation of B's object,A must have a no-arg constructor ,other wise Deserialzation fails ,Runtime error comes . but i tried no ,error comes,B's object after deserialization showing As var values correctly... In your example, A ...





10. Serializable and Inheritance - How many objects?    coderanch.com

I've been studying for the SCJP exam recently and I came across the following question: Given: 10. class Car implements Serializable { } 11. 12. class Ford extends Car { } If you attempt to serialize an instance of Ford, what is the result? a. Compilation fails. b. One object is serialized. c. Two objects are serialized. d. An exception is ...

11. Serialization via Inheritance    coderanch.com