Results 1 to 3 of 3
  1. #1
    Teesea is offline Member
    Join Date
    Aug 2011
    Posts
    1
    Rep Power
    0

    Default First post-Simple question help please

    The question is
    Consider the following class definition
    class rectangle{
    protected int w,h;
    rect(){w=1;h=1;}rect(int w1,int h1)){w=w1;h=h1;}
    public void getHeight(){return h;}
    public void getWidth(){retrun w;}
    public void displayArea(){System.out.println(w*h);}}

    a)Create a derived class called newRectangle having the following behaviours
    i)setHeight(int h) to set height to h;
    ii)and setWidth(int w) to set width to w;
    iii)displayArea to display the Area as given below
    Area=12 for newRectangle objects having height=3 and width=4

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    We don't do this for you here. Try something and tell us what you are having trouble with. Use code tags too, [code]...[/code]

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,184
    Rep Power
    19

    Default

    a)Create a derived class called newRectangle having the following behaviours
    i)setHeight(int h) to set height to h;
    ii)and setWidth(int w) to set width to w;
    iii)displayArea to display the Area as given below
    Area=12 for newRectangle objects having height=3 and width=4
    Done! What did I win?

Similar Threads

  1. Simple Question
    By stackptr89 in forum New To Java
    Replies: 13
    Last Post: 01-29-2011, 05:35 PM
  2. Read this SMALL post BEFORE you submit a question.
    By AcousticBruce in forum New To Java
    Replies: 11
    Last Post: 01-10-2011, 11:22 AM
  3. Replies: 3
    Last Post: 05-04-2009, 03:15 AM
  4. quick pre/post increment question
    By xtrmi in forum New To Java
    Replies: 4
    Last Post: 02-01-2009, 05:47 PM
  5. The first post and first question
    By m_kaleia in forum New To Java
    Replies: 8
    Last Post: 07-19-2008, 06:27 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
  •