Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Karina K patni   on Aug 04 In Java Category.

  
Question Answered By: Sheryl Morgan   on Aug 04

> without creating reference of the base class  using super, u cannot
call a
> method of the outer class from the derived  inner class.

I'd say, yes, you can indeed not call  a method of the outer class from
the derived inner class. The "creating reference of the base class
using super" makes no sense. I think more correct  is "creating a
reference to the base class". I don't think you'd be "using super" to
get a reference to the outer class. "A.this" gets the reference to
the outer class.

I'm only trying to be accurate here btw.

> the basic rule of inheritance is tht when we r extending a base
class, then
> derived class should contain this super  method to initiate the
constructor
> of the base class.

This makes no sense. You are saying that a derived class should
contain the super method to initiate the constructor of the base class.
It's not about the "initiating" or calling  of the constructor that is
an issue in the sample. The "a.super()" really is correct syntax, if
that's what you were wondering.
"contain the super method". I can't figure  out what you're trying to
say here. The derived class should contain the test  method? I really
want the test method to be in the base outer class.

The only thing that's coming out of this whole exercise is that
"You can not call a method of an outer class from a class that's
derived from the outer class' inner class".
That is, "unless you have a reference to the outer class available in
the derived inner class".
Or, "unless the outer class' base inner class can delegate the outer
class' method call", which is what I was doing in my sample version 2.

Aside from all this, sample version 2 looks pretty darn strange, but
is all correct syntax, and works. I just wish I didn't need that
proxy delegate.

Share: 

 

This Question has 18 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Inner class inherit question Or get search suggestion and latest updates.


Tagged: