CSE 8B Chapter Notes - Chapter 11.1-11.5: Hurricane Ioke
Document Summary
Object-oriented programming allows one to define new classes from existing ones: called inheritance. Inheritance: good tool for reusing software: best way to avoid redundancy and make system easy to understand. Inheritance: allows one to define a base class (superclasses) and extend it to more specific classes (subclasses) Class (c1) extended from another class (c2) is called the subclass, and c2 is the superclass: superclass == base class == parent class, subclass == extended class == child class. These classes inherit fields and methods from its parent, and can implement. Syntax for creating a subclass: new fields and methods as well: public class subclass extends superclass. Note: private variables declared in the super class can still only be used within that class. They can still be modified via getters/ setters still. Note: inheritance should model the is-a relationship. Note: in java, a class can inherit from only one super class.