Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

difference b/w interface & abstract

 
Balu Ramachandran
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
please explain me the difference between interface and abstract
also explain complete defination for interface.
with regards,
R.Balu
Bangalore
 
Jane Griscti
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Balu,
An interface can declare constants and methods with no implementation code. Any class implementing an interface must provide code for each method defined in the interface.
An abstract class can declare everything a regular class can as well as methods with no implementation code.
For a more complete description of how an interface works see this post
Hope that helps.

------------------
Jane
 
Balu Ramachandran
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Jane Griscti,

thanks to ur reply.it's realy helpful to me
with regards,
R.Balu
Bangalore.
india.
 
Ira Jain
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have created a list of differences between interfaces and abstract classes.It is :
Difference between abstract class and interface-----
Abstract Class Interface
----------------- -------------
-must not be instantiated -must not be instantiated
-may contain static and final data -variables are implicitly
static and final.The
modifiers which can be
used are public and final
-abstract class can have non-abstract -methods are implicitly
methods but, abstract method should be implemented in the
be inside an abstract class. subclass which
implements it.no method
implementation strictly
in the interface.
-abstract method should not contain -methods in interface
any of these keywords - private, should not contain any of final,static, native, synchronized. these - protected,private,
final, static,native,
synchronized .
-methods are not implicitly public -methods are implicitly
public even if not
specified
-is an incomplete class -specification or
prescription for behavior
-can extend only one parent class -can implement several
interfaces atonce
-can have constructors -interfaces can't
(should contain body) have constructors
-methods in it are given as- -methods in it are given as-
public void amethod(){} public void amethod();
Hope it helps u
Ira
 
Ira Jain
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like the list of differences did not come out Ok .So if you would still like to have it ,I'll email it to you at your mail id.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic