If I look at the method signatures in the Java API for the Graphics class I see the drawing methods like drawString( ) and drawRect( ) are declared as abtract void. The thought occurred to me. How can they be abstract? If they are abstract where does their functionality come from?
Hi Mark, They come from the native code implementation that is supplied with the java runtime for your hardware. So when a Graphics object is passed in to your paint method, for example, it is a concrete platform-specific subclass. Hope this clears it up, Michael Morris
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Note: Considering such a class heirarchy, the implementation of the methods could also be in some subclass of the parent abstract class - it doesn't have to be in machine specific code. You might want to take a look at The "How my Dog learned Polymorphism" Story of The JavaRanch Campfire Stories and The Managing Inheritance Section of Sun's Java Tutorial. If you ever want to find out what class an object actually is (not just the identifier's type)... All objects in Java inherit the getClass() method from java.lang.Object. Use toString() on the returned Class object and find out.You could similarly invoke the getName() method of the Class object. Good Luck.