Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Monster
- {
- private String myName;
- public Monster()
- {
- //myName = "Monster"; //uncomment and recompile and run
- }
- public Monster( String name )
- {
- myName = name;
- }
- public String toString( )
- {
- return myName;
- }
- }
- class Witch extends Monster
- {
- public Witch( ) //GoodWitch will not compile without this constructor
- {
- //automatically calls super()
- }
- public Witch( String name )
- {
- }
- }
- class GoodWitch extends Witch
- {
- //what do we need here??
- // I inserted
- //public GoodWitch(){
- //}
- public GoodWitch( String name )
- {
- //automatically calls super()
- }
- }
- public class WhatsOnTheInside
- {
- public static void main ( String[] args )
- {
- GoodWitch bad = new GoodWitch(); //why does this not compile
- System.out.println(bad);
- GoodWitch witch = new GoodWitch("Harriet");
- System.out.println(witch);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment