aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes When you extend a class with inner class ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "When you extend a class with inner class ?" Watch "When you extend a class with inner class ?" New topic
Author

When you extend a class with inner class ?

venkatesh rajmendram
Ranch Hand

Joined: Dec 05, 2000
Posts: 130
Hi,
When a class A extends the Class B, and Class B has
a) Class C as inner class - how does Class A access the methods of Class C ?
b) Class C as method local inner class - how does Class A access the methods of Class C...
Is it the same way as accessing the inner class.....I guess for situation b) it will not be able to access ....?
any knowledge is appreciated..
Thanks
Venkatesh


SCJP 1.4, SCWCD<p>Ours is a world where people don't know what they want and are willing to go through hell to get it.<br /> - Don Marquis
Sandhya Jayaram
Greenhorn

Joined: Dec 16, 2003
Posts: 16
hi,
found some replies in the sun website closely related to your topic.
------------------------------------------------
You need to be accessing a specific instance of the inner class if you are going to use a non-static member of it.
-------------------------------------------------
You cannot simply get an instance of an inner class. You only have the instance of the outer class to work with.
To solve this problem, you can do one of two things:
1) Move your inner class to a separate "outer" class (thus decoupling it from the outer class)
2) If you want to keep it as an inner class, add a "pass-through" method to the outer class which will place the call on the active instance of the inner class.
------------------------------------------------
Re: extending a nested class and parent access
> This is inconsistent with inheritance: you'd think
> that if you extend an inner class, you would inherit
> the abilities and characteristics of that inner class,
> just as you would in other cases of inheritance.
That's a rather facile way of looking at it. Here's another example that contradicts the above stmt: suppose there is a class A in package X that extends another class B in the same package X. Then class A can access any members of class B that are declared to permit package-friendly access. Now if you extend A by class A1 in package Y, then A1 does not have access to those members of class B.
Hope this helps. Hope i haven't confused you even more!!
-sandhya
venkatesh rajmendram
Ranch Hand

Joined: Dec 05, 2000
Posts: 130
I think it does not say in case of inheritance what happens to the inner class, will the behavior be inherited by the child class ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: When you extend a class with inner class ?
 
Similar Threads
answers to java.ditmas.net Mock Exam
Doubt on Inner class
anonymous inner class
Question about DesignPattern
Inner classes within inner classes