A compile-time error will be produced when you fail to follow the basic syntax of Java. For example, the following would cause a compile-time error due to incorrect array-access syntax:
However, if the code follows all of the syntax rules, it won't generate a compile-time error but, if you're doing something "bad", you could still produce a run-time error. Take this example:
Even though this meets the syntax requirements, this will cause an ArrayIndexOutOfBounds exception to be thrown at run-time. I hope this helps a little. If you're having a problem with a specific example, perhaps you could ask about that and I can try to be of more help. Corey
It really depends on the situation. You'll have to read up on APIs and how they work and/or write some code and experiment. Writing code is a good way to learn things for the certification exam. This may have been a more general answer than what you wanted but I think if you take the time and write code you will be doing yourself a favor. Good luck!
The only reason for time is so that everything doesn't happen all at once.
- Buckaroo Banzai
Hi, Thanks for your responses. I think I understand the concept behind it, but I always seem to have problems with questions like this when I do sample exams. I wrote the exam once before and failed miserably on these kind of questions. So would you suggest that a rule of thumb is to check to see if the question has the correct syntax first, and then rule out the multiple choice answers as I go along? Thanks again, Anthea
If a question says, "What is the result of compiling and running this code?", the first thing I do is look for compiler error. That means look at every nit-picky detail - be a human compiler for a minute. If you're sure there aren't any of issues there, then you can rule out that response and move on to look for potential run-time errors. Again, if you don't find any of those, then you know that the app will run properly so now all you have to do is figure out what it does! I hope that helps a little, Corey