. Write 2 interfaces:interfacea and interfaceb; in interface interfacea there's a way. void
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.
Interfacea interface package alphabet; public interface Interfacea {void Printcapitalletter ();}
Intfaceb interface package alphabet; public interface Interfaceb {void Printlowercaseletter ();}
Print class package alphabet; public class Print implements Interfacea, Interfaceb {@Overridepublic void Printcapitalletter () { System.out.println ("A,b,c,d,e,f,g,h,i,g,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z");} @Overridepublic void Printlowercaseletter () {System.out.println ("a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x, Y,z ");}}
Main class Epackage alphabet; public class E {public static void main (string[] args) {interfacea a=new Print (); A.printcapitalletter (); Interfaceb b=new Print (); B.printlowercaseletter ();}}
Run results
The alphabet of Java object-oriented exercises polymorphism