what is an Interface?
An interface in java is a blueprint of a class. It
has static constants and abstract methods only.
The
interface in java
is a mechanism to achieve fully abstraction. There can be only abstract
methods in the java interface not method body. It is used to achieve fully
abstraction and multiple inheritance in Java.
This way all common behaviour can be declare in interface and then multiple classes can implement those behaviour according to their nature or functionality class wants to achieve.
Java Interface also represents IS-A relationship.
It cannot be instantiated just like abstract class.
Why use Java interface?
There are mainly three reasons to use interface. They are given below.It is used to achieve fully abstraction.
By interface, we can support the functionality of multiple inheritance.
It can be used to achieve loose coupling.
When use Interface?
Interfaces are more flexible, because a class can implement
multiple interfaces. Since Java does not have multiple
inheritance, using abstract classes prevents your users from using any other
class hierarchy.
TCCI Computer Coaching Institute
provides coaching in Java Language in Bopal and Satellite, Ahmedabad.
Online coaching for Java is available at TCCI.
We never regret our students . Join us at TCCI, Ahmedabad .
Call us @ 9825618292
Visit us @ http://www.tccicomputercoaching.com
No comments:
Post a Comment