-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAnimalInterface.java
41 lines (33 loc) · 941 Bytes
/
AnimalInterface.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
interface Animal1 {
public void animalSound(); // interface method (does not have a body)
public void sleep(); // interface method (does not have a body)
}
interface FirstInterface {
public void myMethod(); // interface method
}
interface SecondInterface {
public void myOtherMethod(); // interface method
}
class Pig implements Animal1, FirstInterface, SecondInterface {
public void animalSound() {
System.out.println("The pig says: wee wee");
}
public void sleep() {
System.out.println("Zzz");
}
public void myMethod() {
System.out.println("Some text..");
}
public void myOtherMethod() {
System.out.println("Some other text...");
}
}
class AnimalInterface {
public static void main(String[] args) {
Pig myPig = new Pig();
myPig.animalSound();
myPig.sleep();
myPig.myMethod();
myPig.myOtherMethod();
}
}