Java Basic Interface Exercises

Source: Internet
Author: User

Write 2 interfaces: Interfacea and INTERFACEB; there is a method void in the interface interfacea

Printcapitalletter (); In interface Interfaceb there is a method void Printlowercaseletter ();

After writing a class print implementation interface Interfacea and INTERFACEB, requires the Printcapitalletter () method

Implements the output capital English alphabet function, the Printlowercaseletter () method implements the output lowercase English

The function of the alphabet. Write a main class E, create the Print object in the main method of the primary class E, and assign

The value given to Interfacea is variable A, object A calls the Printcapitalletter method, and finally in the main class E

The Main method creates a print object and assigns a value to the variable B of INTERFACEB, which is called by object B

Printlowercaseletter method.

Package com.chuoji.text01;  Public Interface interfacea {    void  printcapitalletter ();        }
Package com.chuoji.text01;  Public Interface interfaceb {    void  printlowercaseletter ();    }
Package com.chuoji.text01; Public classPrint implements Interfacea, Interfaceb {@Override Public voidPrintlowercaseletter () {System. out. println ("abcdefghijklmnopqistuvwxyz"); } @Override Public voidPrintcapitalletter () {System. out. println ("ascdefghijklmnopqrstuvwxyz"); }}
Package com.chuoji.text01;  Public class E {    publicstaticvoid  main (string[] args) {        interfacea a=  New  Print ();        Interfaceb b=new  Print ();        B.printlowercaseletter ();        A.printcapitalletter ();            }}

Java Basic Interface Exercises

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.