Java interface example :
In this class i implement Java shape interface in the circle class .as you will see in the following example ,up-casting for the object "circleshape" .
Note :
Interface classes , functions are public and abstract ,and fields are public and final
public class Main {
public static void main(String[] args) {
shape circleshape=new circle();
circleshape.Draw();
}
}
interface shape
{
public String baseclass="shape";
public void Draw();
}
class circle implements shape
{
public void Draw() {
System.out.println("Drawing Circle here");
}
}
No comments:
Post a Comment
Please Provide your feedback here