This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Rajnish please Use Code Tags when you post a source code. That way your code looks formatted. Unformatted code is hard to read. You can add code tags by wrapping your code in [code] [/code] tags. You can edit your message using button and then add code tags to it.
I think you forgot to put inheritance in your code, none of your classes extend Alpha class...
I think it is as I expected that s is a static variable and can't be inherited by its subclasses .. Am I right ???
or any diffrent logic is involved here please clear my problem.. thanks..
If a superclass has an instance variable or static variable then every subclass has this variable.
Only trick in this question is that the SubSubAlpha extends only the Alpha (and doesn't extend the SubAlpha). When new SubSubAlpha is creating the SubSubAlpha constructor calls Alpha constructor which adds "alpha" to the s String, after that SubSubAlpha adds " subsub" to the s and in a next line of the program the s variable i shown as "alpha subsub"