I'm looking for some exercieses to practice my Java.
Two weeks ago I had following Java training: Java Programming Language, Java SE 6 (SL-275-SE6). This was a training with Java Basics. Now my boss wants me to become a OCJP/SCJP. But I think I'm not ready to manage that test without enough practice.
Hi Sezar, i think first you should read apis and practice before taking any exam. I recommend you to solve the problems posted here, this will give you enough understanding about java. Also java book by kathy siera is recommended to enhance your knowldge in a systematic way. Hope this will help you.
30614 now, soon to be 30615.
I would have been impressed by a good beginners’ exercise, but I can see several style problems with the first suggested solution. Post the first solution and I promise to find 4 things wrong with it. But not until tomorrow.
Even if you don’t post the exercise’s solution, I shall not look at it, but shall tell you what I think it wrong with it, from memory:-
1: Minor point. Use of return twice in the same method. Some people do not regard this as an error, however.
2: Minor point: the use of i-- and index++ is confusing. Use index - i.
3: Minor point: It would be better to iterate the array forwards, rather than using i--.
4: Minor point: Wrap the entire body of the method in a test for whether the array’s length is greater than 1. You can’t reverse an array with ≤ 1 member! This is linked with point 7, however.
5: Moderate point. That method takes all information required from its parameters, and passes all information back via its return type, so it ought to be static.
6: Major point: that method has the dangerous possibility of returning null. It would be better simply to throw an Exception. Beginners using it might not know how to throw Exceptions, so they should forget about the possibility of nulls and let the JVM throw its own Exceptions. It might say return null in the question, but that is a dangerous thing to do
7: Major point. That method does not do what the question asked for. It does not reverse the array, but creates a copy array in reverse order.