superclasses and access attribute


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: superclasses and access attribute

  1. #1
    Join Date
    Sep 2005
    Posts
    11

    superclasses and access attribute

    Hi,
    I have a couple of questions:

    What access attribute should static fields have? How about static final fields?

    Can you store a reference to a superclass object in a subclass reference variable? Do you know of an examples?


    Thanks a lot

  2. #2
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    What access attribute should static fields have? How about static final fields?
    That depends on wether you need to be able to change the value of the variable or
    if it is a fixed value. For final static values private access has no meaning, they can't
    be changed anyway. Static fields can be public, protected or private and you must
    use the access attribute that suits your application, i.e. what parts of your app needs
    to read/write the fields.
    Can you store a reference to a superclass object in a subclass reference variable? Do you know of an examples?
    If ClassB is an extension of ClassA, then of course ClassB can reference instances of
    ClassA. If you want ClassB to refefence its own superclass you do this by using:

    super.aSuperclassMethod();
    super.aValue=someValue;

    the super prefix is only required if you have overridden the method/field in the
    subclass.


    ...the question is rather strange though
    Last edited by sjalle; 10-09-2005 at 08:27 AM.
    eschew obfuscation

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
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

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