First thanks for the reply...
but let say i remove the private method in class A so it looks like this
when compiled and run it will print the value for "i",
the question is -- isnt this the same as when the print method is private...?
i mean, because when a method or variable that belongs to superclass is private the subclass doesnt see it, as if it doesnt exists. and the print method in Class B is simply just a method that belongs to class B... and not an override of the method in Class A.
[ August 16, 2006: Message edited by: Firman Drage CORRECT ME IF IM WRONG ]
i think the solution is... (looking back to the original code.. -see orginial
thread) when the reference variable
xxx is created its of a type
A and at compile time, the xxx.print() will look for the print() method in class A, and since the print method in class A is private... it naturally say that it cannot find it... but let say, for argument sake, that the method A.print() is public.
At "compile time", xxx.print() sees that the method exist because its public -- also remember that
is saying that xxx is a holder type A but its content is B -- so xxx.print() at "runtime" it will run the print() in B
[ August 16, 2006: Message edited by: Firman Drage ]