• 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
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

compile time and run time error

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what are the cases when one is supposed to expect:
1. compile time error
2. run time error
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

venu chakravorty wrote:1. compile time error


Compiler can catch it. mostly related to syntax validation

venu chakravorty wrote:2. run time error


Compiler cant catch it . mostly related to logic of your program
 
Ranch Hand
Posts: 449
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

seetharaman venkatasamy wrote:
Compiler can catch it. mostly related to syntax validation


Some more examples might be

Typechecking errors
(Rarely) compiler crashes

seetharaman venkatasamy wrote:
Compiler cant catch it . mostly related to logic of your program


Some examples are

Division by zero
Deferencing a null pointer
Running out of memory

 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Compile time error
--------------------------
string s=null;
This will be compile time error because "string" should be of "String"


Run time error
--------------------
ArrayList arr= new ArrayList();
arr.add("1');
arr.add("2');

System.out.println(arr.get(3));

This will be of run time error as arr is having size of 2 only but you are accessing 3rd one.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Compile time errors happens when you attemp to compile your code and the compiler find errors such as undefined variables, missing parenthesis, accessing variables out of scoped or something like that.

Run time errors happens when your program is running and an unchecked exception is thrown such as NullPointerException or ArithmeticException.
 
Marshal
Posts: 76426
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The really nasty runtime errors occur when the program runs happily and produces the wrong result
 
Venu Chakravorty
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks everyone.
 
Your mind is under my control .... your will is now mine .... read this tiny ad
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic