Student level question, I hope stackOverflow can help me get a deeper understanding here:
I noticed that many of the methods (for example, in Graphics2D , for example) in the Java API have “abstract” modifiers. Why is this?
I'm just wrapping my head around inheritance and polymorphism right now, but as I understand it, an abstract class is intended to be used as a kind of “parent class” that is extended by subclasses, and this abstract classes themselves cannot be created.
I also understand that abstract methods are declared (but not implemented) in an abstract class and must presumably be implemented in a subclass in order for this subclass to be considered non-abstract (and therefore be real).
So, how can I import a class like Graphics2D, instantiate it, and use its abstract methods?
My instructor mentioned that methods are overwritten at runtime (?), But I don't understand how / why. Obviously, I missed something here, I would like to know more!
source
share