i tried the following code:
package p1;
public class xp1
{
final void aMethod()
{
System.out.println("p1 aMathod");
}
}
package p2;
import p1.xp1;
public class yp2 extends xp1
{
void aMethod()
{System.out.println("p2 aMathod");}
public static void main(
String args[])
{
yp2 obj= new yp2();
obj.aMethod();
}
}
on compiling yp2 the following WARNING results:
"Method void aMethod() in class p2.yp2 does not override the
corresponding method in class p1.xp1. If you are trying to override this method, you cannot do so because it is private to a different package."
final methods cannot be overriden anyway, so it is valid for void aMethod(){} to appear in the subclass in a different package, as, it is being declared again and not overridden.
i would say that's an error in the RHE exam answer, unless somebody has a better reason to say it is correct.