In K&B for java 1.5 chap-2,Self-test Q8 i have a doubt...
Which statement(s), inserted at line 6,will compile?
1. Flower getType(){return this;}
2. String getType(){return "this";}
3. Plant getType(){return this;}
4. Tulip getType(){return new Tulip();}
the answers in the book says options 1,3 and 4 are correct as 1 and 4 are examples of co-variant returns
but when i tried to compile the program using these options ...it said the return type is incompatible with Plant.getType()....i am totally confused now! Plz Help
[ March 25, 2006: Message edited by: nivi zal ]
[ March 25, 2006: Message edited by: nivi zal ]
[ March 25, 2006: Message edited by: nivi zal ]