Posting the name of a book is ofcourse not illegal.
Note that books in general are copyrighted. Redistributing a book in electronic format (as a PDF for example) for free, without permission from the publisher, is ofcourse illegal. So posting links to illegal electronic versions of books is not permitted on JavaRanch. If I encounter someone posting a link to an illegally copied book, I delete the post and try to warn the owners of the website that they are hosting illegally copied material.
When you copy a question from a book, mock exam or other source, we require that you
quote your sources. One of the reasons for that is that we do not allow questions from "dumps", which are illegally copied sets of questions from the real SCJP exam. When you do the exam, you agree to Sun's terms and conditions, and one of those is that you will not redistribute the questions you see on the exam.
In principle, questions that you find in books etc. are also copyrighted, but we do allow discussing single questions from books and other sources here. If the author of such a book or mock exam would object to it, then we would remove those questions from the forums. But as said above, questions from "dumps" or questions that we recognise as coming from the real exam will be deleted immediately.