You are on page 1of 1

public interface Animal

{
public void animalSound();
public void sleep();
}

public class Cat implements Animal


{

public void animalSound()


{
// The body of animalSound() is provided here
System.out.println("The cat says: meeeooowww");
}

public void sleep()


{
// The body of sleep() is provided here
System.out.println("Mmmurrr");
}

public class InterfaceTest


{
public static void main(String[] args)
{
Cat myCat = new Cat(); // Create a Pig object
myCat.animalSound();
myCat.sleep();
}

Keluaran:
run:
The cat says: meeeooowww
Mmmurrr

You might also like