30 September 2020

Inhertiance

"is a" vs. "has a" Composition: A class has objects of various types as state. BigFraction: A BigFraction has two BigIntegers. You know taht every class you create is an Object.


                      Grandpa
                     /
                  Mama       Papa
                   f()        f()
                    \         /
                       Baby

Baby b = new Baby();
b.f();  //what's the problem?  What if Mama's and Papa's f()s
do different stuff.  

DIAMOND OF DEATH: It is not allowed in Java.
Once you inherit, you can't do so again.  
Why is this ok for interfaces?  THEY HAVE NO CODE.