tag:blogger.com,1999:blog-694855878384792308.post8437034746294129317..comments2024-03-21T06:26:49.387-07:00Comments on Java67: 5 Difference between Interface and Abstract class in Java? [Answer]javin paulhttp://www.blogger.com/profile/15028902221295732276noreply@blogger.comBlogger25125tag:blogger.com,1999:blog-694855878384792308.post-48102205335321493942021-10-18T21:53:43.531-07:002021-10-18T21:53:43.531-07:00Yes, that's correct, given now you can add bot...Yes, that's correct, given now you can add both static and default methods on interface which is not abstract. I will update, its been pending from quite sometime now. javin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-26542871055400191682021-10-18T21:53:08.197-07:002021-10-18T21:53:08.197-07:00Yes, its needed, given now you can add both static...Yes, its needed, given now you can add both static and default methods on inteface which is not abstract. javin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-76237175575315039282021-10-04T00:29:51.857-07:002021-10-04T00:29:51.857-07:00i think this page must be updated. Java allows you...i think this page must be updated. Java allows you to create non abstract method inside interface tooSreenathhttps://www.blogger.com/profile/04672362669380159404noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-11464848376504445542021-01-15T05:09:27.621-08:002021-01-15T05:09:27.621-08:00Noted, thx for feedback. Noted, thx for feedback. javin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-52924858383145372192021-01-13T08:28:55.148-08:002021-01-13T08:28:55.148-08:00Your explnations is superb , but you write same se...Your explnations is superb , but you write same sentences in first 2 paras again and again and it waste a lot of time ... Anonymoushttps://www.blogger.com/profile/06364182535356311699noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-41319525714451601752020-04-11T22:35:30.238-07:002020-04-11T22:35:30.238-07:00Thanks AskThanks Askjavin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-80766838305606971602020-04-11T08:03:24.559-07:002020-04-11T08:03:24.559-07:00I have been a Java developer for 8 years now. Real...I have been a Java developer for 8 years now. Really well written article on abstract class and interfaceAskanydifferencenoreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-59001839907033476012019-09-27T03:11:09.557-07:002019-09-27T03:11:09.557-07:00Hi Javin,Can you please update all your blog as pe...Hi Javin,Can you please update all your blog as per current java changes. Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-70807248793425087582016-09-13T19:15:39.170-07:002016-09-13T19:15:39.170-07:00Hi Javin,
Can you please explain the real time sce...Hi Javin,<br />Can you please explain the real time scenario when we use interface and abstract class.<br />I'm not clear with the answer given to Raman.<br />Thanks a lotAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-43262903734007340492016-08-20T00:19:30.030-07:002016-08-20T00:19:30.030-07:00Use abstract class if you want to provide a Skelet...Use abstract class if you want to provide a Skeleton class e.g. AbstractList class from java.util package, while use interface to define public API e.g. List is an interface and AbstractList is an abstract class. The List allows you to use List in a flexible way and AbstractList allows developer to create a new implementation of List easily.javin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-72482657807907742272016-08-20T00:17:49.716-07:002016-08-20T00:17:49.716-07:00Indeed, but that's the half of the story, you ...Indeed, but that's the half of the story, you want others to extend your class before use, that's the meaning of abstract class e.g. your servlet should extend HttpServlet and implement doGET(), doPost() methods etc.javin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-71993664484415905742016-08-20T00:16:41.042-07:002016-08-20T00:16:41.042-07:00@Anonymous, from Java 8 onward, interface can incl...@Anonymous, from Java 8 onward, interface can include static methods.javin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-32538807760940517742016-08-20T00:16:01.590-07:002016-08-20T00:16:01.590-07:00@Anonymous, From Java 8 Onwards interface is not c...@Anonymous, From Java 8 Onwards interface is not completely abstract i.e. they can also have code in form of static and default methods. That actually blur the difference between abstract class and interface but still you can implement multiple interface but only extend one class. javin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-36927309497368398692016-08-20T00:14:39.002-07:002016-08-20T00:14:39.002-07:00@Aulo, good catch, thanks for pointing out, indeed...@Aulo, good catch, thanks for pointing out, indeed "interface" is the keyword to declare interface in Java. javin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-57838890927041794072016-08-19T22:27:36.194-07:002016-08-19T22:27:36.194-07:00Typo found, there in the picture, should read: &qu...Typo found, there in the picture, should read: "To declare an interface, use interface keyword".Aulohttps://www.blogger.com/profile/10622265450927302820noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-49927907639961151842014-07-24T18:55:52.618-07:002014-07-24T18:55:52.618-07:00In an interface we cannot define static methods an...In an interface we cannot define static methods and can only define public static final <br />variablesAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-80735812800829830262014-01-30T04:21:49.528-08:002014-01-30T04:21:49.528-08:00This is all going to change in Java 1.8. the intro...This is all going to change in Java 1.8. the introduction of Functional interfaces changes the differences listed here :)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-22725785253823052032014-01-23T05:00:37.567-08:002014-01-23T05:00:37.567-08:00If we don't want to allow anybody to create th...If we don't want to allow anybody to create the object to our class,then we should go for abstract class.<br />Ex:HttpServlet.<br />Anonymoushttps://www.blogger.com/profile/10197775024427374246noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-71683582315783883792013-08-12T05:23:40.989-07:002013-08-12T05:23:40.989-07:001. A class can implement more than one interface(M...1. A class can implement more than one interface(Multiple Inheritance is possible with interface). But A class can not extend more than one abstract class(Multiple Inheritance is not possible with class).<br /><br />2. If You want to add a new method in interface, you need to implement that method in all the classes that implementing the interface. But if you want to add a new method in abstract class, you can add it as a non abstract method. You don't need to implement it in all the classes that extending the abstract class.<br /><br />3. Interface don't have constructors. But Abstract class has constructors.<br /><br />Prathap<br /><a href="http://wisentechnologies.com/it-courses/java-training.aspx" title="java training in chennai" rel="nofollow">Java training in chennai</a>dehttps://www.blogger.com/profile/03263826785097470489noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-71673162646171370482013-08-07T00:22:49.295-07:002013-08-07T00:22:49.295-07:00i don't understand where we use interface and ...i don't understand where we use interface and where we use abstract class ?Ramanhttps://www.blogger.com/profile/13007562269545419922noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-43964110975838897192013-05-17T07:40:27.272-07:002013-05-17T07:40:27.272-07:00Thank u... It s very useful for me.Thank u... It s very useful for me.Dhivyahttps://www.blogger.com/profile/05484682884702497924noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-67120225067242954012013-04-23T23:47:42.831-07:002013-04-23T23:47:42.831-07:00i lerned very well by IT?????????? i lerned very well by IT?????????? BALuhttp://www.facebook.com/pages/Dude/607788632580701?ref=hlnoreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-16807884611732919082013-03-31T12:34:59.173-07:002013-03-31T12:34:59.173-07:00thanks a lotthanks a lotAnonymoushttps://www.blogger.com/profile/02102487729575784317noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-54214119648386392022012-12-19T20:27:07.176-08:002012-12-19T20:27:07.176-08:00Thanks dude really helpful ....Thanks dude really helpful ....Aditya Chttps://www.blogger.com/profile/03998990972552911166noreply@blogger.comtag:blogger.com,1999:blog-694855878384792308.post-1001483195239163692012-10-24T16:49:19.288-07:002012-10-24T16:49:19.288-07:00Great post - very informative. I found this page ...Great post - very informative. I found this page to be very helpful as well:<br /><br />http://www.programmerinterview.com/index.php/java-questions/interface-vs-abstract-class/Anonymousnoreply@blogger.com