This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I've been studying for about two months using K&B guide book and some test simulators (Whizlabs, LearnKey). I have few questions:
1) on some simulators I found questions that shouldn't be on the exam (according to K&B book), for example, questions regarding ConcurrentHashMap class and object. Who am I to trust about that? Should I skip those questions while practicing?
2) considering questions on the exam: In book it is stated that you must answer 47/72 to pass, but on the Sun's website it says 35/60. I hope Sun's information is correct, since it is easier to pass then
3) if it's multiple choice question, is it stated in question how much answers we must choose?
4) how many (approximately) d&d is usually on the exam, and, if anyone who took the exam can tell me, by his personal opinion, are those questions easier or harder than the regular ones?
5) I don't know very well some of the important classes' API that will be on the exam (for example, Scanner, Date and Number Format classes...), simply, because I've almost never used them in programming. Most of the questions about them I can answer correctly, because I understand what each method does, but some trick questions I can't catch (for example, once I answered incorrect because I didn't recognize that "put" is the method for adding elements to Maps, you can't use "add"). How important is to know all the classes' API by heart before taking the exam?
SCJP done, SCWCD on the way!
1. Yes, you can leave those questions.
2. Exam has 60 questions and you have to get 35 correct.
3.yes, it will prompt you on how many answers to choose.
4, You cant say how many d&d questions will be on exam but they are really easy.
5. Yes, you should have a sound knowledge of all API's.
Apart from all above suggestions, what you need is to stay calm.
Be positive. Always remind yourself that you are going to clear exam in the first attempt itself.
Don't be nervous at all. You have done studies, so it won't be a difficult task for you.
Thank you for answers I haven't still taken the exam because I'm waiting for the vouchers to arrive by mail (they're already ordered). It should be any day now.
In the meantime, I've been doing the Learnkey exam simulator, which came on the CD with K&B book, and I think I found an error in one question. Here's the thing:
Which of the following will fullfill the equals() and hashCode() contracts for this class? (Choose all that apply)
a) return ((SortOff)o).bal == this. bal;
b) return ((SortOff)o).code.length() == this. code.length();
c) return ((SortOff)o).code.length()*((SortOff)o).bal == this. code.length()*this.bal
d) return ((SortOff)o).code.length()*((SortOff)o).bal*((SortOff)o).rate == this.code.length()*this.bal*this.rate
C is one correct answer, I agree with that. But in the solutions it is stated that D is also a correct answer, and I disagree. For example, suppose we have two objects, and values o1.code.length=4, o1.bal=5, o2.code.length=5, o2.bal=6, and values for the rates are o1.rate=6, and o2.rate=4. So, in that case, the o1.hashCode would be 4*5=20, and o2.hashCode=5*6=30. But o1.equals(o2) would return 4*5*6==5*6*4 which is true. So we have equal objects with non-equal hashCodes, which is not good.
Am I right?
The question is number 52 in the Quiz A of the test simulator I mentioned above.
Although this should all be in a different topic but I think you are right. I created the following code which clearly shows that there are two objects inserted in the set though they are equal.
However, the bigger point is that the variables used in calculating the hashcode must at least be used in the equal, which this program is clearly doing with option IV. The object has been given meaningful equivalence, but what you have unearthed is that our hashing algorithm is poor.