java_interface-for-viewing - 3-1Java InterfaceAfter...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 3-1Java InterfaceAfter completing this tutorial, you should be able to do the following:•Define interfaces•Implement interfaces 3-2Defining and Using Interfaces•An interface is like a fully abstract class:–All of its methods are abstract.–All variables are public static final.•An interface lists a set of method signatures without any code details. •A class that implements the interface must provide code details for all the methods of the interface.•A class can implement many interfaces but can extend only one class. 3-3Examples of Interfaces•Interfaces describe an aspect of behavior that different classes require.•For example, classes that can be steered support the “steerable” interface.•Classes can be unrelated.SteerableNonsteerable3-4Creating Interfaces•Use interfacekeyword:•All methods are public abstract.•All variables are public static final.public interface Steerable {int MAXTURN = 45;void turnLeft(int deg);void turnRight(int deg);}3-5Implementing Interfaces...
View Full Document

This note was uploaded on 08/18/2011 for the course COMP 3868 taught by Professor Keithchan during the Summer '97 term at Hong Kong Polytechnic University.

Page1 / 13

java_interface-for-viewing - 3-1Java InterfaceAfter...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online