• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Runtime & Compile time Error

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whats the difference between runtime error and compile time error?
Is runtime error and exception and the same thing?

Please clarify.

Thanks,
Lovleen.
 
Ranch Hand
Posts: 637
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic