wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes About interface and abstract classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "About interface and abstract classes" Watch "About interface and abstract classes" New topic
Author

About interface and abstract classes

Ja King
Greenhorn

Joined: May 15, 2009
Posts: 28
I know the definiton and how to use both interface and abstract....
but what is the use of both interface and abstract classes..
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10175
    
    8

I find both your statements contradictory.
Would you care to rephrase your question?


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Frank Kellinghusen
Greenhorn

Joined: Jul 10, 2009
Posts: 11
vijai ganesh wrote:I know the definiton and how to use both interface and abstract....
but what is the use of both interface and abstract classes..


When you create an interface, you're defining a contract for what a class can do, without saying how the class will do it. It is up the the developer implementing the interface, how the class runs internally.

When you define an abstract class, you still defining a contract, but you can implement the class partially. When you know that some methods will be the same for all subtypes, you can provide those in your abstract class.

And finally, classes can implement many interfaces, but only can extend one class.

Harshit Rastogi
Ranch Hand

Joined: Apr 15, 2008
Posts: 131
Check out the question 4,5 & 6 . I hope this would help
Abstract class and interface


<a href="http://technologiquepanorama.wordpress.com" target="_blank" rel="nofollow">My Techie Blog</a><br /><a href="http://www.java-questions.com" target="_blank" rel="nofollow">Java Questions</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: About interface and abstract classes
 
Similar Threads
use of abstact class and interface
Abstract classes instead of Interfaces
abstract class & interface
abstract interface
Difference between interfaces and abstract classes