6.-Interfaces.txt - Interfaces An interface is a completely abstract class that contains only abstract methods Some specifications for interfaces

6.-Interfaces.txt - Interfaces An interface is a completely...

This preview shows page 1 out of 1 page.

Interfaces An interface is a completely abstract class that contains only abstract methods. Some specifications for interfaces: - Defined using the interface keyword. - May contain only static final variables. - Cannot contain a constructor because interfaces cannot be instantiated. - Interfaces can extend other interfaces. - A class can implement any number of interfaces. An example of a simple interface: interface Animal { public void eat(); public void makeSound(); } Interfaces have the following properties: - An interface is implicitly abstract. You do not need to use the abstract keyword while declaring an interface.
Image of page 1

You've reached the end of your free preview.

Want to read the whole page?

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture