

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Chris Brooks
Department of Computer Science
University of San Francisco
Department of Computer Science — University of San Francisco – p. 1/
??
-^
-^
-^
-^
Department of Computer Science — University of San Francisco – p. 2/
??
public
class
Person
public
String
lastName;
public
String
id;
public
void
eat()
public
void
sleep()
Department of Computer Science — University of San Fra
public
class
Professor
extends
Person
public
String
officeNum;
public
void
teach()
public
void
grade()
public
void
forget()
Department of Computer Science — University of San Francisco – p. 4/
??
-^
Person(String
lname)
lastName
= lname;
-^
Department of Computer Science — University of San Francisco – p. 5/
??
-^
Professor(String
lname,
String
office)
lastName
lname;
officeNum
= office;
-^
Department of Computer Science — University of San Fra
Constructors and Inheritance
-^
-^
Professor(String
lname,
String
office)
super(lname);officeNum
= office;
-^
Department of Computer Science — University of San Francisco – p. 7/
??
More on super()
-^
-^
-^
in
Person.java
public
void
greet()
System.out.println(‘‘Nice
to
meet
you’’);
Department of Computer Science — University of San Francisco – p. 8/
??
More on super()
-^
in
Professor.java
public
void
greet()
System.out.print(‘‘I
do
say,
old
chap,’’);
super.greet(); }
Department of Computer Science — University of San Fra
Exercise
-^
-^
-^
-^
-^
Department of Computer Science — University of San Francisco – p. 10/
??
Interfaces
-^
-^
-^
-^
-^
-^
Department of Computer Science — University of San Francisco – p. 11/
??
Interfaces
-^
-^
interface
FlyingThing
public
void
fly();
} public
class
Bat
extends
Animal
implements
FlyingThing
public
void
fly()
System.out.println(‘‘I’m
flying!’’);
Department of Computer Science — University of San Fran