Hi,
Question 49 in exam Bonus 1 says:
Consider the following class definition:
public class Parent {
final void zzz() { }
}
Which of the following methods may appear in a subclass of Parent, when the subclass is in a different package from Parent?
The option A) void zzz() { } is given as wrong.
I know final methods cannot be overriden, but these two source files compiled successfully:
<pre>
package p1;
public class X{
final void aMethod(){}
}
</pre>
<pre>
package p2;
import p1.X;
public class Y extends X{
void aMethod(){}
}
</pre>
I supose it compiled because class Y cannot see aMethod() in X. It is the same as when I can declare a method with the same name and argument list that another final and private one in a superclas. Please correct me if I am wrong.
And shouldn't answer A be given as correct then?
Thank you
[This message has been edited by Mafalda Alabort (edited March 25, 2001).]
[This message has been edited by Mafalda Alabort (edited March 25, 2001).]