Created
January 19, 2014 08:55
-
-
Save rajeevprasanna/8502195 to your computer and use it in GitHub Desktop.
constructor with args
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package constructors.superConstructorWitArgs; | |
public class Animal { | |
Animal(String name) { } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package constructors.superConstructorWitArgs; | |
public class Horse extends Animal { | |
//TODO : Comment the constructor and check the error | |
Horse() { | |
//super(); // Problem! as super class doesn't have a default constructor | |
super("name"); // works | |
} | |
public static void main(String[] args){ | |
Horse horse = new Horse(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment