Exforsys

Online Training

Difference between Interface and Abstract Class

This is a discussion on Difference between Interface and Abstract Class within the Java forums, part of the Programming Talk category; What is exact difference between Interface And Abstract Class ? Where exactly these Interface are useful in realtime scenario....


Go Back   Exforsys > Programming Talk > Java

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-07-2007, 12:51 PM
Junior Member
 
Join Date: Oct 2007
Posts: 2
Aditya.ark is on a distinguished road
Difference between Interface and Abstract Class

What is exact difference between Interface And Abstract Class ? Where exactly these Interface are useful in realtime scenario.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 10-29-2007, 05:40 AM
Junior Member
 
Join Date: Sep 2007
Posts: 2
karthigayini is on a distinguished road
an abstract class is just a outline of the entire class. u can have only method name inside it. u can't create objects for them. a abstract class should always be inherited. where as a inteface is a collection or a group of empty methods.

Last edited by karthigayini; 10-29-2007 at 05:47 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 10-29-2007, 11:37 AM
Junior Member
 
Join Date: Oct 2007
Posts: 5
adarshshukla is on a distinguished road
An abstract class is a class which may or maynot consist of the abstract methods while an interface must have all the functions as abstract.

the abstract class with all the functions as abstract must be defined as an interface.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 11-02-2007, 02:39 AM
Junior Member
 
Join Date: Nov 2007
Posts: 8
vickyas400 is on a distinguished road
Abstract class vs interface

Abstract class can (or not ) have methods in it and it has no use in instantiating it since it has no meaning in instantiation.
It has to be inherited for use .
You need to INHERIT to use an abstract class.
You can have a variable in Abstract class. ( a silly difference )
Basically u use an abstract class when you want to provide a generalized form of abstraction and leave the implementation task with the inheriting subclass.

Interface - group of related methods with empty bodies .
You need to IMPLEMENT to use an interface.
I dont think you can have a variable in a interface.
When you want a few classes to use a few methods which you dont want to be included in the class ,then you go for the interface, which makes it easy to just implement and make use of the methods defined in the interface. But the problem with the interface is that, u have to implement all the methods defined in the interface , even if you dont need some of them.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 03-07-2008, 04:45 AM
Junior Member
 
Join Date: Mar 2008
Location: bangalore
Posts: 9
sampra is on a distinguished road
An abstract class is a class which may or maynot consist of the abstract methods while an interface must have all the functions as abstract.

the abstract class with all the functions as abstract must be defined as an interface.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 03-11-2008, 10:33 PM
Junior Member
 
Join Date: Nov 2007
Posts: 8
vickyas400 is on a distinguished road
Hello

Hello .,.. welcome ./.. .this group seems to be inactive for a long time !! !..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
Common Interface to I/O fernandez.dan@gmail.com Software Patterns 2 08-27-2005 10:19 PM
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit Tech FAQ 0 06-01-2004 07:00 AM
comp.lang.eiffel Frequently Asked Questions (FAQ) Franck Arnaud Tech FAQ 0 04-17-2004 08:27 AM
Smalltalk FAQ (v.1.0) Vikas Malik Tech FAQ 0 04-17-2004 08:27 AM
Factory design pattern Vs abstract factory design pattern Nimmi Srivastav Software Patterns 4 10-26-2003 11:06 AM


All times are GMT -4. The time now is 04:05 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2004 - 2007 Exforsys Inc. All rights reserved.