Think Inheritance how many type of Vehicles can you name? and how are they related? List a few common features of all vehicles (i.e. passenger capacity) List a feature unique to a specific vehicle (i.e. School Bus exit doors) ====================================================== Think Inheritance how many type of Vehicles can you name? and how are they related? I drive a SUV a type of Car I use to drive a Pickup Car (# of doors) | | | SUV Sedan Pickup? -------------------------------------------- Schoolbus Cargo Truck Motercycle Car Sailboat Airplane Glider Bicycle ---------------------------------------------- Vehicle id,name,year make,model Moterized Non-Moterized engine Car Truck Boat Bicycle # of pass cargo cap SailBoat Canoe ------------------------------------------------- Sometimes I have fields/method that do not fit in classic Inheritance, for example I need a method to fuel my Vehicle... I can fuel a car I can fuel a Motercycle I can fuel an airplane I do not fuel a sailboat, nor bicycle Java has Single Inheritance, so you cannot have more than 1 parent class Java does support have more than 1 Interface which does allow me to say: A Car is a MotorVehicle and a Car is Fuelable (an Interface) for example I have a lot of Entity classes, and I want to sort them.... I have a problem: 1) the sort is already built in to Java 2) my Entity class has specific business rules for sorting How do you sort Employees? sort by name?, by hire date?, by job title?, sort by parking space! SO Java has an Interface Comparable, if your Entity class implements (not extends) the Comparable interface, your Entity class is sortable this means you MUST code all the methods of the Interface and it means Java can call the method (by name) and we have a sort! this is Polymorphism. I can have at MOST 1 parent class (superclass) but I can implement as many interfaces as I like so my Entity class can be: Comparable, Runnable, Serializable, etc ================================================= Multiple-Inheritance I am a worker so I have a name a method to computePay the computePay method take hours work * pay_rate (+ overtime) I just go a promotion to supervisor a supervison has a computePay method different than a work does so I am BOTH a worker and supervisor, which computePay should run?