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.
Is it safe to say that in general a compiler error resulted from codes that do not make sense in its syntax, while runtime error is the result of poor logic? I would like to know if there is a generalized way to determining if a given code would generate compiler error or runtime error. A related question, so what if the parent class has no default no arg constructor and the child class has no constructor? As far as I can tell, this would be a compiler error since compiler would put in a call for the default no arg constructor in the child class, which means invoking a non-existing constructor in the parent class. Is this right? [ June 22, 2002: Message edited by: Chung Huang ]
Hi Chung, With compile-time vs. runtime errors (or exceptions), I think it's not as clear-cut an explanation as you have said. Compile-time errors include not handling a checked exception. Runtime errors include failure to read from a file or stream. IMO, The best way to determine whether an error is generated at compile-time or at runtime is to experience them yourself. Write and run some code and see for yourself.
Hi , You are correct. Compilation errors occur when your syntax is not right or not allowed. Run time errors occur when you are executing and these might be due logical errors ( semantic), the data required is not available, corruption of data (mainly which invovles remote method invocations and data is serialized). For example , if you are working with sockets and trying to connect to a server, the program would throw a run-time exception , if server is not running for any reason. My idea of posting this message, is to emphasize that run-time errors occur not only due to logical errors , but might also depend on other factors (like network connection, object serilization etc)