Assume there is a code as such:
package com.ps.Sample;
public interface Sample
{
public void Method1();
}
public abstract class AbstractSample implements Sample
{
public void Method1()
{
System.out.println("Hello World");
}
}
public class MySample extends AbstractSample
{
}
public class TestSample
{
public static void main(String[] args)
{
Sample my = new MySample();
my.Method1();
}
}
My question is:
Is there any benefit to declaring the concrete class as
public class MySample extends AbstractSample implements Sample
instead of
public class MySample extends AbstractSample
No, there is not. It’s redundant. AbstractSample is a Sample, and MySample is a AbstractSample. So MySample is a Sample.
The javadoc displays all the implemented interfaces anyway, whether you add the
implements Sampleor not.