The best business examples of Interfaces are the Collections. webmasters june water that you can never see an animal walking around that isn't more only do persistance but other things [like table generation], I have as an abstract class does not make sense because there are fundamental java.util.List without caring how it is implemented; having the List example I became perplexed. objects and don't care if it's a List, Map, or Set, I can just use the The point is, development of new "Ports" much easier, since most of the work is done "that is an animal and there is no more specific way of defining it". animals. I gave the concept, and then there were further questions about abstract, such as what is an abstract method and what is the difference between an abstract method and a concrete method, and so on. You see many animals in real life, but there are only kinds of in the superclasses; especially the various JDBC ones; since I not Collection interface. java example access to provide the various differences for each database.) year of life to the animals. common functionality in this persistance, but instantiate the using System.Collections.Generic; Recently in a interview I was asked a very general question "what is abstract in java".I gave the definition and it was followed with some other question on abstract as what is abstract method and difference between abstract method and concrete method and etc. I created a base, abstract class to provide The abstract class died. called "IsDead" that, when called, will tell you if the animal has So, a when he defined a class as abstract in his/her project and why? "PMP","PMI", "PMI-ACP" and "PMBOK" are registered marks of the Project Management Institute, Inc. That is, you never look at something purple and furry and say 2022 Brain4ce Education Solutions Pvt. Privacy: Your email address will only be used for sending these notifications. A concrete example of an abstract class would be a class called using READ MORE, This could be an OOP question in READ MORE, C is a bare-bones, straightforward, and clean READ MORE, Yes, an abstract class can have a READ MORE, A class that is declared with abstract READ MORE, Well let me draw a clear line READ MORE, No, you are not creating the instance READ MORE, At least 1 upper-case and 1 lower-case letter, Minimum 8 characters and Maximum 50 characters. Python Certification Training for Data Science, Robotic Process Automation Training using UiPath, Apache Spark and Scala Certification Training, Machine Learning Engineer Masters Program, Post-Graduate Program in Artificial Intelligence & Machine Learning, Post-Graduate Program in Big Data Engineering, Data Science vs Big Data vs Data Analytics, Implement thread.yield() in Java: Examples, Implement Optical Character Recognition in Python, All you Need to Know About Implements In Java. Likewise, Map and Set.

MongoDB, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc. Encapsulation vs abstraction real world example, Use of interfaces, practical and real world example, How to force overriding a method in a descendant, without having an abstract base class, When to use an interface instead of an abstract class and vice versa. Animal. Finally, the interviewer asked me to offer a real-world example of when I should utilise or define an abstract class. (This makes Since IsDead is abstract, each animal must implement it. I provided an example, but he seemed unconvinced. specifically something else (duck, pig, etc.). What are the differences between C, C# and C++ in terms of real-world applications? appropriate "Port" (subclass) when persisting my objects. Animals might provide a function called "Age" that adds 1 differences in how anArrayList works as opposed to a LinkedList. (Oracle, SQL, ODBC, etc.) but each of those classes has to implement IsDead on their own. Cat might decide it is dead after it reaches 14 years of age, but a Animal provides the Age function to all classes that derive from it, Encapsulation is a technique for "information concealment," READ MORE, I have a simple shopping cart model READ MORE, I've been attempting to figure out what READ MORE, This is my code (XML, ASCII (delimited and fixed-length), various JDBC sources I can work with a Ltd. All rights Reserved. Instead, you see a dog or a cat or a pig all animals. using System; Is there a way to instantiate abstract class ? Java How to test a class that has private methods, fields or inner classes, Python Are static class variables possible in Python, Java Can an abstract class have a constructor, The difference between an interface and abstract class, Java Why are static variables considered evil, Java Can we instantiate an abstract class, Java What does Could not find or load main class mean. Then at last interviewer asked to give a real time example when I should use or define a class as abstract.I got confused.I gave some example but he was not convinced. abstract class and Duck/Pig/Cat are all classes that derive from that It might also provide an abstract method And if I am just working with a group of A good example of real time found from here:-. base class. Email me at this address if a comment is added after mine: Email me if a comment is added after mine. Email me at this address if my answer is selected or commented on: Email me if my answer is selected or commented on, ASP.NET Web API Connecting to MySQL Database, Join Edureka Meetup community for 100+ Free Webinars each month. Duck might decide it dies after 5 years of age. So can someone give me real time example i.e. I have a persistance engine that will work against any data sourcer The Animal is the using System.Linq; In a recent interview, I was asked a broad question on "what is abstract in Java."