Created
January 19, 2014 06:44
-
-
Save rajeevprasanna/8501351 to your computer and use it in GitHub Desktop.
return type of overriding methods
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 legalReturnTypes.overriding; | |
public class Alpha { | |
Alpha doStuff(char c) { | |
return new Alpha(); | |
} | |
} |
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 legalReturnTypes.overriding; | |
public class Beta extends Alpha { | |
Beta doStuff(char c) { //return type Beta is sub class of Alpha | |
return new Beta(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment