We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Java
- Advanced
- Covariant Return Types
- Discussions
Covariant Return Types
Covariant Return Types
Sort by
recency
|
109 Discussions
|
Please Login in order to post a comment
attached image must be changed
one flower's name is Lotus
java conarient return type hacker rank solution
Covariant return types make method overriding flexible, like mapping states to flowers. Saw some cool Java insights on Top Digital Marketing Agencies Uk.
class Flower {
} }
class Jasmine extends Flower{ String whatsYourName(){ return "Jasmine"; } }
class Lily extends Flower{ String whatsYourName(){ return "Lily"; } }
class Region { public Flower yourNationalFlower(){ return new Flower(); } }
class WestBengal extends Region{ public Jasmine yourNationalFlower(){ return new Jasmine(); } }
class AndhraPradesh extends Region{ public Lily yourNationalFlower(){ return new Lily(); } }