This week's book giveaways are in the iOS and Features new in Java 8 forums. We're giving away four copies each of Barcodes with iOS: Bringing together the digital and physical worlds and Core Java for the Impatient and have the authors on-line! See this thread and this one for details.
} } since the subclass member overshadow the superclass members how does the super class member variable protected String billtype="small bill" is called out put is large bill:500.0 large bill:500.0 small bill:50.0 large bill small bill small bill no bill please explain
The "shadowing" that you are describing is only true for methods. This is because variables are created in memory at the time that they are declared. This is resolved at compile time. Then when you place a subclass in that holder (like putting TubeLight in a Light holder), the object is still actually an instance of the superclass and retain the superclasses variables. Methods however are invoked at runtime ("late-binding"). Since you have a TubeLight in a Light holder the methods of the subclass shadow the methods of the superclass. Of course if you REALLY want to understand this (and get a few smiles at the same time) you should read: http://www.javaranch.com/campfire/StoryPoly.jsp
"JavaRanch, where the deer and the Certified play" - David O'Meara