Please enable JavaScript.
Coggle requires JavaScript to display documents.
Inheritance & Interfaces (calling the superclass constructor (ex…
Inheritance & Interfaces
-
-
overriding
-
If you are not satisfied with the behavior of an inherited method, you override it by specifying a new implementation in the subclass.
-
-
-
dynamic method lookup.
method calls are always determined by the type of the actual object, not the type of the variable containing the object reference
Dynamic method lookup allows us to treat objects of different classes in a uniform way. This feature is called polymorphism
-
Abstract classes & meths
-
-
-
extending ab ab class makes it to where the subclass has to use the meths in the ab class - it also forces the creation of subclasses
-
In Java, an interface type is used to specify required operations. We will declare an interface type that we call Measurable: public interface Measurable { double getMeasure(); }
An interface type is similar to a class, but there are several important differences: • Methods in an interface type must be abstract (that is, without an implementation) or, as of Java 8, static or default methods (see Java 8 Notes 9.1 and 9.2). • All methods in an interface type are automatically public. • An interface type cannot have instance variables. • An interface type cannot have static methods.