Abstraction:
We all know that abstraction is one of the characteristics of Object Oriented Programming System (OOPS). If you ask someone "what is abstraction?" the most common possible answer that you hear is .. "Abstraction is hiding some important features or data ..bla ..bla..bla "
The question is ..what is hiding ..? where you are hiding..? which part you are hiding ..?
Is hiding something is the correct definition for abstraction ?
then what it (abstraction) really means?
Here it goes:
In simple words i can say.. "Abstraction implies providing something.. but not everything"
Suppose there is an aeroplane flying in the sky. We know that it is flying, but we don't know how exactly it is flying and what are the underlying mechanisms, working and all.
this is what we are looking for.. "abstraction"
How to achieve Abstraction in Java:
By using abstract classes or interfaces , we can achieve abstraction in Java.
As we all know that abstract classes, interfaces contains abstract methods (ofcourse abstract classes may or may not contain) i.e , only method declarations.
By looking at the method declaration we can estimate what exactly the method is doing, what it is going to return. But we don't know how exactly the abstract method will be implemented.
We came to know about the implementation, once we provided the method implementation in the classes which implement the corresponding abstract class or interface.
Example for the above illustration:
Let us consider an interface ( you can take abstract class also) Addicted.
In the above interface, getAddictedListOfPersons() is the abstract method (by default all the methods in an interface are public abstract ) which returns list of all the addicted persons. By looking at the method declaration we can infer this.
(As per the java documentation we should give proper names to the methods and variables)
But we don't know how exactly the method will be implemented in it's (interface) implementation classes.
Following are the implementation classes for the interface Addicted.
The class AddictedToJava is providing implementation to the abstract method which returns the list of persons who were addicted to Java.
The class AddictedToAndroid is providing implementation to the abstract method which returns the list of persons who were addicted to Android.
Now , by looking at these implementations we came to know that the implementation is different in both of the implementation classes for the interface(Addicted).
Only after providing implementation, we came to know how exactly the method was implemented.
This is considered to be abstraction what i mentioned in the begining of the article.
Abstraction ------> Providing something.. but not everything
you cleared my doubts bro. I was asked the same question in an interview "what are we hiding when we are not implementing any logic in the abstract method".
ReplyDeleteVery informative buddy...
ReplyDeleteNice tutorial...share your knowledge is caring.
ReplyDeletegreat keep it up.but i need some extra information.
ReplyDeleteGreat
ReplyDeleteAbstraction in Java
ReplyDeleteReal life Example of Abstraction
Abstraction shows only important things to the user and hides the internal details. Real life example of abstraction is; we know how to ride the bike but we don't know internal function of bike.
Hello SP, thanks for ur support.
ReplyDeleteI jus got a doubt, is abstraction to the developers or to the end users???
It shud be for the end user only bcz however developers are aware of everything.
If it is for the end user, then an end user even not aware of what is the implementation logic in concrete classes.
So how can I say confidently to the end user that abstraction is achieved only by using abstract classes and interfaces??
Thanks in advance:)
Abstraction is for Implementer who uses your class.
DeleteHello SP, thanks for ur support.
ReplyDeleteI jus got a doubt, is abstraction to the developers or to the end users???
It shud be for the end user only bcz however developers are aware of everything.
If it is for the end user, then an end user even not aware of what is the implementation logic in concrete classes.
So how can I say confidently to the end user that abstraction is achieved only by using abstract classes and interfaces??
Thanks in advance:)
Hi Sajjawathussain,
ReplyDeleteEnd user is the one who consumes the application and who doesn't bother about technical implementation.
So for your question, not only abstraction, all the other OOP properties are for developers only.
To write effective code and for effective utilisation we have all these properties..
The main intention of using abstract classes /interfaces is to have a specific set of methods (which are abstract ) that needs to be implemented in their respective implementation classes in their own way..
Hope you got it.. please feel free to get back in case of any confusion here.
i'm glad that this helped you pratikindia..
ReplyDeletethans for reading this and liking it Rajeswari
ReplyDeletethank you Koyel..
ReplyDeleteHi Pratap,
ReplyDeleteIn continuation to Sajjawathussain question and your reply.
Why this concept is called abstraction when everything is known to the developer and end user doesn't bother about technical details.
Thanks
It's for developer only to reduce the complexity of the design. In abstract class some of the functionality you will implement and some of the functionality will be implemented by the concrete classor some of the method over-riden by concrete class. Ex. HttpServlet is a abstract class. We are extending HttpServlet class and we are overriding doGet() and doPost() method. How these methods are getting called?, How request and response is provided to doGet(req,res) and doPost(req,res) method? we are not aware about that this is abstraction.
ReplyDeletewhat you hide in above example ??In interface you declared a method and provided it's implementation specific to a class implements it.Here what you hide??and how it is helpful?? you can use simply overriding mechanism why to declare it as interface and later to provide implementation??
ReplyDeleteThanks It was helpful for me..!! keep sharing.
ReplyDeleteI have a doubt. in an interview I was asked->
ReplyDeleteIf abstraction is showing and encapsulation is hiding, whats the thin layer separating these two concepts?
One of the best explanation.....
ReplyDeleteHi Pratap,
ReplyDeleteI have a doubt actually. Suppose we want to use the method 'getAddictedListOfPersons()' defined in class 'AddictedToAndroid' , then I have to create the object of the class to use the method as below:
Addicted adJava= new AddictedToAndroid();
And while creating the object, the user will know the class which is implementing the method and will also know how the abstract method is being implemented. And thus there is no hiding from the user i.e. no abstration.
This comment has been removed by the author.
ReplyDeleteGood Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
ReplyDeleter-programming Training in rajajinagar
r-programming Training in bangalore
Rprogramming Training in velachery
Rprogramming online Training
Rprogramming Training
r-programming Training in Bangalore
Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
ReplyDeleterpa training in velachery| rpa training in tambaram |rpa training in sholinganallur | rpa training in annanagar| rpa training in kalyannagar
Great post! I am actually getting ready to across this information, It’s very helpful for this blog.Also great with all of the valuable information you have Keep up the good work you are doing well.
ReplyDeleteData Science course in kalyan nagar | Data Science course in OMR
Data Science course in chennai | Data science course in velachery
Data science course in jaya nagar | Data science training in tambaram
Impressive. Your story always bring hope and new energy. Keep up the good work.
ReplyDeletePython training in marathahalli | Python training institute in pune
Thanks you for sharing this unique useful information content with us. Really awesome work. keep on blogging
ReplyDeletejava training in chennai | java training in electronic city
java training in marathahalli | java training in btm layout
Thanks you for sharing this unique useful information content with us. Really awesome work. keep on blogging
ReplyDeletejava training in chennai | java training in electronic city
java training in marathahalli | java training in btm layout
Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work. R Programming institutes in Chennai | R Programming Training in Chennai
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteAmazing article. Your blog helped me to improve myself in many ways thanks for sharing this kind of wonderful informative blogs in live. I have bookmarked more article from this website. Such a nice blog you are providing ! Kindly Visit Us hadoop training in chennai velachery | hadoop training course fees in chennai | Hadoop Training in Chennai Omr
ReplyDeletebig data training in Velachery | Hadoop Training in Chennai | big data Hadoop training and certification in Chennai | Big data course fees
ReplyDeleteWhen I initially commented, I clicked the “Notify me when new comments are added” checkbox and now each time a comment is added I get several emails with the same comment. Is there any way you can remove people from that service? Thanks.
ReplyDeleteAmazon Web Services Interview Questions And Answers | Best AWS interview questions 2018
Advanced Amazon Web Services Training in Chennai | Best AWS Training Institute in Chennai
Advanced AWS Training Institute in Pune | Best AWS Training Center in Pune
Best AWS Training Institute in Marathahalli | Advanced AWS Training in Marathahalli, Bangalore
Your info is really amazing with impressive content..Excellent blog with informative concept. Really I feel happy to see this useful blog, Thanks for sharing such a nice blog..
ReplyDeleteIf you are looking for any Data science Related information please visit our website Data science courses in Pune page!
Hi,
ReplyDeleteBest article, very useful and well explanation. Your post is extremely incredible.Good job & thank you very much for the new information, i learned something new. Very well written. It was sooo good to read and usefull to improve knowledge. Who want to learn this information most helpful. One who wanted to learn this technology IT employees will always suggest you take Python Certification Course in Bangalore.
very nice post...
ReplyDeleteinplant training in chennai
inplant training in chennai
inplant training in chennai for it
Australia hosting
mexico web hosting
moldova web hosting
albania web hosting
andorra hosting
australia web hosting
denmark web hosting
Thanks for your post.I gained some new important information.I am very happy reading your post.Learn Python,a powerful language used by sites like YouTube and Dropbox.
ReplyDeletepython training in btm Layout
Your resume after a year of the job gains the place at the top position than the others. cursos de ti online
ReplyDeleteWant to do a No.1 Data Science Course in Chennai with a Certification Exam? Catch the best features of Data Science training courses with Infycle Technologies, the best Data Science Training & Placement institutes in and around Chennai. Infycle offers the best hands-on training to the students with the revised curriculum to enhance their knowledge. In addition to the Certification & Training, Infycle offers placement classes for personality tests, interview preparation, and mock interviews for clearing the interviews with the best records. To have all it in your hands, dial 7504633633 for a free demo from the experts.
ReplyDeleteTheir say agreement operation some would. Market exist stock guess.entertainment
ReplyDeleteBursa
ReplyDeleteMersin
izmir
Rize
Antep
8X86F
izmir
ReplyDeleteErzurum
Diyarbakır
Tekirdağ
Ankara
LO1İ
görüntülüshow
ReplyDeleteücretli show
CQ6XH
ankara parça eşya taşıma
ReplyDeletetakipçi satın al
antalya rent a car
antalya rent a car
ankara parça eşya taşıma
FJTWG
istanbul evden eve nakliyat
ReplyDeletezonguldak evden eve nakliyat
adıyaman evden eve nakliyat
bilecik evden eve nakliyat
ankara evden eve nakliyat
FOT
adana evden eve nakliyat
ReplyDeletebolu evden eve nakliyat
diyarbakır evden eve nakliyat
sinop evden eve nakliyat
kilis evden eve nakliyat
CYXİ
ığdır evden eve nakliyat
ReplyDeleteağrı evden eve nakliyat
maraş evden eve nakliyat
diyarbakır evden eve nakliyat
şırnak evden eve nakliyat
P7VPWV
FFBBA
ReplyDeleteManisa Evden Eve Nakliyat
buy testosterone enanthate
Van Evden Eve Nakliyat
Çerkezköy Evden Eve Nakliyat
sustanon for sale
clenbuterol
Trabzon Evden Eve Nakliyat
buy halotestin
oxandrolone anavar for sale
17D41
ReplyDeleteBartın Şehirler Arası Nakliyat
Antalya Rent A Car
Düzce Lojistik
Samsun Şehir İçi Nakliyat
Silivri Cam Balkon
Malatya Şehirler Arası Nakliyat
Kırşehir Parça Eşya Taşıma
Artvin Evden Eve Nakliyat
Elazığ Şehirler Arası Nakliyat
A4046
ReplyDeleteKarabük Parça Eşya Taşıma
Kastamonu Parça Eşya Taşıma
Kütahya Şehirler Arası Nakliyat
Erzincan Evden Eve Nakliyat
Kars Evden Eve Nakliyat
Luffy Coin Hangi Borsada
Çerkezköy Kombi Servisi
Trabzon Şehirler Arası Nakliyat
Zonguldak Evden Eve Nakliyat
E72C0
ReplyDeleteBinance Referans Kodu
Coin Para Kazanma
Linkedin Takipçi Hilesi
Facebook Sayfa Beğeni Hilesi
Discord Sunucu Üyesi Hilesi
Twitter Retweet Satın Al
Tiktok Beğeni Hilesi
Clubhouse Takipçi Satın Al
Kwai Beğeni Hilesi
شركة عزل اسطح بالدرعية ifIOMQTea9
ReplyDeleteشركة مكافحة الصراصير بالجبيل QJFOcu8Bba
ReplyDelete16DE8A8206
ReplyDeletetakipçi satın al
7B06771AC2
ReplyDeletedüşmeyen takipçi satın al