CSE 143 Chapter Notes - Chapter 16: Multiple Inheritance

24 views1 pages
oliveherring648 and 7 others unlocked
CSE 143 Full Course Notes
6
CSE 143 Full Course Notes
Verified Note
6 documents

Document Summary

Interface: a type that consists of a set of method declarations; when classes promise to implement an interface, you can treat those classes similar in your code. An interface is like a class, but it only contains method headers w/o bodies. To write a(cid:374) i(cid:374)terfa(cid:272)e, (cid:272)reate a (cid:374)ew file with the sa(cid:373)e (cid:374)a(cid:373)e as the i(cid:374)terfa(cid:272)e"s (cid:374)a(cid:373)e. e(cid:454): Inside the interface, write headers for each method that we want the interface to have. Instead of writing methods with braces, we use semi-colons: do(cid:374)"t spe(cid:272)if(cid:455) how ea(cid:272)h (cid:373)ethod will (cid:271)e e(cid:454)e(cid:272)uted, these methods are called abstract methods, writing the public keyword on the abstract methods is optional. To connect a class to an interface: de(cid:272)lare that the (cid:272)lass (cid:862)i(cid:373)ple(cid:373)e(cid:374)ts(cid:863) the i(cid:374)terfa(cid:272)e. I(cid:373)ple(cid:373)e(cid:374)t ea(cid:272)h of the i(cid:374)terfa(cid:272)e"s (cid:373)ethod i(cid:374) the (cid:272)lass.

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