This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
1) Class A is the Super class and B extends from A 2) Class C extends B 3) The method display has been over-ridden in all the classes. 4) From the method in class C, I wish to call that of B & A. 5) I am able to call that of B using super.
Question: Is there a way to call A's display from C's display directly???
Originally posted by sivakumar k r: I didn't want to call display by simply create an object of A and calling the method from that newly created object within C.
Unfortunately, the answer is still "no".
Think of it like this. You are the designer of class C, which inherits from B. Your class overrides B, and implements new functionality. But one of the reasons why you override certain methods is that some of the methods of B, are no longer valid, for your C class -- you need those objects overriden, or your class will not function correctly.
Now... do you really want some other developer to create a D class which subclasses your C class, and bypasses the method calls that you overriden?
Henry [ February 08, 2007: Message edited by: Henry Wong ]
The whole desire to call a "super's super method" is an indication that you should rethink your design. There probably is an abstraction missing or something that would obliterate that need.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus