An interface is a collection of abstract methods, meaning that they are not implemented in the interface itself. Interfaces can also contain constants, default methods, static methods, and nested types. An example of an interface in Java is:
public interface Animal {
public void eat();
public void sleep();
}
An abstract class is a class that contains both abstract and non-abstract methods. Abstract classes can also contain constants, default methods, static methods, and nested types. An example of an abstract class in Java is:
public abstract class Animal {
public abstract void eat();
public void sleep(){
System.out.println(“Sleeping…”);
}
}