-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMammalInt.java
More file actions
32 lines (28 loc) · 816 Bytes
/
MammalInt.java
File metadata and controls
32 lines (28 loc) · 816 Bytes
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
package InterfacesProgram1;
/*
Mammalint class implements Animal interface
This program is a simple example of how can be used an interface on a class.
Implements the method of the interface and its own to create an object.
@author Anette Larios
@since 12.06.2023
@version 1.8.0
*/
public class MammalInt implements Animal{
public void eat(){
System.out.println("Mammal eats");
}
public void travel(){
System.out.println("Mammal travels");
}
public int numberOfLegs(){
return 0;
}
//main
public static void main (String []args){
//creates an object called 'firstMammal' type MammalInt
MammalInt firstMammal = new MammalInt();
//Calls methods for the created object.
firstMammal.eat();
firstMammal.travel();
}
}