Exercise 14: Create three interfaces with two methods per interface. Inherits an interface that combines these three interfaces and adds a new method. Create a class that implements the new interface and inherits a specific class. Now write four methods, each of which accepts one of these four as a parameter. In the main () method, create an object of this class and pass it to the four methods.
Package Inter;public class Test {public static void main (string[] args) {d d=new D ();d. A (d);d. B (d);d. C (d);d. ABC (d);} Interface A{void A1 (); void A2 ();}; Interface B{void B1 (); void B2 ();}; Interface C{void C1 (); void C2 ();}; Interface ABC extends a,b,c{void ABC ();} Class E{};class D extends E implements Abc{public void A (a a) {System.out.println ("A.class"); a.a1 (); A.a2 ();} public void B (b b) {System.out.println ("B.class"); B.b1 (); B.b2 ();} public void C (c c) {System.out.println ("C.class"); C.c1 (); C.c2 ();} public void ABC (ABC abc) {SYSTEM.OUT.PRINTLN ("Abc.class"); Abc.abc ();} @Overridepublic void A1 () {//TODO auto-generated Method StubSystem.out.println ("A1 ()");} @Overridepublic void A2 () {//TODO auto-generated Method StubSystem.out.println ("A2 ()");} @Overridepublic void B1 () {//TODO auto-generated method StubSystem.out.println ("B1 ()");} @Overridepublic void B2 () {//TODO auto-generated method StubSystem.out.println ("B2 ()");} @Overridepublic void C1 () {//TODO auto-generated method StubSystem.out.println ("C1 () ");} @Overridepublic void C2 () {//TODO auto-generated method StubSystem.out.println ("C2 ()");} @Overridepublic void ABC () {//TODO auto-generated method StubSystem.out.println ("ABC ()");}}
Java Programming Ideas Fourth Edition Nineth Chapter