Tutorial by Topics: inter



An interface is a reference type, similar to a class, which can be declared by using interface keyword. Interfaces can contain only constants, method signatures, default methods, static methods, and nested types. Method bodies exist only for default methods and static methods. Like abstract classes, Interfaces cannot be instantiated—they can only be implemented by classes or extended by other interfaces. Interface is a common way to achieve full abstraction in Java.

Function pointers are pointers that point to functions instead of data types. They can be used to allow variability in the function that is to be called, at run-time.

A pointer is a type of variable which can store the address of another object or a function.

An interfaces specifies a list of fields and functions that may be expected on any class implementing the interface. Conversely, a class cannot implement an interface unless it has every field and function specified on the interface.

The primary benefit of using interfaces, is that it allows one to use objects of different types in a polymorphic way. This is because any class implementing the interface has at least those fields and functions.


Page 1 of 7