posted 14 years ago
I am doing some problems regarding Return type in java.I am facing some problems. could any help please.
1. class Plant {
2. String getName() { return "plant"; }
3. Plant getType() { return this; } // what mean 'return this' here or return super mean
4. }
5. class Flower extends Plant {
6. ( / insert code here. I have four options A to D. A,C,D are correct here but don't know why? Anyone explain.)
A. Flower getType() { return this; }
B. String getType() { return "this"; }
C. Plant getType() { return this; }
D. Tulip getType() { return new Tulip(); }
7. }
8. class Tulip extends Flower { }