Tuesday, 12 January 2016

Java Tutorial : Java Interface (Duplicate default methods)


Click here to watch in Youtube :
https://www.youtube.com/watch?v=hdIQAA74i2o&list=UUhwKlOVR041tngjerWxVccw

Click the below Image to Enlarge
Java Tutorial : Java Interface (Duplicate default methods)
Java Tutorial : Java Interface (Duplicate default methods)
InterfaceA.java
interface InterfaceA
{
    
    default void sayHello()
    {
        System.out.println("default Hello by InterfaceA...");
    }
}
InterfaceB.java
public interface InterfaceB
{
    default void sayHello()
    {
        System.out.println("default Hello by InterfaceB...");
    }
}
MyClass.java
public class MyClass implements InterfaceA,InterfaceB
{

    public void sayHello()
    {
        System.out.println("Hello by myclass...");
    }
}
InterfaceTest.java
public class InterfaceTest
{

    public static void main(String[] args)
    {
        InterfaceA interfaceARef = new MyClass();
        interfaceARef.sayHello();
        
        System.out.println("----------------------");
        
        InterfaceB interfaceBRef = new MyClass();
        interfaceBRef.sayHello();
        
    }

}
Output
Hello by myclass...
----------------------
Hello by myclass...
Click the below link to download the code:
https://sites.google.com/site/javaee4321/java/InterfaceDemo-DuplicateDefault-App.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/InterfaceDemo-DuplicateDefault-App

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/d3069ae3fffccb0c6ba4336662b6a2619d880c61/BasicJava/InterfaceDemo-DuplicateDefault-App/?at=master

See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • No comments:

    Post a Comment

    Google+ Followers

    Google+ Badge