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.
Ernest Friedman-Hill wrote:Making the class abstract doesn't force you to override a method, but making a method abstract does -- at least, if you're trying to create a non-abstract, instantiable class.
Correct, I made a mistake there!
Joined: Feb 01, 2007
Yes, That is true, Did you see any other situations for Forcibly overriding
what you could do, if you still want to instantiate that particular class, is set its accessibility to default, and extend two classes from it; A public final one, and a public abstract one that overrides the method you want overriden with an abstract method.
That way you ensure that no one outside the package can access your superclass, but it can Access the public final one that can't be subclassed, or it can access the public abstract one, which you can subclass, IF you override that method you want overriden.
But how does it makes difference in normal overriding functionality discussed above?
I dont find anything special, like child class must have to over ride.
It is again child class wish to over ride the method or declare abstract.
It's an interview question. Interview questions are designed to see how you handle problems, not to find out what your actual solutions are. The first response I would have made would be to ask what "forcibly" means.