July 7, 2008
at
Monday, July 07, 2008
Labels:
Computer Science,
Java,
Thinking in Java
Posted by
Billy
Chapter: Interfaces
Create an interface, and inherit two new interfaces from that interface. Multiply inherit a third interface from the second two.
In Java:
package chapter.interfaces;
interface AI {
void top();
}
interface BI extends AI {
void left();
}
interface CI extends AI {
void right();
}
interface DI extends CI, BI {
void bottom();
}
class EC implements DI {
public void top() {System.out.println("Top");}
public void left() {System.out.println("Left");}
public void right() {System.out.println("Right");}
public void bottom() {System.out.println("Bottom");}
}
public class Exercise13 {
public static void main(String[] args) {
EC e = new EC();
e.top();
e.left();
e.right();
e.bottom();
}
}
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment