CS 106A Lecture 21: CS 106A Lecture Notes Week 7 Fri

30 views1 pages

Document Summary

System. out. println: essentially the println commands we"ve used before, system. out. println is standard java; println is the stanford library. Polymorphism: polymorphism: ability for the same code to be used with different types of objects and behave differently with each. A variable of type t can hold an object of any subclass of t. Employee ed = new lawyer(); (lawyer is in employee class) When method is called on ed, it behaves as a lawyer: you can also pass any subtype of a parameter"s type. If you pass employee as a parameter, lawyer subclass and. Polymorphism mystery problems: sometimes classes are jumbled up and call methods of each other, it is best to draw a tree that shows hierarchy of classes. Then fill in diagram that shows what each class inputs for different methods, keeping in mind the principle of overriding. Cs 106a critters: animals: ant, bird, crab, etc, behavior. Eat; fight; getcolor; getmove; tostring: critter subclass.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents