Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Programmer Certification (OCPJP)
I Can't access superclass's method
Sun LiWei
Ranch Hand
Posts: 49
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
class D { String type="class D"; void amethod() { System.out.println("D method"); } }; class A extends D{ String type = "classA"; void amethod() { System.out.println("A method"); } } class B extends A{ String type = "classB"; void amethod() { System.out.println("B method"); } class C //NonStatic inner class { String type = "classC"; C(){ System.out.println(this.type); System.out.println(B.this.type); System.out.println(B.super.type);//3 //(D)B.this.amethod();//3 B.super.amethod(); } } }
how can I access D.amethod() inside C() constructor
[ September 23, 2002: Message edited by: Sun LiWei ]
Barkat Mardhani
Ranch Hand
Posts: 787
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
You can not. See exactly some question asked before...
Sun LiWei
Ranch Hand
Posts: 49
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I can't find the same questions asked before
Shishio San
Ranch Hand
Posts: 223
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,
The only way to do that is to create a method XXX in class A that calls amethod in D and then you can call that method XXX from within the C constructor.
Whatever doesn't kill us ...<br />Is probably circling back for another try.<br />SCJP 1.4
Shishio San
Ranch Hand
Posts: 223
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I think Barkat meant the following post:
https://coderanch.com/t/239367/java-programmer-SCJP/certification/super-super
Whatever doesn't kill us ...<br />Is probably circling back for another try.<br />SCJP 1.4
Sun LiWei
Ranch Hand
Posts: 49
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thanks guys
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Inheritance/Polymorphism question
Get the hidding overridden method...
Inner class
Thanks everyone.
More...