This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
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

Interface and Abstract class

 
Abhishek Reddy
Ranch Hand
Posts: 259
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you explain me when to use the interface and when to use the Abstract Class?
 
bksella sella
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Abhishek,

You will use an Interface when you want the developer to implement his own method implementations, but to have the same method signature.

You will use an Abstract class when you have some common implementation for certain methods and let the developer implement his own logic for the other methods which are declared abstract.

I hope you understood. Let me know if this is clear.


- Sella
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a *very* frequently asked question. If you search this and the beginners forum, you should get tons of threads that discuss this topic.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic