I think I've found 2 more mistakes in the Assessment Tests of the book (OCP Study Guide).
In Q.8 on p. xlii, answer A says "Wolf has-a name" which is true according to the solutions. However, the other answers refer to the class name, not to the name of the field. Also the discussion in Chapter 2 refers always to the class name, never to the field name (as far as I remember). So it would be more correct to say that "Wolf has-a String", isn't it?
In Q.14, I found some more mistakes: The java.util.Scanner class is not properly imported; and also the RainException class is not static - so it cannot be instantiated in the static method in l.7.
Please quote a little more of the parts you are worried about. Also please give more details about the book, e.g. author, so those who have the book can look up the pages for themselves. Thank you for providing the page numbers, which is very helpful for anybody who recognises the book (). I don't have a copy myself.
It is customary when discussing association, inheritance, aggregation, and composition to say things like
A taxi IS-A car.
A car HAS-A driver.
A car HAS-A registration number.
A car HAS[-A] wheel[s].
A car HAS[-A] passenger[s].
Now, the driver and the passenger might be instances of the Person class, so you don't usually say A car HAS-A person, and if the registration number is implemented as a String, you would not usually say a car HAS-A String, so I think I would probably agree with the first solution given.
Please show us the code where the Scanner isn't imported properly, and how that Exception is instantiated.
Oh, I'm sorry, I thought the forum is just about one book :-) It's Boyarsky-Selikoff, OCP Study Guide.
I'm quite fine now with the first one - this was
so we say here that Animal has-a name?
The second one was
So the question was, how many compilation errors are in here.
(1) The line numbers were given to start with one, so the import for java.util.Scanner is missing.
(2) String does not implement AutoCloseable, so cannot be used with try-with-resources statement.
(3) RainException is not catched or declared.
(4) RainException is not static, cannot be instantiated from the static method main.
(5) In the finally block, s is not available anymore (it goes out of scope after the try block).
So these would be 5 errors.