Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>does the tree object use the methods within the Oak or Pine object?</p> </blockquote> <p>Yes. For instance, if <code>getbranch</code> is overridden in <code>Oak</code> or <code>Pine</code>, the version on the object being iterated, not the <code>wood</code> version, is called. So when you're looking at an <code>Oak</code>, <code>Oak</code>'s version is called; when you're looking at a <code>Pine</code>, <code>Pine</code>'s version is called. This is called <a href="http://en.wikipedia.org/wiki/Dynamic_binding_%28computing%29" rel="nofollow"><em>dynamic binding</em></a>, and it's the only kind of binding Java has. (Some languages, like C++, have both dynamic and static binding depending on how you declare the method; in Java, the closest you can come is the <code>final</code> keyword, which prevents you from overriding the method at all [and therefore would allow static binding in a compiler where that was relevant, such as the optimizations that the HotSpot Just-In-Time compiler can do].)</p> <hr> <p>Side notes:</p> <ol> <li><p>The overwhelming convention in Java is that class names are capitalized. Even more important is consistency. So if you have <code>Oak</code> and <code>Pine</code> classes, their base class should be <code>Wood</code>, not <code>wood</code>.</p></li> <li><p>Similarly, camelCase is used for methods (so, <code>getBranch</code>, not <code>getbranch</code>).</p></li> </ol> <p>Again, this is convention, which you can choose to ignore, but when communicating with others (for instance, here on SO!), following convention is useful.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload