If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Hybrid View

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!

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.