Constructor o Method with same name as class ●No return type oCalled automatically by new() oJava provides a default one ONo parameter,default initialization(0/null) OUser can define their own OThe default one is gone
Constructor lMethod with same name as class lNo return type lCalled automatically by new() lJava provides a default one ¡No parameter, default initialization (0/null) lUser can define their own ¡The default one is gone
Method overloading Same method name and return type, different parameter list ODifferent type,order,number... oReturn type is NOT enough
Method overloading lSame method name and return type, different parameter list ¡Different type, order, number… lReturn type is NOT enough
Inheritance o Child class can extend parent class o Gets all the parent's fields and methods OPrivate vs.protected ● Can use child for anything that's expecting parent (upcasting) OBut not vice-versa o Can only extend one class ONo multiple inheritance
Inheritance lChild class can extend parent class lGets all the parent’s fields and methods ¡Private vs. protected lCan use child for anything that’s expecting parent (upcasting) ¡But not vice-versa lCan only extend one class ¡No multiple inheritance
Inheritance oClass Foo extends Bar oCan override parent's implementation o Other classes that only know Bar can use Foo as well,but not any extra methods Foo added
Inheritance lClass Foo extends Bar { lCan override parent’s implementation lOther classes that only know Bar can use Foo as well, but not any extra methods Foo added
polymorphism oWe have an array of Shapes,and we ask each Shape to draw()itself O The correct method will be called OThe Circle's draw()method if the Shape object is actually Circle,Square's draw()if it's actually a Square O-O term:polymorphism
polymorphism lWe have an array of Shapes, and we ask each Shape to draw() itself lThe correct method will be called ¡The Circle’s draw() method if the Shape object is actually Circle, Square’s draw() if it’s actually a Square lO-O term: polymorphism