• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Abstract classes in Graphics class

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic