DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2

Hybrid View

  1. #1
    GR Guest

    Calling base class methods


    Hi,

    Ive worked more on C++ rather than JAVA but I keep visiting
    it now and then to see how certain features in C++ map to
    JAVA.
    A question that I wanted to ask was this:
    Is it possible, in JAVA, to call super class methods in a derived class when
    the derived class is several steps down in the hierarchy?
    In other words say class 1 is the base class. Class 2 is derived from class
    1. Class 3 is derived from class 2. Can class 3 somehow call class 1's methods?


    In C++ you'd do this by explicitly qualifying the method by prefixing it
    with the name of the base class i.e class 1 like
    this:
    ...
    1::method_name() ;

    Can this be accomplished in JAVA?
    From the top of my head, my guess is NO!

    Tell me if Im wrong?
    Thanks
    Gautam

  2. #2
    Paul Clapham Guest

    Re: Calling base class methods


    GR <gautamcr@hotmail.com> wrote in message news:3a098d6e$1@news.devx.com...
    >
    > Hi,
    >
    > Ive worked more on C++ rather than JAVA but I keep visiting
    > it now and then to see how certain features in C++ map to
    > JAVA.
    > A question that I wanted to ask was this:
    > Is it possible, in JAVA, to call super class methods in a derived class

    when
    > the derived class is several steps down in the hierarchy?
    > In other words say class 1 is the base class. Class 2 is derived from

    class
    > 1. Class 3 is derived from class 2. Can class 3 somehow call class 1's

    methods?
    >
    >
    > In C++ you'd do this by explicitly qualifying the method by prefixing it
    > with the name of the base class i.e class 1 like
    > this:
    > ..
    > 1::method_name() ;
    >
    > Can this be accomplished in JAVA?
    > From the top of my head, my guess is NO!
    >
    > Tell me if Im wrong?
    > Thanks
    > Gautam


    You are correct. Class 3 can call class 2's methods by using
    super.method_name() but that's as far as it goes.

    PC2





Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links