ss Sharma wrote:So is the answer in the book is wrong? Is so what about the answer explanation ?
It is very important to have a great eye for detail when you try to run the code snippets yourself. I think (actually I am 100% sure) the code snippet you are using is different from the one in the study guide. That's why you can compile the code snippet, but the book claims a compiler error wil be given. So you should revise your code snippet very carefully with the one listed in the book, make the necessary changes and try to compile the code snippet again.
In this topic you'll find an explanation about the same code snippet. Definitely worth reading as well!