Monday 15 February 2016

Java Tutorial : Java abstract class(implements interface by abstract class)


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

Click the below Image to Enlarge
Java Tutorial : Java abstract class(implements interface by abstract class) 
MyClass.java
interface A
{
    void sayWelcome();

    void sayHi();

    void sayBye();
}

/*
 * The abstract class can also be used to provide some
 * implementation of the interface. In such case, the end
 * user may not be forced to override all the methods of the
 * interface.
 */
abstract class B implements A
{

    @Override
    public void sayWelcome()
    {
        System.out.println("Welcome...");
    }

}

public class MyClass extends B
{

    @Override
    public void sayHi()
    {
        System.out.println("Hi...");

    }

    @Override
    public void sayBye()
    {
        System.out.println("Bye...");
    }

}
AbstractClassTest.java
public class AbstractClassTest
{

    public static void main(String[] args)
    {
        A aRef = new MyClass();
        aRef.sayWelcome();
        aRef.sayHi();
        aRef.sayBye();
        
    }

}
Output
Welcome...
Hi...
Bye...
Click the below link to download the code:
https://sites.google.com/site/javaee4321/java/AbstractClassDemo_Interface_Impl_App.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/AbstractClassDemo_Interface_Impl_App

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/616eaf1c2bb4551c34e3415baa3ee3135766bffc/BasicJava/AbstractClassDemo_Interface_Impl_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