







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!








Public Service Announcement:
Readings:
Today:
Object[] things = new Object[2]; things[0] = new IntList (3, null); things[1] = "Stuff";
Object[] Object Object
Object[] Object[]
3
IntList "Stuff"
String
int
IntList
int IntList
String ???
static type
container
dynamic type value
int double boolean ... Object
Integer Double Boolean String IntList int[] Object[] ... String[]
is a (un)wraps to
class Worker { void work () { collectPay (); } }
class Prof extends Worker { // Inherits work () }
class TA extends Worker { void work () { while (true) { doLab(); discuss(); officeHour(); } } }
Prof paul = new Prof (); | paul.work() ==> collectPay(); TA mike = new TA (); | mike.work() ==> doLab(); discuss(); ... Worker wPaul = paul, | wPaul.work() ==> collectPay(); wMike = mike; | wMike.work() ==> doLab(); discuss(); ...
Lesson: For instance methods (only), select method based on dynamic type. Simple to state, but we’ll see it has profound consequences.