Interfaces 27aug
Interfaces 27aug
interface show{
void display();
dd = d;
mm = m;
yy = y;
System.out.println("Date = "+dd+'/'+mm+'/'+yy);
hour = h;
min = m;
sec = s;
System.out.println("Time = "+hour+':'+min+':'+sec);
Identity(String s){
name = s;
System.out.println("Name = "+name);
class ShowInterfaceDemo{
show ref;
ref.display();
ref.display();
ref.display();
}
Example 2
interface methods{
double PI = 3.14159;
double area();
length = l;
breadth = b;
return length*breadth;
rx = a;
ry = b;
return PI*rx*ry;
class MethodsInterfaceDemo{
methods ref;
}
Interface Example 3:
interface methods{
double area();
double x, y;
x = x1;
y = y1;
super(l, b);
void display(){
super(b, h);
return 0.5*x*y;
void display(){
rx = a;
ry = b;
return 3.14159*rx*ry;
class MethodsInterfaceDemo2{
public static void main(String args[]){
Polygon p;
methods ref;
p = r1;
ref = r1;
p.display();
p = t1;
ref = t1;
p.display();
ref = e1;