/* * @topic T10354 Feb 5, 2013 Inheritance Demo v.2 * @brief class Cat extends VWCharacter */ package inheritance; public class Cat extends VWCharacter { static final private String CAT_SOUND = "meow"; // constructor public Cat( String name ) { // no problem accessing protected data attribute // from the superclass: this.name = name; } // Object's method overriden here (for no good reason but a demo) public String toString() { return getSound(); } // abstract method is implemented here: public void speak() { System.out.println( getSound() ); System.out.println( "My name is " + name ); } // private method demo private String getSound() { return CAT_SOUND; } }//class Cat