tag:blogger.com,1999:blog-8712770457197348465.post4402740063991657419..comments2024-03-18T23:01:42.768-07:00Comments on Javarevisited: Difference between Abstract Class vs Interface in Javajavin paulhttp://www.blogger.com/profile/15028902221295732276noreply@blogger.comBlogger18125tag:blogger.com,1999:blog-8712770457197348465.post-19508429954374029212021-07-08T15:10:41.136-07:002021-07-08T15:10:41.136-07:00"Abstract class comes handy in this case beca..."Abstract class comes handy in this case because you can just define new functionality in abstract super class and every sub class will automatically gets it" - isn't this violating OCP ?<br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-9758456509551484632018-09-28T04:12:44.162-07:002018-09-28T04:12:44.162-07:00Hello Abhishek, yes, will do but meanwhile you can...Hello Abhishek, yes, will do but meanwhile you can check my other post on <a href="http://www.java67.com/2017/08/difference-between-abstract-class-and-interface-in-java8.html" rel="nofollow">Java 8 differences between abstract class and interface </a> . That might help you. javin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-27304580965649068442018-09-27T21:39:27.049-07:002018-09-27T21:39:27.049-07:00Can you please update this post according to java8...Can you please update this post according to java8 implementation JavaCodeGeekhttps://www.blogger.com/profile/07993089861073069066noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-75569123515192423712017-06-14T06:19:57.323-07:002017-06-14T06:19:57.323-07:00what is the difference between abstract class and ...what is the difference between abstract class and interface in java8?<br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-3377563022871229812016-10-16T08:51:35.082-07:002016-10-16T08:51:35.082-07:00"Programming for interfaces than implementati..."Programming for interfaces than implementation is also one of the useful Object oriented design principle which suggests benefit of using interface as argument to function, return type etc."<br /><br />I didn't actually get this. Can you please explain a bit on this?<br />Anonymoushttps://www.blogger.com/profile/10205069577986596685noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-70136868492478875262016-08-30T00:31:54.955-07:002016-08-30T00:31:54.955-07:00This is one of the good OOP Interview question for...This is one of the <a href="http://www.java67.com/2015/12/top-30-oops-concept-interview-questions-answers-java.html" rel="nofollow">good OOP Interview question</a> for Java developers, more important for beginners. Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-71961483730505528352014-09-28T02:15:17.821-07:002014-09-28T02:15:17.821-07:00Fantastic difference !!! A clear distinction betwe...Fantastic difference !!! A clear distinction between abstract class and interface from design perspective.Anonymoushttps://www.blogger.com/profile/04659911514992181895noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-15685352198152241452014-05-28T01:06:41.066-07:002014-05-28T01:06:41.066-07:00Great post, very clear and well explained use scen...Great post, very clear and well explained use scenarios and examples. Thanks a bunch dude!..:: PchiwaN ::..https://www.blogger.com/profile/14153776099108605156noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-12004356277468083442014-03-26T09:36:16.289-07:002014-03-26T09:36:16.289-07:00@Javin on e more short example I want to add ..
...@Javin on e more short example I want to add ..<br /><br /> 7 down vote<br /> <br /><br />I will give you an example first :<br /><br />public interface LoginAuth{<br /> public String encryptPassword(String pass);<br /> public void checkDBforUser();<br />}<br /><br />Now suppose you have 3 databases in your application then each and every implementation for that db need to define the above 2SARAL SAXENAhttps://www.blogger.com/profile/01084233786047386880noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-90708566779585959252014-03-26T09:14:58.280-07:002014-03-26T09:14:58.280-07:00@Javin perfect article , agreed that is most hot q...@Javin perfect article , agreed that is most hot question in java world.!! :) ...lem me add few conclusions points to it...<br /><br />Interface :-<br />-------------<br /> A class can implement multiple interfaces<br /> An interface cannot provide any code at all<br /> An interface can only define public static final constants<br /> An interface cannot define instance variables<br />SARAL SAXENAhttps://www.blogger.com/profile/01084233786047386880noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-10846884125262188852014-02-05T03:34:32.756-08:002014-02-05T03:34:32.756-08:00One should always use interface for declaring Type...One should always use interface for declaring Types and always code against interface than any particular implementation. Recently I had to refactor lot of code, which was dependent on class which implements interface than the interface itself. Programmers was type casting into specific class, even if they are calling public methods of interface, this code was fragile and broke once I have added Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-70408661247075744052013-06-27T00:45:44.345-07:002013-06-27T00:45:44.345-07:00Hello guys, in state design pattern, should we use...Hello guys, in state design pattern, should we use an abstract class or interface for modelling State abstraction? this was asked to me in a recent java interview. I said, concrete class because we definitely wants to provide default implementation of State and let's specific state only overrides methods, which make sense on those state. Please le t me know, if my answer is correct?Gaurinoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-62577757687040656212013-06-03T00:50:33.652-07:002013-06-03T00:50:33.652-07:00My reason of using Abstract class is simple, avoid...My reason of using Abstract class is simple, avoid using interfaces until Java 8 comes with default method implementation. I don't like empty methods and no functional code, which is the case with Java interface.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-64398492701019533632013-05-25T20:55:56.145-07:002013-05-25T20:55:56.145-07:00@Oguzhan Acargil, I sort of agree with you. Interf...@Oguzhan Acargil, I sort of agree with you. Interface in my opinion can represent highest level of abstraction, and abstract class may be with slightly lower than, given they have some sort o implementation, which as you said good for low levels of system architecture.Javin @ puzzle asked in programming interviewshttp://javarevisited.blogspot.com/2013/04/top-10-puzzles-riddles-logical-programming-question-lateral-thinking-interview.htmlnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-52817454949854568582013-05-25T13:12:06.772-07:002013-05-25T13:12:06.772-07:00Well detailed notes about legendary diferrence, th...Well detailed notes about legendary diferrence, thx... my point of view, abstract classes are best fit in low levels of system architecture: persistency, network, web, ui to keep common things under control and reduce redundancy. Interfaces are as is above:) Oguzhan Acargilhttps://www.blogger.com/profile/03971689084568077799noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-18194647174057162462013-05-15T19:46:51.166-07:002013-05-15T19:46:51.166-07:00Great Post Javin. I have faced this question coupl...Great Post Javin. I have faced this question couple of times on interviews, but not able to give proper example, when it comes to choosing interface over abstract class or vice-versa. They always looks similar to me, but I love the way you explain things, If you don't mind, can you take an example and walk though us of using Interface over abstract class, and another example in which abstractParulnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-59383065942777912392013-05-15T11:39:41.207-07:002013-05-15T11:39:41.207-07:00Think the difference between abstract class and in...Think the difference between abstract class and interface may be given point wise. More discussion on their restrictions should be attached.Anonymoushttps://www.blogger.com/profile/05202802538329986043noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-42287084254562858622013-05-15T06:41:30.170-07:002013-05-15T06:41:30.170-07:00When should you use abstract classes and interface...When should you use abstract classes and interfaces? Always. Subclassing makes testing and reasoning about your code more difficult.MCAndrehttps://www.blogger.com/profile/10025555896996100599noreply@blogger.com