2 Replies Latest reply: Nov 23, 2010 1:23 AM by 796440 RSS

    Question related to inheritance

    796244
      class A implements Serializable
      {
      --------------------
      }
      class B extends A
      {
      --------------------
      }


      In this situation B will be serializable or not?
        • 1. Re: Question related to inheritance
          EJP
          A class inherits all the interfaces implemented by any of its base classes. This is basic Java.
          • 2. Re: Question related to inheritance
            796440
            It will have an "IS-A" relationship with Serializable. That is, anywhere a Serializable is expected, it will be syntactically legal to use a B. However, if you have non-transient, not-static, non-Serializable member variables in B (or in A for that matter), then serialization will fail at runtime, so in that sense, it is not serializable (with a lowercase "s", as you wrote it--that is, not able to be serialized).