Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: question on inheritance

  1. #1
    Junior Member
    Join Date
    Nov 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default question on inheritance

    Hello every one,
    I'm new to java ; The following is my doubt
    I have a base abstract class(this cannot be instantiated) which is inherited by 2 classes.
    they are asking to create an class which may contain the child classes.
    eg : name of the base class is postalobject. this is inherited by a class letter and another class parcel.
    therz is another class of length 4 may contain 2 lettres and 2 parcels or 1 lettre and 3 parcels ?
    is it possibel to do it ????????????
    Advance thanks


  2. #2
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: question on inheritance

    Quote Originally Posted by antoni View Post
    therz is another class of length 4
    Classes do not have a length. Please explain what you mean.
    Improving the world one idiot at a time!

  3. #3
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: question on inheritance

    A collection of PostalObjects, perhaps ArrayList<PostalObject>, could contain a combination of Letter and Parcel objects as long as they both extend PostalObject as you indicated they do.

  4. #4
    Junior Member
    Join Date
    Nov 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: question on inheritance

    Quote Originally Posted by Junky View Post
    Classes do not have a length. Please explain what you mean.
    the maximum capcity of an array of objects.
    eg
    BoiteALettres[] BoiteALettresListe= new BoiteALettres[4];

    BoiteALettresListe.length =4

  5. #5
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: question on inheritance

    What happened when you tried that code?
    Improving the world one idiot at a time!

Similar Threads

  1. [SOLVED] Java Inheritance Question...
    By tim8w in forum Object Oriented Programming
    Replies: 3
    Last Post: October 22nd, 2013, 09:35 PM
  2. Inheritance question!
    By Scorks in forum Object Oriented Programming
    Replies: 4
    Last Post: September 23rd, 2013, 12:56 PM
  3. Inheritance question
    By tcstcs in forum Java Theory & Questions
    Replies: 2
    Last Post: February 24th, 2012, 07:19 AM
  4. Inheritance
    By lewzax in forum Object Oriented Programming
    Replies: 4
    Last Post: July 8th, 2011, 01:51 PM
  5. inheritance
    By b109 in forum Java Theory & Questions
    Replies: 3
    Last Post: May 30th, 2010, 09:23 PM