Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

dws,

This is exactly as I had it explained to me by those nice people at Sun when I did a Java course, what hardburn is describing sounds like an interface, as you say.

  • Abstract classes may or may not contain implementation for each of their methods and they may not be instantiated. There is no coercion of methods which the subclass must contain as any which are not implemented are inherited.

  • Interfaces are merely contracts which list the methods which an implementing class MUST have. They may not be instantiated either, but then again they aren't really classes and have no implementation so this should not be surprising

The utility of these two when used together correctly is that an Abstract Class provides common behaviours which subclasses will inherit, whereas an Interface merely defines methods which any extending class must implement. In the first case neanderthals and humans both have the same drink() method inherited from the hominids abstract class, which they extend. In the second case, both humans and fish MUST be able to breathe as they both implement the breathers interface but the actual mechanisms used are different.

Elgon

If this node offends you, re-read it and reconsider. Think for a bit. I am almost certainly not trying to offend you, although I am frequently irreverent or flippant. Rememer - Please never take anything I do or say seriously.


In reply to Re: Re: Abstract Classes by Elgon
in thread Abstract Classes by hardburn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2024-03-28 23:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found