Results 1 to 4 of 4
  1. #1
    hei1233212000 is offline Member
    Join Date
    Jul 2010
    Posts
    36
    Rep Power
    0

    Default Question about inheritance

    Hi,

    Please look at the following codes
    Java Code:
    public abstract class A implements Serializable
    {
           // method
    }
    
    public class B extends A
    {
           // method
    }
    Will the class B inherits the Interface "Serializable"?

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,785
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by hei1233212000 View Post
    Will the class B inherits the Interface "Serializable"?
    Yes, inheritance obeys the 'is a' rule: a subclass is a superclass. Your superclass is a Serializable so your subclass is a Serializable.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    hei1233212000 is offline Member
    Join Date
    Jul 2010
    Posts
    36
    Rep Power
    0

    Default

    Quote Originally Posted by JosAH View Post
    Yes, inheritance obeys the 'is a' rule: a subclass is a superclass. Your superclass is a Serializable so your subclass is a Serializable.

    kind regards,

    Jos
    Thank you.:)

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default

    You really should read the API before asking a question. In the case of Serializable, it's specifically documented.
    All subtypes of a serializable class are themselves serializable.
    Serializable (Java Platform SE 6)

    db

Similar Threads

  1. Class inheritance question (code provided)
    By Adomini in forum New To Java
    Replies: 8
    Last Post: 10-09-2010, 06:30 AM
  2. Inheritance
    By gpio in forum Advanced Java
    Replies: 14
    Last Post: 11-20-2009, 11:41 AM
  3. Generics & Inheritance Question
    By Lee Rhodes in forum Advanced Java
    Replies: 3
    Last Post: 07-03-2009, 06:04 AM
  4. Inheritance example
    By kris4u4ever in forum New To Java
    Replies: 3
    Last Post: 03-21-2009, 03:53 PM
  5. a question about inheritance
    By litojs in forum New To Java
    Replies: 8
    Last Post: 11-10-2008, 11:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •