Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / December 2006

Tip: Looking for answers? Try searching our database.

interfaces

Thread view: 
Prejith - 29 Nov 2006 05:02 GMT
am new to java and i am in the learning phase of core java .i know that
Java doesnt support Multiple Inheritance instead the work around is to use
Interface

but the doubt i have is interface are nothing but empty abstract
methods.when ever i implement those methods in a class i have to write the
method body in the class.. .if interface is just emply methods  then what is
the point of having those empty method names under one tag..

i dont know whether my understanding about interface is correct.if not
please correct me and also if possible give me an explanation...

regards
Prejith
Thomas Schodt - 29 Nov 2006 07:28 GMT
> am new to java and i am in the learning phase of core java .i know that
> Java doesnt support Multiple Inheritance instead the work around is to use
> Interface

It is not a workaround,
the way Java implements inheritance / interfaces
has the side effect of
eliminating the classic multiple-inheritance issue.

> but the doubt i have is interface are nothing but empty abstract
> methods.when ever i implement those methods in a class i have to write the
> method body in the class.. .if interface is just emply methods  then what is
> the point of having those empty method names under one tag..

An interface is a promise to implement a method with a specific name and
 a specific signature.

The beauty when it comes to the classic multiple-inheritance issue is;
two different interfaces used for different purposes
could potentially have a name/signature conflict,
in which case sorting out the mess
is left as an exercise for the person implementing the class.

As Java only allows you to extend one class
there can never be two conflicting implementations.
visionset - 29 Nov 2006 22:54 GMT
> ...if interface is just emply methods  then what is
> the point of having those empty method names under one tag..

Declaration, not Tag

I'll give a high level answer, since that is probably best, whilst you read
around more extensively

An interface is a contract or specification, a promise if you like, to
fulfill the documented behaviour of the *Type*.  In an interface it is the
documentation that is the most important part, in the same way a
specification does nothing but says alot.  The idea is that armed with such
a specification it is then safe to write code that uses these interfaces and
be confident (one hopes) that any such implementation past, present or
future will behave correctly since the writer will have understood the
documentation and implemented the desired behaviour within their concrete
class.

Think how powerful the proliferation of independent governing bodies, the
likes of W3C etc and there far reaching specifications are.  Browsers are
written to conform to the spec and you don't need to bother with Firefox or
Opera [1] documentation, you just know they'll do the right thing.  Exactly
the same with interfaces.

[1] Oh did I leave out IE ?

Signature

Mike W

Lew - 02 Dec 2006 18:39 GMT
> am new to java and i am in the learning phase of core java .i know that
> Java doesnt support Multiple Inheritance instead the work around is to use
[quoted text clipped - 10 lines]
> regards
> Prejith

Deja vu!

Why is this in two separate threads separated by a day?

- Lew


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.