Java基础-接口.编写2个接口:InterfaceA和InterfaceB;在接口InterfaceA中有个方法void printCapitalLetter();在接口InterfaceB中有个方法void printLowercaseLetter();然 后写一个类Print实现接口InterfaceA和InterfaceB,要求 方法 实现输出大写英文字母表的功能,printLowerca

#34.编写2个接口:InterfaceA和InterfaceB;在接口InterfaceA中有个方法void

printCapitalLetter();在接口InterfaceB中有个方法void printLowercaseLetter();然

后写一个类Print实现接口InterfaceA和InterfaceB,要求      方法

实现输出大写英文字母表的功能,printLowercaseLetter()方法实现输出小写英文

字母表的功能。再写一个主类E,在主类E的main方法中创建Print的对象并赋

值给InterfaceA的变量a,对象a调用printCapitalLetter方法;最后再在主类E

的main方法中创建Print的对象并赋值给InterfaceB的变量b,对象b调用

printLowercaseLetter方法。

package hanqi;

public interface InterfaceA {
    
    void    printCapitalLetter();

}
package hanqi;

public interface InterfaceB {

    void printLowercaseLetter();
}
package hanqi;

public  class Print implements InterfaceA, InterfaceB {
    
    public void printLowercaseLetter()
    {
        System.out.println("abcdefg");
    }
     
    public void printCapitalLetter()
    {
        System.out.println("ABCDEFG");
    }
    

}
package hanqi;

public class TestJiekou {

    public static void main(String[] args) {
        
        Print c= new Print();    
        InterfaceA a = new Print();
        a.printCapitalLetter();
        InterfaceB b = new Print();
        b.printLowercaseLetter();;
        
    }
}

 

posted @ 2016-09-26 23:01  张好好  阅读(2592)  评论(0编辑  收藏  举报