Documente Academic
Documente Profesional
Documente Cultură
00 Tutorial 5
Agenda
Quiz 1 Results
Inheritance
Abstract Classes
Interfaces
Quiz 1 Results
Mean: 87.2
Std dev: 13.4
n = 82 (# students)
Quizzes will be available during office
hours this week, or you can pick
them up at Active Learning
session
Inheritance
}
class B extends A { A
int y;
}
class C extends B { B
int z;
}
C
Inheritance Example
x
x
y
/* abstract methods */
abstract public int getCurrentValue();
}
Questions
class Colorizer {
static void colorMeRed(HasColor c) {
c.setBackgroundColor(Color.red);
}
static void swapColors(HasColor c) {
Color tmp = c.getBackgroundColor();
c.setBackgroundColor(c.getForegroundColor());
c.setForegroundColor(tmp);
}
public static void main(String[] args) {
StudentWithColor s = new StudentWithColor();
StringWithColor t = new StringWithColor("HI");
colorMeRed(s); swapColors(s);
t.setBackground(Color.green); swapColors(t);}}
Example Interface Use
fgColor = c; }
public Color getForegroundColor() {
return fgColor; } }
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the United States and other countries.