Interface - Day 7 Flashcards
Interface
Define a generic template that can be implemented by various classes
Containment of interface
Method signatures and constant declarations
Declared methods in interface are implicitly public and abstract and the data fields are implicity public, static and final.
Can extend many interfaces and class can implement more than one interface. Multiple inheritance
Class can extend from only one class but can implement infinite interfaces
Interface key stuff
“implements” keyword to implement an interface. The classes implementing an interface must implement all specified methods. IF NOT; abstract classes
Interface creates a type. Can refer to objects of classes which implement that interface. Thus dynamic binding.
Can have default and static (post Java 8… NOT THIS COURSE)
Creating interface
public interface PremiumWords {
Body }
Using implement
public class PremiumCustomer extends RegularCustomer implements PremiumCards {
Body }