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

what is the difference between

 
Nikos kat
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the difference between an abstract class and an interface?
 
Craig Tyler
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interfaces let you get by the multiple inheritance problem by forcing you to implement all of its methods in a class that implements it. Abstract classes can have defined methods and fields that aren't necessarily public, static, and final.
 
Nikos kat
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for your help
 
badri nath
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nikos
Abstract class can have abstract methods as well as concrete methods whereas an interface will have only abstract methods.In one way we can call an interface as a pure abstract class.
We can create constructors for abstract classes whereas that is not possible for an interface.
 
mert ´┐Żzkaya
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,
Can we create an instance of any bastract class??

Thanks,

Mert
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope, it's pretty much the definition of "abstract class" that you can't instantiate one. Somebody has to extend it into a concrete class that you can instantiate. Often an abstract class is "incomplete" ... you see this in methods marked "abstract" that somebody must implement to make a concrete class.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic