click below
click below
Normal Size Small Size show me how
Chapter 10
Introduction to Inheritance
Term | Definition |
---|---|
Inheritance | A mechanisms in Java and all object-oriented languages that enables one class to acquire all the behaviors and attributes of another class and then to expand on those features |
Unified Modeling Language(UML) | Programmers and analysts sometimes use a graphical language to describe classes and object-oriented processes; this Unified Modeling Langauge consists of many type of diagrams |
1. Class Diagram | A visual tool that provides you with an overview of a class. Consists of a rectangle divided into three sections. The top section contains the name of the class. The middle section contains the names and data types of the attributes. |
2. Class Diagram | The bottom sections contains the methods. Only the method return type, name, and arguments are provided in the diagram |
Base Class | A class that is used as a basis for inheritance |
Derived Class | A class that inherits from a base class |
Composition | The relationship in which a class contains one or more members of another class, when those members would not continue to exist without the object that contains them. Ex: If a Business closes, its Departments do as well |
Aggregation | The relationship in which a class contains one or more members of another class, when those members would continue to exist without the object that contains them. Ex: If a business or department closed, the employees would continue to exist |
Superclass and Subclass or Parent Class and Child Class | Other terms for base class and derived class |
Keyword extends | Used to achieve inheritance in Java. For example, the following class header creates a superclass-subclass relationship between Employee and EmployeeWithTerritory... public class EmployeeWithTerritory extends Employee |
Instanceof Operator | Used to determine if an object is member of a class. Ex: If northerRep is an EmployeeWithTerritory object, then the value of each of the following expressions is true: northernRep instanceof EmployeeWithTerriory... northernRep instanceof Employee |
Upcast | Programmers say that instanceof yields true if the operand on the left can be upcast to the operand on the right |
Polymorphism | Using the same method name to indicate different implementations. This term means "many forms" - many different forms of action take place, even though you use the same word to describe the action |
Overriding Parent Class Methods | When you create a method in a child class tat has the same name and parameter list as a method in its parent class, you override the method in the parent class. When you use the method name with child object, child's version of method is used |
Keyword super | Always refers to the superclass of the class in which you use it |
Information Hiding | The concept of keeping data private |
Keyword Protected | An intermediate level of security between public and private access. If you create a protected data field or method, it can be used within its own class or in any classes extended from that class, but it cannot be used by "outside" classes |
Fragile Classes | Classes that directly use fields from parent classes are said to be fragile because they are prone to errors - that is, they are easy to "break" |
Methods You Cannot Override | The three types of methods that you cannot override in a subclass are... 1. static methods... 2. final methods... 3. Methods within final classes |
Virtual Method Calls | In Java, all instance method calls are virtual method calls by default - that is, the method used is determined when the program runs because the type of the object used might not be known until the method executes |
Inlining Code | When a compiler optimizes a program's performance by removing the calls to final methods and replacing them with the expanded code of their definitions at each method call location |
Subtype Polymorphism | The ability of one method name to work appropriately for different subclasses of a parent class |