Forums Register Login

compile time and run time error

+Pie Number of slices to send: Send
what are the cases when one is supposed to expect:
1. compile time error
2. run time error
+Pie Number of slices to send: Send
 

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
+Pie Number of slices to send: Send
 

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

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
The really nasty runtime errors occur when the program runs happily and produces the wrong result
+Pie Number of slices to send: Send
thanks everyone.
On top of spaghetti all covered in cheese, there was this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 999 times.
Similar Threads
Compile time Vs Runtime Exception
Help..Compile and Run time Errors..??
KAM India Edition Question 6.27
dan exam doubt 11
error in eclipse
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 15:49:52.