You are viewing a single comment's thread. Return to all comments →
class Flower {
String whatsYourName(){ return "I have 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(); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Covariant Return Types
You are viewing a single comment's thread. Return to all comments →
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(); } }