CS 121 Chapter Notes - Chapter 10: Selection Sort, Insertion Sort

55 views6 pages

Document Summary

A class name can be used to declare the type of an object reference variable. Similarly, an interface name can be used as the type of a reference variable as well. An interface reference variable can be used to refer to any object of any class that implements that interface: ex: suppose we declare an interface called speaker public interface speaker public void speak(); public void announce(string str); The interface name, speaker, can now be used to declare an object reference variable: The reference variable current can be used to refer to any object of any class that implements the speaker interface: ex: if we define a class called philosopher such that it implements the. Speaker interface, we can then assign a philosopher such that it implements the speaker interface, we can then assign a philosopher object to a speaker reference. current = new philosopher(); The assignment is valid, b/c a philosopher is a speaker.

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

Related Questions