I am currently studying for the SCJP certification using the Sierra and Bates Study Guide and in many of the self tests (mock exam questions) I keep running into the same problem - I can't tell whether a particular error will be at runtime (an exception) or at compile (compile error). I know this is a bit of a vague question and that it might not be possible to answer but, how can I tell if it's at compile or at runtime? Would you be able to send me some website links that might be able to help me?
Thanks in advance,
It is a mistake to think that you can solve any major problem with just potatoes.
I cant see anything in your question. the blind answer is www.google.com
Mike Vella Zarb
Joined: Dec 28, 2009
I searched on Google before I asked but could not really find anything helpful - some questions need a long explanation and not just a few search key words. I was hoping that someone might be able to explain it to me in their own words. I'm sorry if you don't see anything in my question, but I did try to explain myself as clearly as possible...
1. compile time error:thrown by compiler while interpreted, if any syntax error in your code. programmer is responsible to clear this error
2.exception/runtime error : thrown by JVM in some exceptional condition. this error may occured due to programmer mistake or internal problem like hardware failure, no memory etc...
<edit>is it help you? </edit>
Thanks, but I'm looking for a way to tell which one is which. I get many multiple choice questions in sample tests and they give me the choice of either Compile-time Error or Runtime Error. I know there's an error, but when is it set off is the hard part...
The compiler can only check for syntax, i.e. missing braces, undefined method calls or variables (typing System.Out.println()), etc. The words/symbols in the java file do not follow the established rules of what can follow what.
a run-time error happens when the code is syntactically correct, but something weird happens. For example, you ask the user to enter two values, and your code will divide 'a' by 'b'. Your code can be 100% correct, but if the user inputs 0 for the denominator, you will get an exception at runtime.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors