Commit 3511c9dd authored by Michael Lundquist's avatar Michael Lundquist
Browse files

Adding some notes from the kindle. It was fun, but it's time to get serious

parent 227f7c56
......@@ -144,4 +144,42 @@
### 2.3.2 Multiple Inheritance for Interfaces
-
\ No newline at end of file
- __multiple inheritance__: the ability to inherit more than one type.
- Java onnly allows multiple inheritance for interfaces. If java allowed multiple inheritance for classes, the instance variables and methods could become ambiguous.
- some languages allow multiple inheritance from concrete classes. Inheriting from multiple classes called __mixins__.
- These mixin classes aren't meant to be instantiated, only inherited from.
- java approximates this with interfaces
- interfaces __extend__ other interfaces, but classes __implement__ interfaces.
- According to the book, "Java interfaces that approximate teh mixin include:"
- `java.lang.Cloneable`
- `java.lang.Comparable`
- `java.util.Observer` which adds an update feature to a class that whishes to be notified when certain "ovservable" objects change state.
- The book doesn't offer much information on how these methods are implemented, just that mixins implement them.
### 2.3.3 Abstract Classes
- abstract classes include teh __abstract__ modifier in their class definition.
- Abstract classes can't be instantiated themselves. They must be overridden to be instanteiated.
- Abstract classes can have abstract methods that also have the __abstract__ modifier, don't have a method body, and must me instantiated by their subclasses.
- Although abstract methods have no body, they can be called from other methods within the abstract class because their subclasses *must* implement them. This is a design pattern known as __template method pattern__
-Syntax:
```java
public abstract class ExampleAbstract{
public void exampleAbstractMethodCall(){
abstractMethodExample();
}
public abstract void abstractMethodExample();
}
```
## 2.4 Exceptions
-
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment