I've been ask开发者_JAVA百科ed a question. It is the following:
The API documentation of an abstract class tells you whether a method is abstract. When and why would you need to know this?
Any help would be appreciated.
You need to know what methods are abstract because you will need to provide implementations for those methods when inheriting the class.
As an extension to Fredrik's answer, it also specifies which behaviour is intended to be changed.
You can usually override a method (if the method is not final and the class is not final) but in practice that can be very tricky if the class is not specifically designed for changes. It may be that existing methods assume some kind of behaviour of the method you override, which is not specified (it happens) and that you do not provide.
By explicitly declaring a method to be abstract you express the intention that the method will be implemented by someone else. It also usually means that the documentation of an abstract method is a bit more complete with regards to expected behaviour.
If you call the abstract method you need to take into account that the actual implementation is elsewhere and may have some variation in behavior.
you have know if the method is abstract, because in that case you have to implement it in your concrete (inherited) class.
I advice you to take a look on the following books about Design Patterns, because they mention these stuff and have practices too:
http://oreilly.com/catalog/9780596007126
精彩评论