Am i doing encapsulation correctly?

I have tried a combination of abstract and encapsulation concepts. Can u guys please tell me whether there is any blunder in the following code. The code compiles very well. But i want to know my way of writing this java code.Please correct my code.... any better way of coding this..Expecting your suggestions..
public abstract class Shapes {
     public int length  = 0;
     public int breadth = 0;
public Shapes(){
     this.breadth = breadth;
     this.length = length;
public abstract int getLength();
public abstract int getBreadth();
public void calculateArea(int l,int b){
     System.out.println("Area  is "+(l*b));
public class Square extends Shapes{
     public Square(int length,int breadth){
          super.length = length;
          super.breadth = breadth;
     public int getBreadth(){
      return super.breadth;     
     public int getLength(){
          return super.length;
     public static void main(String args[]){
          Shapes a = new Square(23,37);
          a.calculateArea(a.getBreadth(),a.getLength());
}

Kannan_S wrote:
Can u please correct my code..so that maximum encapsulation is achieved.."Encapsulation" is sometimes referred to as "data-hiding", so any field that is declared public violates encapsulation (unless it's also final ); however, as prometheuzz pointed out, if you define eveything as private you'll have an unusable object. The trick is to provide only the access required to make something work. A few guidelines for you, until you know when you can open things up a bit more (I'll probably get shot down here, but here goes...):
1. Make all your instance fields private .
2. Provide a public constructor or factory method to allow clients to create objects (factory methods are sometimes better).
3. Provide public or protected "getter" methods for any field that needs to be read outside the class.
4. Provide public or protected "setter" methods for any field that needs to be updated outside the class.
    Note: before you make any of them public, make sure that it really does need to be updated outside the heirarchy.
5. Don't call any public methods from a constructor or factory method.
6. If a field only needs to be set once, at creation time, make it final.
7. Unless you know that a class is going to be subclassed, declare it final too. You can always change your mind later.
HIH

Similar Messages

  • Error "can not start the configuration in parallel does not correct"

    Hello everybody,
    I have Windows 7 SP1, and when I install Business Objects 4.1 Client, it is install correctly but when i execute the program, for example BO Rich Client, an error appear "can not start the configuration in parallel does not correct" Could you help me?
    Thanks in advance!

    Check this KB
                  1678498  - BI 4.0 Universe Designer Gives Side-by-Side configuration incorrect Error

  • Freight Charges does not correctly show Tax % / calaculate

    Hi
    When I try to add freight charges to an A/P invoice the tax group shows correctly (V1) but the Tax % shows 0.0 instead of 7.5 on every row/type of freight and therefore the Tax is not calculated automatically.
    Somebody an idea whats wrong?
    Thanks
    Franz

    Problem solved.
    As a difference to all the other modules, A/P Invoice does not have the current day as default posting date (maybe this a bug). Since the Tax calculation needs the posting date, it does not correctly show the Tax on the main form as well as on the freight dialog, it shows the correct code, but always with 0%.
    So, for correct tax calculation, always make sure the posting date is entered before.
    @SAP: Change the behavior with the default posting date, as it is in all other modules.
    Best regards,
    Franz

  • Story does not correctly export fdx file with scene numbers? Bug needs to be fixed.

    Story does not correctly export fdx file with scene numbers? Bug needs to be fixed.

    Okay, Even if i remove the scene numbers from Story and export the file to Final Draft 8. The format in incorrect. The "transitions" ex. CUT TO:  are not in the correct allignment. Also there are numbers on each of the dialogues
    Pretty much alot of the formatting is not the same. Spaces  that break dialouge and action which are there in Story, are not converted over to Final Draft.
    Please fix this as soon as possible.
    thanks,
    Rohit

  • I have typos in my podcast description. Updating the RSS does not correct this. How can I get iTunes to re-read my RSS???

    I have typos in my podcast description. Updating the RSS does not correct this. How can I get iTunes to re-read my RSS???

    Thanks for your help.
    Here are the RSS feeds:
    http://www.solidrockvista.com/Podcasts/Lite/rss.xml
    http://www.solidrockvista.com/Podcasts/Phat/rss.xml
    And here are the iTunes pages:
    http://itunes.apple.com/us/podcast/james-world-lite/id162059136
    http://itunes.apple.com/us/podcast/james-world-phat/id162296074
    Both Podcast Descriptions have typos.

  • Firefox is taking forever to open any website, the little spinning circle is driving me mad. Once it has opened my bookmarks and history haven't loaded. Once in ten attempts it does load correctly but this is happening less frequently...

    I'm running Windows 7x64 and Firefox 6.0.2 is taking forever to open any website, the little spinning circle is driving me mad. Once it has opened my bookmarks and history haven't loaded. Once in ten attempts it does load correctly but this is happening less frequently...

    Try the Firefox SafeMode to see how it works there. <br />
    ''A troubleshooting mode, which disables most Add-ons.'' <br />
    ''(If you're not using it, switch to the Default Theme.)''
    * You can open the Firefox 4/5/6/7 SafeMode by holding the '''Shft''' key when you use the Firefox desktop or Start menu shortcut.
    * Or use the Help menu item, click on '''Restart with Add-ons Disabled...''' while Firefox is running. <br />
    ''Don't select anything right now, just use "Continue in SafeMode."''
    ''To exit the Firefox Safe Mode, just close Firefox and wait a few seconds before using the Firefox shortcut (without the Shft key) to open it again.''
    If it is good in the Firefox SafeMode, your problem is probably caused by an extension, and you need to figure out which one. <br />
    http://support.mozilla.com/en-US/kb/troubleshooting+extensions+and+themes

  • ACL does not correctly order the permissions when they are updated

    Outlook Connector sjab32.dll 7.1.228.0 sjms32.dll 7.1.228.0 sjui32.dll 7.1.228.0 sjtp32.dll 7.1.228.0
    Problem: We have identifed an issue with editing calendar permissions using the Outlook Connector. Basically the calendar ACEs are evaluated on a first match basic. Outlook Connector does not correctly order the permissions when they are updated. A brief example is below. Editing permissions via UWC works fine and will in fact fix any out of order ACE entries.
    Basic calendar permission:
    1.aces=@@o^a^rsf^g;@@o^p^rw^g;@@o^c^wdeic^g;@^a^sf^g;@^c^^g;@^p^r^g^
    after adding user mab, Ace has now been re-ordered so that the everyone permissions are now before the owner permissions:
    2.aces=mab^p^r^g;mab^c^rwd^g;mab^a^rsf^g;@^c^rwd^d;@^c^^g;@^p^r^g;@^a^sf^g;@@o^c^wdeic^g;@@o^p^rw^g;@@o^a^rsf^g
    any suggestion as to why this re-ordering is happening when updated through OC and any supporting doucuments for ACL

    Hi,
    This issue is most likely related to bug #6471869 (Outlook Connector allows invites to users with restricted permissions). This has been fixed in the latest Outlook Connector 7.1_233 (aka 122018-09). I recommend logging a Sun support case to get a copy of this new release.
    Regards,
    Shane.

  • I cannot get the subtitles to work no matter how many times I set it up and I am doing it correctly, what is wrong?

    I cannot get the subtitles to work no matter how many times I set it up and I am doing it correctly, what is wrong?

    if the material don't state there is subtitles in your language it don't include it
    and if will only show subtitles if the language you choose in the atv settings so if you have it set to french
    and the material only have subtitles in English and not french they will not display

  • Does Aperture Correct Lens Distortion with Panasonic Raw Files?

    I have a Panasonic GF1. When shooting in JPEG I know that the camera adjust for barrel distortion on the saved image. However It does not for RAW images as far as I know.
    I am aware that Adobe reluctantly added the software correction to Adobe Camera Raw for Panasonic cameras that need this for their RAW files to look correct, even though technically the file is no longer RAW after this adjustment. The information needed to do these corrections is encoded in the RAW file. So! I am wondering if Aperture does this correction to imported RAW files now that it supports The GF1?
    Heres a more in depth look at the distortion issue: http://www.dpreview.com/reviews/PanasonicGF1/page19.asp

    As a DMC-G1 owner, I thought that RAW conversions were fully supported now. Turns out that my perception seems to have been only partly true.
    I fired up SilkyPix again (thought I'd seen that for the last time!) and checked what corrections it offers. In the 'Lens aberration controller', there are three controls: Shading (angle and amount), Distortion (distortion rate and centre) and Chromatic Aberration (R rate and B rate).
    Aperture only exposes controls for the [Chromatic Aberration|http://documentation.apple.com/en/aperture/usermanual/index.html#cha pter=17%26section=11|Working with the Chromatic Aberration Controls] (red/cyan and blue/yellow) - this can be applied globally or brushed in selectively.
    There doesn't appear to be any access to shading or distortion as there is in SiklyPix, though - at a quick glance and I could be wrong - Aperture's [Devignette|http://documentation.apple.com/en/aperture/usermanual/index.html#ch apter=17%26section=4|Working with the Devignette Controls] tool appears to provide a similar function to the description of the Shading tool in SiklyPix.
    If there's distortion correction automatically going on behind the scenes - you did mention the embedded correction information in the RAW file - then it's not obvious. There's certainly no user control that I have seen.
    Hope this helps...
    Regards,
    Gary

  • Tagging my Photo - Am I doing it correctly?

    I have 400 plus photos in my organized files.  With my Adobe Photoshop Element 9  here is the steps I had taken:
           1.  On the "File" above the screen, I scrolled down to "Write keyboard TAG and Properties Info to Photos.
           2.  After clicking the above, a small screen poped up with the words:  All Displayed items chosen.    Are you sure you want to write the catalog data fro all of the currently displayed photos to their files.  Yes   No.
                Am I doing correctly?  If so, than I do click "Yes."
         If I am doing it correctly by having all my photos properly tagged, how do I make folder files or photo albums?

    You wouldn't assign the tag "people" to a photo, you would first create a tag with the person's name "George", and assign that to the appropriate photos.
    http://help.adobe.com/en_US/elementsorganizer/using/WSae2ea3b149d0c3591ae939f103860b3d59-7 e8f_WIN.html
    and
    http://help.adobe.com/en_US/elementsorganizer/using/WSae2ea3b149d0c3591ae939f103860b3d59-7 e8e_WIN.html
    and
    http://help.adobe.com/en_US/elementsorganizer/using/WSae2ea3b149d0c3591ae939f103860b3d59-7 e8d_WIN.html

  • Iphone 5 C freezes reboot does not correct issue

    iphone 5C freezes, reboot does not correct or solve issue

    Hi bogside2,
    Thanks for the question. Based on what you stated, it seems like the iPhone is not responding. I would recommend that you read this article, it may be able to help you isolate or resolve the issue.
    iOS: Not responding or does not turn on - Apple Support
    Thanks for using Apple Support Communities.
    Cheers,
    Mario

  • Lr 5.6 error message that reading preview cache failed and will correct when reopened; does not correct on reopening; removing preview.lrdata files allows LR to open but photos not shown; what action should I take next?

    Lr 5.6 error message that reading preview cache failed and will correct when reopened; does not correct on reopening; removing preview.lrdata files allows LR to open but photos not shown; what action should I take next?

    Yikesyou have helped me before and I thank you for that.  Funny how at the last resort I ask a question and then an hour later I fix something that has been broken for five days.  I got off on the wrong foot with Lightroom installation and I really stepped in it...a lot had to do with a bad hard drive and all that.  I still have remnants of catalogues etc so I am never quite sure where I am.  I ran a search and found more than one .lrdata files.  I finally got the right one to delete and I think I am okI'll be crying to you again if I am wrongall best, thanks again for your helpjim sterne

  • Premiere CS4 Does Not Correctly Export Quicktime

    Hello,
    When CS4 initially came out, all of the Quicktime exports were messed up. Now after several patches it still seems that it is not completely correct. I have rendered out of a 3d app sequential images with a white background and an alpha channel. When I import these into Premiere, when the alpha channel is disabled for the clip, it correctly shows a white background in the monitor. But when I export this clip to Quicktime Animation and turn on 32 bit depth, it creates the clip with an alpha channel, but when the alpha channel is disabled on the clip, it renders the background still as black, but with no alpha. It should render it as white. Quicktime Animation clips created this way with other Quicktime exporting software does not do this, and so I believe this is a bug. Where can this be logged?
    thx

    It's not a problem with Quicktime, but rather Premiere CS4 because other apps can create the same thing correctly, using the Quicktime Animation codec.
    thx

  • 802.1x with ACS does not correctly work

    Hello
    I have here a WLan setup with a WDS, some 40 Accesspoints, an ACS 4.1 server and a Windows Domain Controller which has the users configured.
    I have a group mapping in ACS configured which points to a small group in the ADS.
    The groupmapping in ACS points to a specific group in ACS.
    There I've configured the following:
    [009\001] cisco-av-pair
    - ssid=xx-200 (the name of the SSID the clients connect)
    [006] Service-Type
    - Login
    [007] Framed-Protocol
    - PPP
    [025] Class
    - OU=pers; (this is not the special group where those users are in, but they are also in this one)
    [064] Tunnel-Type
    - Tag 1 Value Vlan
    [065] Tunnel-Medium-Type
    - Tag 1 Value 802
    [081] Tunnel-Private-Group-ID
    - Tag 1 Value 200 (the Vlan in which they should go)
    The good thing is, authentication with username password works.
    The bad thing is, every user can authenticate and get into this SSID instead of only the users in the special group which points to this groupmapping.
    The other ADS groups also point to other ACS groups, but they don't have the above values ([009\001] cisco-av-pair, [064] Tunnel-Type, [065] Tunnel-Medium-Type, [081] Tunnel-Private-Group-ID) configured.
    The logfile from the ACS also shows that the wrong users are mapped into the correct group like they should, but they still get access.
    Here the WDS configuration:
    aaa group server radius RADIUS_GROUP_WDS_RADIOMANAGEMENT
    server 10.1.1.30 auth-port 1645 acct-port 1646
    server 10.1.2.30 auth-port 1645 acct-port 1646
    aaa authentication login METHOD_WDS_RADIOMANAGEMENT group RADIUS_GROUP_WDS_RADIOMANAGEMENT
    aaa authentication enable default enable
    aaa session-id common
    radius-server host 10.1.1.30 auth-port 1645 acct-port 1646 key 7 xxxx
    radius-server host 10.1.2.30 auth-port 1645 acct-port 1646 key 7 xxxx
    radius-server retransmit 2
    radius-server timeout 18
    radius-server deadtime 1
    radius-server vsa send accounting
    wlccp authentication-server infrastructure METHOD_WDS_RADIOMANAGEMENT
    wlccp authentication-server client any METHOD_WDS_RADIOMANAGEMENT
    ssid xx-200
    The accesspoint config:
    aaa authentication login METHOD_RAD_WDS_CLIENT group radius
    aaa authentication enable default enable
    aaa session-id common
    dot11 ssid xx-200
    vlan 200
    authentication open eap METHOD_RAD_WDS_CLIENT
    authentication network-eap METHOD_RAD_WDS_CLIENT
    authentication key-management wpa
    interface Dot11Radio0
    encryption vlan 200 mode ciphers aes-ccm
    broadcast-key vlan 200 change 60
    ssid xx-200
    interface Dot11Radio0.200
    description
    encapsulation dot1Q 200
    no ip route-cache
    no cdp enable
    bridge-group 200
    bridge-group 200 subscriber-loop-control
    bridge-group 200 block-unknown-source
    no bridge-group 200 source-learning
    no bridge-group 200 unicast-flooding
    bridge-group 200 spanning-disabled
    interface FastEthernet0.200
    description
    encapsulation dot1Q 200
    no ip route-cache
    bridge-group 200
    no bridge-group 200 source-learning
    bridge-group 200 spanning-disabled
    I hope you can find why any user can authenticate and not just the ones in the groupmapping which has the radius attributes configured.
    Thanks,
    pato

    I have finally found something to look into :/
    000619: Jan 18 16:50:11 A: RADIUS: AAA Unsupported Attr: ssid [263] 6
    000620: Jan 18 16:50:11 A: RADIUS: 48 53 52 2D [xxx-]
    000621: Jan 18 16:50:11 A: RADIUS: AAA Unsupported Attr: interface [156] 4
    000622: Jan 18 16:50:11 A: RADIUS: 32 35 [25]
    This is with various debugging active on the WDS. And this might be the reason why it doesn't work.

  • I have an index page that does not correctly load css, but css works on all other pages in the site.

    http://www.boulderridgecondos.com/ does not load the css correctly, but ALL other pages in the site do load the css correctly. There is nothing different (that I can identify) between the pages.
    http://www.boulderridgecondos.com/news.htm
    I am guessing that there is something wrong in the css, I inherited this site and have gone over the css but can't find a issue that would cause this to occur.
    Any help or suggestions to research something would be appreciated.

    That page is saved as UTF-16 (Content-Type: text/html (BOM UTF-16, litte-endian)) in your text editor. The CSS file is send as ISO-8859-1. Firefox likes to see all files in the same encoding. The other pages are send as ISO-8859-1 and thus use that CSS file. You will have to re-save that page as ISO-8859-1 and upload that corrected version.

Maybe you are looking for