where is SunGraphics2D in the Java API doc?
Nowhere
Any sun.* and com.sun.* methods are not part of the Java API, and thus not documented. But that's OK, because the only methods of that object your code should be using are the ones defined in Graphics. A different JVM may use a different class (e.g. I think that the Linux or IBM JVMs don't have classes that are in the sun.* hierarchy).
How did the compiler know which class to use when I told it to use the Graphics class in the awt package?
The compiler didn't know (and doesn't need to know - it only cares about which methods Graphics has). The important thing is that the JVM knows how to create objects that extend Graphics, though.
This is similar to working with interfaces. Whenever a method uses an interface, the compiler doesn't know which class the object being used will have. It only knows that the object implements the interface, so the methods in that interface are accessible by the code that follows.
How would I have known that I can invoke the abstract method if reading the API doc tells me it is abstract?
It's implied by the fact that you're dealing with an object. While classes can have abstract methods, actual existing objects can't. So you know that whatever methods are defined -abstract or not- will be present and accessible.
[ August 11, 2007: Message edited by: Ulf Dittmer ]