SE450: Java: Types, Interfaces, Concrete and Abstract Classes [9/41] ![]() ![]() ![]() |
Java allows for single inheritance in class extension, but multiple inheritance in interface implementation
class Foo extends Bar implements Baz, Boo { // implementation }
interfaces can be thought of as "pure virtual" abstract classes
Diamond inheritance is supported in Java with interfaces only
abstract classes are classes with abstract methods. They can't be instantiated, and the abstract methods must be implemented by subclasses, unless the subclass is itself abstract
The Type relationships in Java are:
Object
Object
For every class C (that is not Object
), C is a subtype
of Object
. This has implications for every
class that you write.
A value of a subtype can appear wherever a value of its supertype is expected. In other words, a value of a subtype can always substitute for a value of its supertype.