COSI 12b Lecture Notes - Lecture 7: Codeshare Agreement, Multiple Inheritance

67 views2 pages

Document Summary

An interface is a list of methods that classes can promise to implement. Inheritance gives you an is a relationship with code sharing. An interface gives you an is a relationship without code. Syntax: public interface {public (parameters);} Implementing syntax: public class implements {} An interface can be used as a type in parameters. For example, public static void info (shape s) {} with the interface shape will take in any class that implements the interface. An array of an interface type can be created to store class"s objects that implement the interface. Multiple inheritance is not allowed (a class can only extend one class), but multiple interfaces can be implemented. Interfaces can store constants, but they must be public, static, and final. A class that implements an interface that extends another interface must implement within the class the abstract methods of the superinterface.

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