Computer Science 225
Advanced Programming
Spring 2020, Siena College
Lecture 6: Interfaces; Introduction to Inheritance
Date: Monday, February 3, 2020
Agenda
- Announcements
- Lab 1: Java Interfaces due in your labs this week
- Problem Set 2 repository deadline today, all due Thursday night
- Problem Set 1 recap
- check your GRADING.md files for accuracy
- int vs. long, including literals
- let the stack do the work
- approaches to the anagrams
- a tree "cursor"
- Java Interfaces wrapup
- implementing multiple interfaces
- In-class exercises (5 assignment points)
- Write the Java statement that would implement sorting of our
array of Animal objects in the ZooArray example, this
time by number of legs from largest to smallest, using a
Comparator defined as an anonymous class passed directly as
a parameter to the Arrays.sort method.
- What changes would need to be made to the Dog class to
implement the Comparable interface, defining the ordering
based on a new int-valued field age?
- Overloaded methods
- Inheritance
- terminology
- a simple example
- protected and default protection
Terminology
- inheritance
- overloading
- ad hoc polymorphism
- subclass/extended class
- superclass/base class
- extends
- derived class
- IS-A association
Examples