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) |
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..."); } }
public class AbstractClassTest { public static void main(String[] args) { A aRef = new MyClass(); aRef.sayWelcome(); aRef.sayHi(); aRef.sayBye(); } }
Welcome... Hi... Bye...
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:
No comments:
Post a Comment