1 |
A class can only have one parent class but can implement several interfaces
|
2 |
interfaces are essentially abstract classes and can have methods without impementation and static variables
|
3 |
interface Printable {
-
void print();
-
void print(String str);
|
4 |
}
|
5 |
class Cookie implements Printable {
-
void print() {
-
System.out.println("Cookie");
-
}
|
6 |
}
|
7 |
class WastePaper implements Printable {
-
void print(String str) {
-
int i,len=str.length();
-
for(i=0; i < len; i++) {
-
singlechar = str.charAt(i);
-
System.out.println("This is character No." + i + " " + singlechar);
-
}
-
}
|
8 |
}
|