public interface MyInterface{
void method1();
void method2();
void method3();
}
抽象父类
public abstract class Parent implements MyInterface{
@Override
public void method1(){
}
@Override
public void method2(){
}
@Override
public void method3(){
}
}
在你的儿童课上
public class Child1 extends Parent{
@Override
public void method1(){
}
}
public class Child2 extends Parent{
@Override
public void method2(){
}
}
ex--- instead of implementing Servlet(I) if we extends GenericServlet(AC) then we provide implementation for Service()method we are not require to provide implementation for remaining meyhod..
interface Test {
void m() throws NullPointerException;
}
class Parent {
// Parent class doesn't implements Test interface
public void m() {
System.out.println("Inside Parent m()");
}
}
class Child extends Parent implements Test {
}
public class Program {
public static void main(String args[]) {
Child s = new Child();
s.m();
}
}