Romba Chinna Thambi
Originally posted by vidya:
[B]class Tester {
public static void main(String[] args) {
System.out.println(new Sub().g()); }
int g() { return f(); }}
class Sub extends Tester {
public int f() { return 1; }
}
Well in my opinion the call to Sub().g() makes the compiler to check g() method in the Sub class and finds it(since it's inherited) , so no problem.
but the call to f() method is not associated with any refernce so the compiler checks for the method in Tester class which it does not find ,there is no way for the compiler to know that there is f() method present in Sub class ,so it shows .
if a reference of Sub class invokes the f() method or if there is a superclass of Tester implementing f() method then the compiler can be made to stop screaming.
please do comment to correct me if i am not Right!
satish varanasi
[This message has been edited by Satish Varanasi (edited August 13, 2000).]
Originally posted by Satish Varanasi:
Originally posted by vidya:
[B]class Tester {
public static void main(String[] args) {
System.out.println(new Sub().g()); }
int g() { return f(); }}
class Sub extends Tester {
public int f() { return 1; }
}
Well in my opinion the call to Sub().g() makes the compiler to check g() method in the Sub class and finds it(since it's inherited) , so no problem.
but the call to f() method is not associated with any refernce so the compiler checks for the method in Tester class which it does not find ,there is no way for the compiler to know that there is f() method present in Sub class ,so it shows .
if a reference of Sub class invokes the f() method or if there is a superclass of Tester implementing f() method then the compiler can be made to stop screaming.
please do comment to correct me if i am not Right!
satish varanasi
[This message has been edited by Satish Varanasi (edited August 13, 2000).]
Jayakumar Thirumalai
Jayakumar Thirumalai
"I'm not back." - Bill Harding, Twister
Those cherries would go best on cherry cheesecake. Don't put those cherries on this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|