1 public interface CentralPartyCommittee { 2 void partyLeader(); 3 4 }
1 public class StateCouncil { 2 3 void safetyInProduction() { 4 System.out.println("安全生產"); 5 } 6 }
1 public class Province extends StateCouncil implements CentralPartyCommittee { 2 3 @Override 4 public void partyLeader() { 5 System.out.println("我們各省人民一定堅持黨的領導"); 6 } 7 8 void safetyInProduction() { 9 System.out.println("我們各省人民一定按照國務院的指示進行安全生產!"); 10 } 11 }
1 public static void main(String[] args) { 2 3 Province a= new Province(); 4 a.partyLeader(); 5 a.safetyInProduction(); 6 7 }
運行: