
- Forum
- Programming Talk
- Java
- Why do we use interfaces in java?
Why do we use interfaces in java?
This is a discussion on Why do we use interfaces in java? within the Java forums, part of the Programming Talk category; Interfaces define only declaration of methods and final data members.We use them when we want different definitions of methods in ...
-
10-24-2011, 06:47 AM #1
- Join Date
- Oct 2011
- Answers
- 10
Why do we use interfaces in java?
Interfaces define only declaration of methods and final data members.We use them when we want different definitions of methods in different classes for different purposes.
To implement multiple inheritance in Java we must use interfaces in which one class can implement one or more than one interfaces.
-
02-04-2012, 04:41 AM #2
- Join Date
- Jan 2012
- Answers
- 8
Using interfaces allows you to substitute multiple implementations that conform to the interface (think plugins) while using a specific class hard-codes you to the class or its descendants. Interfaces also allow you to mimic multiple inheritance since classes can implement more than one interface but can only extend a single base class.
.........................................................................................................
Last edited by admin; 02-04-2012 at 11:21 AM.

Reply With Quote





