geeta kasar wrote:I want example where we can use only overriding concept..without that code will fail. If anybody can guide me, it would be a greate help in clearing my understanding.
It's not generally a case of whether it fails or not; it's of programming that makes sense.
Personally, I've always liked the Shape example:
If you run it, you'll find that it prints out:
a Circle
a Square
a Triangle
a Square
which proves that the
overridden method is being run in each case. Polymorphism in action.
Tip: Although it's not required, it's worth using the "@Override" annotation when you write overridden methods. It helps the compiler to give you nice meaningful messages; especially if you change things later on.
HIH
Winston