public class Fir extends Test
{
public static void main(String args[])
{
Fir fir = new Fir();
System.out.println(fir);
}
public String toString(String x) throws RuntimeException
{
return "Fir";
}
}
class Test
{
protected String toString(String x) throws NullPointerException
{
return "Test";
}
}
Both classes do not override the toString method appropriately.
Question: Are these methods overriden?
If yes, what about this rule: If the superclass method declares an exception, subclass overridden method can declare same, subclass exception or no exception but cannot declare parent exception. RuntimeException is parent of NullPointerException.
appropriately... they to do override at all!toString()method fromObject, not the one fromTest. My apologies.