Real world example for Abstract Class in java
Abstract class is a class that contains abstract method and non abstract methods. Sub class which extends the abstract class "must" implements the abstract methods in the abstract class.
For examples.
Let us consider animal as our abstract class. I wrote 2 function in it. One breath() , breath is a non abtract method.
please consider every animal breath in a common way. so i write some code inside the function breath(). let it be a "Through respiratory system"
second function is a abstract method lifespan(), lifespan is different for each types of animals.
now consider sub class as dog , cat and ant
these class extends that abstract class. The relation ship will come in this way like dog is an animal, cat is a animal ..."is - a" relation ship
since the sub class extends the base class animal.. we need to define lifespan() function in each subclass.
lifespan() is different for each animal
for cat its 25, dog 22 and ant 3.
while i create an object Animal a = new cat();
a.breath() will return me "Through respiratory system" and
a.lifespan() will return me 25
if i create an object Animal a = new dog();
a.breath() ----> "Through respiratory system"
a.lifespan() -----> 22
got it !!!!
Thanking you...................
Wonder-full...!!!!
ReplyDeleteThanks Padmanabham Vishwakarma
DeleteThen what it the difference from the concept of interface?
ReplyDeleteOnly abstract methods are used.
Deletehttp://javabelazy.blogspot.in/2012/01/how-to-reduce-coupling-in-java.html
Understood the concept. Thank u so much
ReplyDeletegood explanation
ReplyDeleteamazing explanation.............give the list of java interview question list with the best real life example.
ReplyDeletehttp://javabelazy.blogspot.in/2012/11/find-missing-number-in-sequence.html
DeleteLike this (aptitude questions)
good explanation
ReplyDeleteThanks Ankit
DeleteHey there! Someone in my Facebook group shared this website with us so I came to give
ReplyDeleteit a look. I'm definitely enjoying the information. I'm book-marking
and will be tweeting this to my followers! Excellent blog and terrific
design.
Look into my webpage - frontier internet service provider
I am in fact pleased to glance at this blog posts which carries lots of useful information, thanks for providing these kinds of statistics.
ReplyDeleteReview my web site - www.prbuzz.com
Hello my family member! I wish to say that this post
ReplyDeleteis amazing, great written and include approximately all important infos.
I'd like to peer more posts like this .
Also visit my page: www.sbwire.com
my page :: www.emailwire.com
If you are going for finest contents like me,
ReplyDeletesimply go to see this site all the time since
it offers quality contents, thanks
my web-site :: http://www.emailwire.com/
My web site > http://www.sbwire.com
I am genuinely delighted to glance at this website posts which includes plenty of useful facts, thanks for providing these data.
ReplyDeletemy blog post ... frontier wireless internet
Also see my web page: emailwire.com
Excellent !!! Understood the concept clearly ! :)
ReplyDeleteHello thеrе! Do уou use
ReplyDeleteTωitter? I'd like to follow you if that would be ok. I'm undoubtedly
enjoying yоur blog and look forward to neω posts.
Tаke а look at my ωebsitе - diamondlinks review