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
|
107 Discussions
|
Please Login in order to post a comment
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(); } }
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(); } }
class Flower { String whatsYourName(){ return "I hava many names and types"; } }
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(); } }