• 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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

How to find whether a compile OR a runtime Error

 
Ranch Hand
Posts: 274
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are loads of questions with options having both "compile-time" as well as "runtime" errors. I get confused whether a piece of code will give either compile-time" or "runtime" error.

Is there any way to get to know if it will be a compile-time" or "runtime" error?

If not how to decide upon this?

I hope i'm not asking a silly question here

regards,
gitesh
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Gitesh,

In general compile time errors means your application/.java file won't compile, so you won't be able to run it and therefore won't get any runtime errors. A compile time error usually consists of syntax errors, or importing (or lack there of) of packages and such.

ex:
String s = "wow";
s.delete(1,2); //won't compile because delete doesn't exist in String

Runtime errors are errors that can not be caught in compile time, like indexOutOfBounds, division by zero, etc. These errors typically occur because of certain end cases that are not handled.

ex:
System.out.println(args[8]); //this could throw an IndexOutOfBoundException

I hope that helps...
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Compile time - Syntax checks.
Run Time - Semantics Checks.
 
Ranch Hand
Posts: 1609
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First thing you can always do for the exam is that check for choices in the given answers/options, if there is a choice for 'compile-time error' then you need to hunt for its possibility in the code, else you can start following through the logic. I dont think there are any runtime errors, only runtime exceptions on exam.
 
Gitesh Ramchandani
Ranch Hand
Posts: 274
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Noam,Kishore and Akhilesh. I will follow your advice.
 
Just the other day, I was thinking ... about this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic