interfaces are used as
It is used to achieve total abstraction.
Since java does not support multiple inheritance in case of class, but by using interface it can achieve multiple inheritance .
It is also used to achieve loose coupling.
interfaces are used as
It is used to achieve total abstraction.
Since java does not support multiple inheritance in case of class, but by using interface it can achieve multiple inheritance .
It is also used to achieve loose coupling.
interface in java
In many cases, it is more important to know what an object can do,instead of
how it does what it does. This is a reason why interfaces are commonly used for
declaring a type of variable.
interface : DrawingTool : a tool can draw
interface DrawingTool {
void draw(Curve curve);
}
DrawingTool pencil = new Pencil();
DrawingTool brush = new Brush();
Both Pencil and brush class should implement draw method
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us