for example Class B extends A
.
An object A test= new B (x,y)
;
Then a method that there is only on Class B
is invoked on the test
object.
Will it be a Compile time error or a run time error?
Overall what are the different between both errors.
views:
43answers:
1
+1
A:
It's a compile time error. (See here)
A compile time error is when the compiler can't understand what you wanted to do.
There is a lot of conditions to have a compile-time error but basically it's when the syntax you used either confuses the compiler or isn't valid at all.
Colin Hebert
2010-10-03 19:04:24
How would this be a syntax error? More a "you're using it but I can't prove that it's there" error. But that's still a compiletime error, so I'm just being pedantic :)
delnan
2010-10-03 19:25:50
@delnan, as the Java Language Specification specifies that a method must exist to be called, it's a syntax error for the java language ;)
Colin Hebert
2010-10-03 19:34:51
Thanks Colin. When will it be a runtime error?
gbox
2010-10-04 20:40:10
Well most of the time when the compiler can't detect the error itself and when the syntax is correct but what you want to do isn't (accessing an invalid index of an array for example)
Colin Hebert
2010-10-04 20:47:12