Home Segments Top Top Previous Next

331: Mainline

To ensure that the rating method is defined in both the Movie and Symphony subclasses of the Attraction class, you perform two steps.

First, you mark the Attraction class with the abstract keyword:

         *-- Keyword 
         | 
         v 
public abstract class Attraction { 
 ... 
} 

Second, you define the rating method, again marking that method with the abstract keyword, but now inserting a semicolon where you would ordinarily expect the definition's body:

         *-- Keyword 
         |                    *-- No body 
         v                    v 
public abstract int rating () ;