The Artima Developer Community
Sponsored Link

Java Answers Forum
java

2 replies on 1 page. Most recent reply: Jan 15, 2009 9:35 AM by zet ucu

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 2 replies on 1 page
n veerendra

Posts: 4
Nickname: veerendran
Registered: Jun, 2008

java Posted: Jun 23, 2008 10:34 AM
Reply to this message Reply
Advertisement
MAJOR DIFFERENCE BETWEEN ABSTRACT CLASS AND INTERFACE


Matthias Neumair

Posts: 660
Nickname: neumi
Registered: Sep, 2003

Re: java Posted: Jun 26, 2008 1:31 AM
Reply to this message Reply
Interface: Defines a few criteria a class must have.
It's possible to implement multiple interfaces in one class


Abstract class: A class which has not all of it's methods implemented, but can contain completed methods and variables.
A class extending a class must complete the missing parts.
Only one abstract class can be extended.



And please, please, please turn off Caps Lock when writing.

zet ucu

Posts: 4
Nickname: zett
Registered: Jan, 2009

Re: java Posted: Jan 15, 2009 9:35 AM
Reply to this message Reply
Differences are as follows:

* Interfaces provide a form of multiple inheritance. A class can extend only one other class.
* Interfaces are limited to public methods and constants with no implementation. Abstract classes can have a partial implementation, protected parts, static methods, etc.
* A Class may implement several interfaces. But in case of abstract class, a class may extend only one abstract class.
* Interfaces are slow as it requires extra indirection to to find corresponding method in in the actual class. Abstract classes are fast.

Similarities:

* Neither Abstract classes or Interface can be instantiated.

Flat View: This topic has 2 replies on 1 page
Topic: Running batch file by passing parameters Previous Topic   Next Topic Topic: JSP

Sponsored Links



Google
  Web Artima.com   

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