Geeks Talk

Prepare for your Next Interview




Diff B/W Interface & Abstract class

This is a discussion on Diff B/W Interface & Abstract class within the Java forums, part of the Software Development category; Hi frnds, Can any body solve my qustion, In Interface containing abstract methods right...... and Abstract class also containing abstract methods right.... so both are using abstract methods. Then why ...


Go Back   Geeks Talk > Software Development > Java

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 02-25-2008
Junior Member
 
Join Date: Feb 2008
Location: Pune
Posts: 11
Thanks: 5
Thanked 2 Times in 2 Posts
sforsree is on a distinguished road
Smile Diff B/W Interface & Abstract class

Hi frnds,

Can any body solve my qustion,

In Interface containing abstract methods right......
and
Abstract class also containing abstract methods right....

so both are using abstract methods.

Then why Interface or Abstract class ?????? what's the diff

Let me know at least 3 resons plz...



Thanks & Regards,

Sreekanth S.

Last edited by sforsree : 02-25-2008 at 03:45 AM.
Reply With Quote
The Following User Says Thank You to sforsree For This Useful Post:
Sponsored Links
  #2 (permalink)  
Old 05-20-2008
Junior Member
 
Join Date: Mar 2008
Location: trivendrum
Posts: 4
Thanks: 0
Thanked 3 Times in 3 Posts
gyanrathore3438 is on a distinguished road
Re: Diff B/W Interface & Abstract class

Diff B\w Interface And abstract Class:

1.Abstract class contains abstract method but interface did't contains abstact method

2.modifier for abstact class can be public and internal
for interface modifier can be public and abstacr

3.it's an incompleate class but interface is not a class it is treated as class
for abstact class keyword abstact is used but for inteface , keyword interface is used .

i think so it will be helpful for u .

thanks
G.S.Rathore
Reply With Quote
The Following User Says Thank You to gyanrathore3438 For This Useful Post:
  #3 (permalink)  
Old 05-20-2008
Junior Member
 
Join Date: Feb 2008
Location: Pune
Posts: 11
Thanks: 5
Thanked 2 Times in 2 Posts
sforsree is on a distinguished road
Re: Diff B/W Interface & Abstract class

Hi Rathore,

Thanks for your give advise. But I have one doubt,

when you says interface did't contains abstract method , but in Interface by default all methods are public abstract. Is it right or wrong.

plz solve this doubt.

Thanks & Regards,
Sreekanth S


Quote:
Originally Posted by gyanrathore3438 View Post
Diff B\w Interface And abstract Class:

1.Abstract class contains abstract method but interface did't contains abstact method

2.modifier for abstact class can be public and internal
for interface modifier can be public and abstacr

3.it's an incompleate class but interface is not a class it is treated as class
for abstact class keyword abstact is used but for inteface , keyword interface is used .

i think so it will be helpful for u .

thanks
G.S.Rathore
Reply With Quote
  #4 (permalink)  
Old 06-03-2008
Junior Member
 
Join Date: Jun 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Shafia is on a distinguished road
Re: Diff B/W Interface & Abstract class

you can define the body of abstract method in abstract class but u cannot define the body of method in interface.
Reply With Quote
  #5 (permalink)  
Old 06-03-2008
Junior Member
 
Join Date: Mar 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
MRamaLakshmi is on a distinguished road
Re: Diff B/W Interface & Abstract class

In abstract class there is no necessity that, all the methods should be abstract. there can be both abstract and concrete methods.

But in interface all the methods are abstract. No method should be concrete.
Reply With Quote
  #6 (permalink)  
Old 06-03-2008
Junior Member
 
Join Date: Jul 2007
Location: Gurgaon
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
vaneet is on a distinguished road
Re: Diff B/W Interface & Abstract class

Hi Sree,

Abstract class and interfaces are completely different.

1) In an abstract class, you may also have some concrete methods( fully implemented. It can have all its methods as concrete, yet be declared as abstract) , but in an interface, all the methods ought to be abstract.

2)Abstarct class can never be instantiated, but you can indirectly instantiate an interface by instantiating the class which implements it and then use the its methods.
Reply With Quote
  #7 (permalink)  
Old 06-05-2008
Junior Member
 
Join Date: May 2008
Location: chennai
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
sivaslm is on a distinguished road
Re: Diff B/W Interface & Abstract class

need study guide for weblogic?beginning learners
Reply With Quote
  #8 (permalink)  
Old 09-30-2008
Junior Member
 
Join Date: Sep 2008
Location: hyderabad
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
pavanguru423 is on a distinguished road
Re: Diff B/W Interface & Abstract class

Abstract classes are intended to be used base class. An abstract class cannot be instantiated.
A non-abstract class derived from an abstract class must include actual implementations of all inherited abstract methods and accessors.
Abstract and sealed (class cannot be inherited) modifier can’t work together.

An abstract class can have abstract members as well non-abstract members. But in an interface all the members are implicitly abstract and all the members of the interface must override to its derived class.

Abstract classes can have protected members, static members.
The members of the interface are public with no implementation

An interface can inherit from one or more base interfaces.
A class can inherit one or more interfaces, but only one abstract class.
Reply With Quote
Reply

  Geeks Talk > Software Development > Java


Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
Difference between interface and abstract class? are they both same mahesh9920 OOPS 17 1 Week Ago 02:44 AM
Real time example for abstract class and interface Geek_Guest Java 2 01-31-2008 01:50 PM
difference between abstract class and interface manipalreddy.s Java 12 10-25-2007 07:06 AM
Is there any benefit to extend both Interface and abstract class Geek_Guest Java 1 06-08-2007 01:54 PM
Confusion with ABSTRACT and INTERFACE Geek_Guest Java 2 05-07-2007 04:38 AM


All times are GMT -4. The time now is 06:29 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved