• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Inheritance help

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am learning about inheritance and for the most part I understand all the concepts along with polymorphisms. What I don't understand is how these ideas fall into building a real world application. If someone could, please point me to some code examples that embrace inheritance and polymorphisms. I would like to see how they work in a large application/program. Don't point me to a general Dog extends Animal example, I get the concept. I guess I'm just trying to bridge everything together.

Thanks, Jim
 
author and iconoclast
Posts: 24204
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jim,

Welcome to JavaRanch!

Well, one example is probably right under your nose: Java's Swing and AWT APIs. Everything you can see on the screen is a Component. Some Components are Containers (JPanel, JFrame) because they can contain other Components. Other Components represent "widgets" like JButton, JComboBox, JTree, JList... Every one of these objects is very different from the others, but they all have identical methods to set the size, color, font... all inherited from Component. Obviously each Component has to react differently to be told to resize itself (for example). But to tell a Component to resize itself, you can just call setSize(), not matter what subclass of Component it is.
 
Jim Bain
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ernest,

Thanks for the reply, looking over the awt/sing api has been very helpful!

Jim
 
There are 10 kinds of people in this world. Those that understand binary get this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic