DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Beginner Question: Class Capabilities

  1. #1
    Join Date
    Feb 2007

    Beginner Question: Class Capabilities

    Hello All,
    I missed a few lectures in class and I got very behind. My assignment is to:
    Create a base class named "Rectangle" that contains length and width data members. From this class, derive a class named "Box" having an additional data memner named "depth". The method members of the base "Rectangle" class should consist of a constructor and an override method named "area()" method. The derived "Box" class should have a constructor and an override method named "area()" that retuns the surface area od the box and a "volume()" method.

    Include in the classes constructed for the previous exercise in a working Java program. Have yoru program call all of the member methods in each class and explain the result when the area method is called using the two "box" objects.
    Can someone guide me in the right direction? Can you show me how to set up the first part? I am very thankful for any help I get.


  2. #2
    Join Date
    Dec 2004
    San Bernardino County, California
    Parent class is Rectangle, fields length and width, method area. Child class is Box with fields length and width (inherited from parent) and depth, methods area (inherited but overridden) and volume. Your Box class will have to construct its Rectangle-ness before itself. I trust you know how to calculate areas and volume.

    Is this a "Shape" hierarchy? Are these derived from "Shape"? if so, you'll need to initialize their "Shapeness", too.

Similar Threads

  1. Assembly class
    By Shailesh C.Rathod in forum .NET
    Replies: 2
    Last Post: 03-13-2002, 08:53 PM
  2. How To Do It - Shared Class Variables Part III
    By Patrick Ireland in forum .NET
    Replies: 5
    Last Post: 05-10-2001, 06:19 PM
  3. How To Do It - Shared Class Variables Part IV
    By Patrick Ireland in forum .NET
    Replies: 3
    Last Post: 05-07-2001, 03:04 PM
  4. Simple Class Variables question
    By Gary McCallum in forum Java
    Replies: 2
    Last Post: 10-20-2000, 11:20 AM
  5. Abstract class
    By Manika in forum Java
    Replies: 1
    Last Post: 09-06-2000, 01:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center