COMPSCI 61B Lecture Notes - Lecture 8: Hyponymy And Hypernymy, Method Overriding, Alaskan Malamute

95 views5 pages

Document Summary

After adding the insert methods from discussion 3, our alist and sllist classes have the following methods. Suppose we"re writing a library to manipulate lists of words. Might want to write a function that nds the longest word from a list of words. Hard to generalize code for both alists and slists. Java allows multiple methods with same name, but di erent parameters. More code to maintain (changes must be made to both functions) If we make another list someday, we"ll need to de ne yet another function. In natural languages, we have a concept known as a hypernym to deal with this problem. Dog is a hypernym of poodle, malamute, yorkie, etc. Sllists and alists are both clearly some kind of list . List is a hypernym of sllist and alist. Expressing this in java is a two-step process: Step 1: de ne a reference type for our hypernym (list61b. java)

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents