posted 20 years ago
Answers : d,e,f
I understand the d and the e...but why is it a compiler error at line 4
Also the explanation to the answer is as follows:
At line 2, the statement, "return i;", contains the expression, i. The enclosing method, m2, is declared void. The return statement generates a compile-time error, because it contains an expression. At line 3, the statement, "return;", does not contain an expression. The enclosing method, m3, is declared with the result type, int. The return statement generates a compile-time error, because it does not contain an expression that produces a value that is assignable to the declared result type.
Thanks
[ August 14, 2004: Message edited by: Murtuza Akhtari ]