Interfaces


Interfaces allow the construction of nonhierarchical type frameworks.I have not clearly understood this statement, concept.
Please advise. Any ideas, sugestions, sample code, links, resources highly appreciated. thanks in advance
LVL 7
gudii9Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

 
for_yanCommented:
I once wrote a lot about interfaces in response to one of the EE questions, you may
read it here:
http://www.experts-exchange.com/Programming/Languages/Java/Q_26785479.html
0
 
for_yanCommented:
Interfaces allow the construction of nonhierarchical type frameworks -
this statement emphasizes that if inheritance in Java implies
strictly hierarchical structure because a class can inherit only
from one class, interfaces allow to attribute to a Java class
proprties of a wide range of types - a class can implement
as many interfaces as you like, which creates a network of connections between
types/classes which does not need to be hierarchical
0
 
dpearsonCommented:
A hierarchy is when class A extends B extends C.  A is derived from B which is derived from C.  It's a chain where each class has a single parent.  This means it's a hierarchy and is how Java does inheritance.

With interfaces, you're allowed to implement multiple interfaces at once.  So we can have:
class A implements I,J,K
class B implements I,J,K

both A and B implement the same classes, but they're not related to each other at all.  They don't have any of the same parent classes, so they're not part of a hierarchy.  It might look like they are derived from I,J,K - but they're implementing the interfaces, not deriving from classes.

Doug
0

Experts Exchange Solution brought to you by ConnectWise

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.