Java Programming Ideas Fourth Edition Nineth Chapter

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.