wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Runtime & Compile time Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Runtime & Compile time Error" Watch "Runtime & Compile time Error" New topic
Author

Runtime & Compile time Error

Lovleen Gupta
Ranch Hand

Joined: Feb 26, 2007
Posts: 63
Whats the difference between runtime error and compile time error?
Is runtime error and exception and the same thing?

Please clarify.

Thanks,
Lovleen.
Stuart Ash
Ranch Hand

Joined: Oct 07, 2005
Posts: 637
This is a general programming concept. Most simply:

A compile-time error is a problem found at compile time.

A runtime error is anything that goes wrong at runtime -- in Java, runtime errors are usually indicated/communicated via exceptions (Throwable and family).


ASCII silly question, Get a silly ANSI.
Mike Petrogeorge
Greenhorn

Joined: Feb 13, 2007
Posts: 3
Well, yea, compile exceptions are caught by the compiler, and runtime exceptions are caught at runtime. But for the test, you gotta know that compile time exceptions are known as checked-exceptions (extend object Exception) and run time exceptions extend RuntimeException (who also extends the Exception). Check the java 5 documentation. You will find that Throwable is the daddy object, Exception extends Throwable and is the main object. Then you have the RuntimeException. Exceptions like NullPointerException and ArithmeticException extend the RuntimeException. Hence runtime exceptions (as far as the test is concerned).
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41116
    
  45
There is no such thing as a "compile exception" or "compile time exception". As Stuart said, there are "compile errors", which the compiler reports (nothing to "catch" here, as as there is no exception involved).

Runtime exception come in checked and unchecked varieties. Checked exceptions need to be treated in the code either by a try/catch block, or a "throws" clause in the method declaration. The compiler will enforce this. Unchecked exception extend java.lang.RuntimeException, and do not need to be treated in the code.


Ping & DNS - my free Android networking tools app
Gaurav Pavan Kumar Jain
Ranch Hand

Joined: Mar 19, 2007
Posts: 168
Hi Loovelen

Runtime Errors are considered as Exceptions in java. Where Compile time errors are simply just errors which occurs due to improper Syntax.

I think it is the answer you want.

Nice question.

 
Don't get me started about those stupid light bulbs.
 
subject: Runtime & Compile time Error
 
Similar Threads
Final Class cannot be instantiated
tricky question
JSP
Giving up too soon....
Var args ... explanation needed