The Artima Developer Community
Sponsored Link

Java Answers Forum
interfaces

4 replies on 1 page. Most recent reply: Apr 28, 2004 5:28 AM by Matthias Neumair

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 4 replies on 1 page
Nancy

Posts: 11
Nickname: ac121107
Registered: Feb, 2004

interfaces Posted: Apr 27, 2004 12:46 AM
Reply to this message Reply
Advertisement
how interfaces compare to abstract classes?
Nancy


Matthias Neumair

Posts: 660
Nickname: neumi
Registered: Sep, 2003

Re: interfaces Posted: Apr 27, 2004 1:38 AM
Reply to this message Reply
Here are the main differences:

A abstract class normally is a complete class wich requires some additional methods.

A Interface just makes sure the implementing class offers some methods.
A Interface has no methods

You can implement multiple Interfaces
(Using a abstract class you can extend only one class with all it's super classes)

A interface has no super class, so there is no restriction how and where to use it.

twc

Posts: 129
Nickname: twc
Registered: Feb, 2004

Re: interfaces Posted: Apr 27, 2004 7:03 AM
Reply to this message Reply
>A interface has no super class, so there is no restriction how and where to use it.

This isn't entirely correct. Some interfaces do have super/sub interfaces. For example, java.awt.ItemSelectable is a super-interface for javax.swing.ButtonModel. LayoutManager and LayoutManager2 are also related through inheritance (LayoutManager2 is the sub-interface).

However, MOST interfaces do not have super or sub interfaces.

Adam Duffy

Posts: 168
Nickname: adamduffy
Registered: Feb, 2003

Re: interfaces Posted: Apr 27, 2004 3:38 PM
Reply to this message Reply
For information on Object-Oriented Programming Concepts see
http://java.sun.com/docs/books/tutorial/java/concepts/index.html

For information on Classes and Inheritance
http://java.sun.com/docs/books/tutorial/java/javaOO/index.html

Finally, for Abstract Classes and Methods
http://java.sun.com/docs/books/tutorial/java/javaOO/abstract.html

No sense in redoing what has already been done (or reexplaining what has already been explained, as the case may be).

HTH,
Adam

Matthias Neumair

Posts: 660
Nickname: neumi
Registered: Sep, 2003

Re: interfaces Posted: Apr 28, 2004 5:28 AM
Reply to this message Reply
Ok, my choice of words was not the best.
I meant, it does not EXTEND a class, but it can IMPLEMENT other interfaces.

Flat View: This topic has 4 replies on 1 page
Topic: PB in db access, URGENT!!! Previous Topic   Next Topic Topic: Core java

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use