Write 2 interfaces:interfacea and interfaceb; in interface interfacea There is a method void in the
Printcapitalletter (); there is a method in interface interfaceb void printlowercaseletter () ; then
Write a class print Implementation interface Interfacea and interfaceb, require print Capitalletter () method
Implements the output uppercase English alphabet function, theprintlowercaseletter () 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 the interfacea variable a, Object a calls print Capitalletter method; Finally again in the main class E
The main method creates the Print object and assigns a value to the variable bof the interfaceb Object b call
Printlowercaseletter method.
Package Lianxi; Public Interface interfacea { void printcapitalletter ();}
Package Lianxi; Public Interface interfaceb { void printlowercaseletter ();}
PackageLianxi; Public classPrintImplementsInterfacea, Interfaceb {@Override Public voidPrintlowercaseletter () {System.out.println ("Lower case Alphabet"); for(CharC= ' a '; c<= ' z '; C + +) {System.out.print (c+" "); } System.out.println (); } @Override Public voidPrintcapitalletter () {System.out.println ("Capital Table"); for(Charc= ' A '; c<= ' Z '; C + +) {System.out.print (c+" "); } System.out.println (); }}
Package Lianxi; Public class Q { publicstaticvoid main (string[] args) { Print a=new Print (); A.printcapitalletter (); Print b=new print (); B.printlowercaseletter (); }}
Java Basic Practice Writing 2 interfaces