You are viewing a single comment's thread. Return to all comments →
I am use abstract class:
abstract class Flower { public abstract String whatsYourName(); }
class Jasmine extends Flower {
@Override public String whatsYourName() { return "Jasmine"; }
}
class Lily extends Flower {
@Override public String whatsYourName() { return "Lily"; }
abstract class Region { public abstract Flower yourNationalFlower(); }
class WestBengal extends Region {
@Override public Jasmine yourNationalFlower() { return new Jasmine(); }
class AndhraPradesh extends Region {
@Override 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 →
I am use abstract class:
abstract class Flower { public abstract String whatsYourName(); }
class Jasmine extends Flower {
}
class Lily extends Flower {
}
abstract class Region { public abstract Flower yourNationalFlower(); }
class WestBengal extends Region {
}
class AndhraPradesh extends Region {
}