Interfaces Flashcards
If interfaces cannot be instantiated, what are they?
Implemented by other classes
Extended by other interfaces
Interface method definition
Access modifier, interface keyword, interface name, parent interfaces, interface body
Interface Access Modifiers should be…
Should be public else interface is only accessible to classes defined in same package as interface
Abstract Method
Interface followed by semicolon
No braces
Does not contain implementation
Default Method–How to Define
Default keyword at beginning of method signature
Default Method–Defn
Allow for evolving interfaces by adding new functionality to existing interfaces and allowing for binary compatibility with older code
Static Methods–How to Define
Static keyword
Constant Declarations
Way to say an interface value is public, static and final
Implicitly public methods
Abstract, default and static methods
When defining a reference variable with an interface as its type…
..any object assigned to it MUST be ab instance of a class that implements the interface
Options for extending an interface containing a default method
Don’t reference default method
Redeclare default method (makes it abstract)
Redefine the default method
Things contained in an interface
Constants Method signatures Default methods Static methods Nested Types
Interface method bodies exist only for…
Default methods and static methods