Professional Documents
Culture Documents
What Are The Oops Concept in Java Explain With Real Time Examples
What Are The Oops Concept in Java Explain With Real Time Examples
wh at are t h e oops con cept in java explain wit h real t im e exam ples
AdvertiseyourBusinessHere
Testimonials
ReferthisSite
Login|SignUp
Categories>>Software>>JavaRelated>>JavaJ2EE>>CoreJava
CoreJava
Question
(1808)
Advanced
whataretheoopsconceptinjavaexplainwithrealtime
examples
QuestionSubmittedBy::CoreJava
Java(34 8)
IalsofacedthisQuestion!!
Swing(4 5)
EJB(134 )
Answer
PostedBy
AnswerswereSortedbasedonUser'sFeedback
Servlets
(256)
Struts(198)
JDBC(188)
JMS(89)
SunOne(10)
J2EE(73)
Weblogic
Answer
#1
OOPSConceptsaremainly4
1.Abstraction
2.Encapsulation
3.Inheritance
4 .Polymorphisam
Abstraction:Hiddingnonessential
featuresandshowingthe
essentialfeatures
chandramouli
(152)
Websphere
(14 )
(or)
Hiddingunnecessarydatafromthe
usersdetails,iscalled
h t t p://www.allin t erview.com /sh owan swers/5 945 9/wh at -are-t h e-oops-con cept -in -java-explain -wit h -real-t im e-exam ples.h t m l
1/15
5 /24/2016
Java
Networking
(20)
JavaJ2EE
AllOther(86)
wh at are t h e oops con cept in java explain wit h real t im e exam ples
abstraction.
RealTimeexample:TVRemoteButton
inthatnumberformatandpower
buttonsandotherbuttons
there.justweareseeingthebutttons,we
don'tseethe
buttoncircuits.i.ebuttonscircutesand
wiringsallare
hidden.soithinkitsgoodexample.
Encapsulation:
WritingOperationsandmethodsstored
inasingle
class.ThisisCalledEncapsulation
RealTimeExample:MedicalCapsuals
i.eonedrugisstoredinbuttomlayer
andanotherdrugis
storedinUpperlayerthesetwolayers
arecombinedin
singlecapsual.
Inheritance:
TheNewClassisExistingfromOld
Class,i.eSubClassis
ExistingfromSuperClass.
RealTimeExample:
FatherandSonRelationship
Polymorphisam:
SinleFormbehavingdiffreantlyin
diffreant
Situations.
Example:
Person
PersoninHomeactishusband/son,
inOfficeactsEmployer.
inPublicGoodCityzen.
Ithinktheseallarerealtime
experianceany.isthereany
h t t p://www.allin t erview.com /sh owan swers/5 945 9/wh at -are-t h e-oops-con cept -in -java-explain -wit h -real-t im e-exam ples.h t m l
2/15
5 /24/2016
wh at are t h e oops con cept in java explain wit h real t im e exam ples
moreanswerssendmemymailalso.
Thanksall
CM
IsT his
Answer
Correct
?
1206
Yes
66
No
submit
Answer
#2
Encapsulation
raja
Abstraction
polymorphisms
inheritance/delegation
IsT his
Answer
Correct
?
584
Yes
110
No
submit
Answer
#3
1)Abstraction:
ramya
Abstractionisawaytoremovethe
associationofthe
behaviorofanobjectwiththeactual
detailsbehindthe
sceneswhichimplementthatobject's
behavior.This
'abstraction'isusuallyaccomplished
throughtheuseof
baseclasseswithvirtualfunctions
eachderivedfunction
providesthedetailsthatimplementthe
behaviorbehindthat
abstraction.
eg/weinventedflightbasedonthe
h t t p://www.allin t erview.com /sh owan swers/5 945 9/wh at -are-t h e-oops-con cept -in -java-explain -wit h -real-t im e-exam ples.h t m l
3 /15
5 /24/2016
wh at are t h e oops con cept in java explain wit h real t im e exam ples
mechanismofBirds.So
flightisderivedformthebaseofbirds.
2)Encapsulation:
Itisaprocessofbindingorwrapping
thedataandthe
codesthatoperatesonthedataintoa
singleentity.This
keepsthedatasafefromoutside
interfaceandmisuse.One
waytothinkaboutencapsulationisas
aprotectivewrapper
thatpreventscodeanddatafrombeing
arbitrarilyaccessed
byothercodedefinedoutsidethe
wrapper.
eg/Inkistheimportantcomponentin
penbutitishiding
bysomeothermaterial
3)Polymorphism:
asinglefunctionorsingleoperatorhas
differentcharacter
indifferentplace.
eg/Agirlplaysaroleofdaughterat
homeandamanagerat
office
4 )Inheritance:
Thenewclasses,knownasderived
classes,takeover(or
inherit)attributeandbehaviorofthe
preexistingclasses,
whicharereferredtoasbaseclasses
(orParentclasses).
Itisintendedtohelpreuseexisting
codewithlittleorno
modification.
eg/parentchildrelation
h t t p://www.allin t erview.com /sh owan swers/5 945 9/wh at -are-t h e-oops-con cept -in -java-explain -wit h -real-t im e-exam ples.h t m l
4/15
5 /24/2016
wh at are t h e oops con cept in java explain wit h real t im e exam ples
IsT his
Answer
Correct
?
187
Yes
63
No
submit
T witter
Answer
#4
OOPSConceptsaremainly4
1.Abstraction
2.Encapsulation
3.Inheritance
4 .Polymorphisam
Abstraction:Hiddingnonessential
featuresandshowingthe
essentialfeatures
devendra.m
(or)
Hiddingunnecessarydatafromthe
usersdetails,iscalled
abstraction.
RealTimeexample:TVRemoteButton
inthatnumberformatandpower
buttonsandotherbuttons
there.justweareseeingthebutttons,we
don'tseethe
buttoncircuits.i.ebuttonscircutesand
wiringsallare
hidden.soithinkitsgoodexample.
Encapsulation:
WritingOperationsandmethodsstored
inasingle
class.ThisisCalledEncapsulation
RealTimeExample:MedicalCapsuals
i.eonedrugisstoredinbuttomlayer
andanotherdrugis
storedinUpperlayerthesetwolayers
arecombinedin
singlecapsual.
Inheritance:
h t t p://www.allin t erview.com /sh owan swers/5 945 9/wh at -are-t h e-oops-con cept -in -java-explain -wit h -real-t im e-exam ples.h t m l
5 /15
5 /24/2016
wh at are t h e oops con cept in java explain wit h real t im e exam ples
TheNewClassisExistingfromOld
Class,i.eSubClassis
ExistingfromSuperClass.
RealTimeExample:
FatherandSonRelationship
Polymorphisam:
SinleFormbehavingdiffreantlyin
diffreant
Situations.
Example:
Person
PersoninHomeactishusband/son,
inOfficeactsEmployer.
inPublicGoodCityzen.
Ithinktheseallarerealtime
experianceany.isthereany
moreanswerssendmemymail
mdevendra@gmail.comalso.
Thanksall
Devendra.M
IsT his
Answer
Correct
?
131
Yes
28
No
submit
Answer
#5
OOPSConceptsaremainly4
1.Abstraction
2.Encapsulation
3.Inheritance
4 .Polymorphisam
praveena
Abstraction:Hidingunneccessarydata
fromuseriscalled
Abstractionaccessspecifierslike
public,privateetcare
usedtoprovidedifferentlevelin
abstraction.
h t t p://www.allin t erview.com /sh owan swers/5 945 9/wh at -are-t h e-oops-con cept -in -java-explain -wit h -real-t im e-exam ples.h t m l
6/15
5 /24/2016
wh at are t h e oops con cept in java explain wit h real t im e exam ples
Encapsulation:Takingdataandobject
inasingleunityis
calledEncapsulation.Aclassis
exampleforEncapsulation.
Inheritance:creatinganewclassfrom
existingclassis
calledInheritance.reusabilityismain
advantagein
inheritance.
polymorphism:ifsinglemthodperforms
differenttaskis
calledpolymorphism.
IsT his
Answer
Correct
?
88
Yes
34
No
submit
Answer
#6
Wehavethefollowingoopsconcepts
like
1.Abtsrction
2.Encapsulation
3.Inheritance
4 .Polymorphism
muralikrishna
thanneeru
Abstraction:
hidingunnecessarydatafromtheusers
andmakingthe
applicationasuserfriendlythenitis
calledasabstrcation
ex:Anymailaccounttheuserissimply
fillingtheformand
hedon'tknowhoitisdeveloped.
Encapsulation:
Wrappingthedataandcodeasasingle
h t t p://www.allin t erview.com /sh owan swers/5 945 9/wh at -are-t h e-oops-con cept -in -java-explain -wit h -real-t im e-exam ples.h t m l
7/15
5 /24/2016
wh at are t h e oops con cept in java explain wit h real t im e exam ples
unitiscalledas
encapsulation.
ex:Capsuleisthebestrealtime
exampleforit.Initwe
willhavetwotypesofdrugscombined
assinglecapsule.
Inheritance:
Acquiringthepropertiesfromone
class(baseclassorparent
class)toanotherclass(derivedclassor
childclass)is
calledasinheritance.
Ex:Inventinglaptopfromdesktop.
Polymorphism:
Singleentitybehavingindifferentforms
iscalledas
polymorphism
ex:Mouseisforclickthebuttonsand
draggingthebarsor
placingthepointerinaparticularplace.
IsT his
Answer
Correct
?
66
Yes
14
No
submit
Answer
#7
Wehavethefollowingoopsconcepts
like
1.Abtsrction
2.Encapsulation
3.Inheritance
4 .Polymorphism
l.priya
Abstraction:
hidingunnecessarydatafromtheusers
andmakingthe
h t t p://www.allin t erview.com /sh owan swers/5 945 9/wh at -are-t h e-oops-con cept -in -java-explain -wit h -real-t im e-exam ples.h t m l
8 /15
5 /24/2016
wh at are t h e oops con cept in java explain wit h real t im e exam ples
applicationasuserfriendlythenitis
calledas
abstrcation
ex:Anymailaccounttheuserissimply
fillingtheformand
hedon'tknowhoitisdeveloped.
Encapsulation:
Wrappingthedataandcodeasasingle
unitiscalledas
encapsulation.
ex:Capsuleisthebestrealtime
exampleforit.Initwe
willhavetwotypesofdrugscombined
assinglecapsule.
Inheritance:
Acquiringthepropertiesfromone
class(baseclassorparent
class)toanotherclass(derivedclassor
childclass)is
calledasinheritance.
Ex:Inventinglaptopfromdesktop.
Polymorphism:
Singleentitybehavingindifferentforms
iscalledas
polymorphism
ex:Mouseisforclickthebuttonsand
draggingthebarsor
placingthepointerinaparticularplace.
IsT his
Answer
Correct
?
57
Yes
12
No
submit
h t t p://www.allin t erview.com /sh owan swers/5 945 9/wh at -are-t h e-oops-con cept -in -java-explain -wit h -real-t im e-exam ples.h t m l
9/15
5 /24/2016
wh at are t h e oops con cept in java explain wit h real t im e exam ples
Answer
#8
1,class
2,encapsulation
3,polymorphism
4 ,inheritance
5,Abstraction
niventhmca
class
collectionofattributesiscalledclass
Realtimeexample......humanbody
encapsulation
Toencapsulatethesome
methods,operationsinone
classiscalledtheencapsulation
Realtimeexample......capsules
polymorphism
Toabilitytotakemorethanoneform
Realtimeexample......xeroxmachine
inheritance
oneclasspropertiesoccurfrom
anotherclassproperties
Realtimeexample......landline...will
phone....cellphone
2g....3g....
IsT his
Answer
Correct
?
74
Yes
34
No
submit
Answer
#9
Abstraction:
Hidingunnecessarythingsandshowing
theessential
information.
bhaskara
reddyakepati
Example:Supposetakeacar:Inthat
wewillhavebreaks
andsteringandetc...Herewhenweare
changingthegear
boxtouporbottomthengearswill
workbutwedon'tknow
h t t p://www.allin t erview.com /sh owan swers/5 945 9/wh at -are-t h e-oops-con cept -in -java-explain -wit h -real-t im e-exam ples.h t m l
10/15
5 /24/2016
wh at are t h e oops con cept in java explain wit h real t im e exam ples
howtheyaremanaginginternallyand
wedon'tnohowitis
working.Asadriverwedon'tneedto
knowhowitis
workinginternallywhenweare
changingeverytime.Thatis
thereasontheywillhidethewiresand
cablesinternally
andtheywillshowuponlygearboxto
us.
Advantages:1)Codewillbecleanand
formanagingitwill
beveryeasy
Inheritance:
Acquiringthepropertiesfromsuper
classto
subclass.
Example:Supposetaketwojava
classes
ClassAcontains2variablesand
ClassBExtendsClassA
thatmeanshereClassBcanaccess
theclassAvariables
withoutdeclaringit.Ifwedothisthen
thememorywillbe
lessandreusable.
Advantages:1)Reusabilityofcode
Encapsulation:Wrappingupofdata
andmethodsintoa
singleunit.
Example:Inourclassweneedtomake
allourvarablesand
methodskeepingtogether.
Advantage:Maintancewillbegood
Polymorphism:Itmeansmanyforms.
2types:
h t t p://www.allin t erview.com /sh owan swers/5 945 9/wh at -are-t h e-oops-con cept -in -java-explain -wit h -real-t im e-exam ples.h t m l
11/15
5 /24/2016
wh at are t h e oops con cept in java explain wit h real t im e exam ples
1)Compiletimepolymorphism
2)Runtimepolymorphism
Methodoverloadingisanexamplefor
Compiletime
polymorphismand
Methodoverridingisanexamplefor
Runtimepolymorphism
IsT his
Answer
Correct
?
23
Yes
7
No
submit
Answer
#10
OOPSCOnceptsAre:
Mainlythesearetheconceptsarevery
importantinoops:
Abstraction
Encapsulation
Inheritance
Polymorphism.
m
arunachalam
BirdsVsAbstractions
Birds:weinventedflightbasedonthe
mechanismofBirds.
Soflightisderivedformthebaseof
birds.
Abstraction:Abstractionisawayto
removetheassociation
ofthebehaviorofanobjectwiththe
actualdetailsbehind
thesceneswhichimplementthat
object'sbehavior.This
'abstraction'isusuallyaccomplished
throughtheuseof
baseclasseswithvirtualfunctions
eachderivedfunction
providesthedetailsthatimplementthe
behaviorbehindthat
abstraction.
h t t p://www.allin t erview.com /sh owan swers/5 945 9/wh at -are-t h e-oops-con cept -in -java-explain -wit h -real-t im e-exam ples.h t m l
12/15
5 /24/2016
wh at are t h e oops con cept in java explain wit h real t im e exam ples
PenVsEncapsulation
Pen:Inkistheimportantcomponentin
penbutitishiding
bysomeothermaterial
Encapsulation:isaprocessofbinding
orwrappingthedata
andthecodesthatoperatesonthedata
intoasingle
entity.Thiskeepsthedatasafefrom
outsideinterfaceand
misuse.Onewaytothinkabout
encapsulationisasa
protectivewrapperthatpreventscode
anddatafrombeing
arbitrarilyaccessedbyothercode
definedoutsidethewrapper.
CrocodileVsPolymorphism
Crocodile:liveindifferentlyonlandorin
thewater.In
wateritsMomentveryfastcompareto
land.Ananimallives
indifferentcharacterindifferentplace.
Polymorphism:asinglefunctionor
singleoperatorhas
differentcharacterindifferentplace.
InheritanceVsHumanRelationship
HumanRelationship:GrandFather
FatherSon
Inheritance:Aderivedfromexistingone
tonewoneisknown
asInheritance.
IsT his
Answer
Correct
?
12
Yes
2
No
submit
h t t p://www.allin t erview.com /sh owan swers/5 945 9/wh at -are-t h e-oops-con cept -in -java-explain -wit h -real-t im e-exam ples.h t m l
13 /15
5 /24/2016
wh at are t h e oops con cept in java explain wit h real t im e exam ples
>>
Question
Asked@
Answers
cts
saksoft
whatisanobjectandhowdoyouallocatememorytoit?
wipro
Canweiteratethroughcollectionusingforloop?
rolta
benchmark
Howcanyoueliminateduplicates?
whatisthemaindifferencebetweenstringand
stringbuffer?canyouexplainitwithprogram?
ibm
WhatJNDI(JavaNamingandDirectoryInterface)
provides?
Whatisalayoutmanager?
rbs
saisoftech
whataredepricatedmethodsinthreadsandexplainthe
lifecyclemethods
whatisHashmap&Hashtablewirhexample?
whatisdifferencebetweenStringbufferandString
builder?
whyconstructordonthavereturnstype?
7)SupposethereisStudentclasslikeclassstudent{
intagestringname}Wewanttostoretheseobjects
inaHashMap.Doweneedtooverrideanymethodsin
Studentclass?Ifanywhichonesandwhy?whatifijust
overrideequalsorjusthashcode?whatwillbethe
resultsinboththecases?
DifferencebetweenabstractclassandInterfaces?
FormoreCoreJavaInterviewQuestionsClickHere
h t t p://www.allin t erview.com /sh owan swers/5 945 9/wh at -are-t h e-oops-con cept -in -java-explain -wit h -real-t im e-exam ples.h t m l
14/15
5 /24/2016
wh at are t h e oops con cept in java explain wit h real t im e exam ples
CopyrightPolicy|T ermsofService|SiteMap|
SiteMap|ContactUs|
Copyright 2015ALLInterview.com.AllRightsReserved.
A L L I n t e r v i e w . c o m ::F o r u m 9 . c o m ::K a l A a j K a l . c o m
h t t p://www.allin t erview.com /sh owan swers/5 945 9/wh at -are-t h e-oops-con cept -in -java-explain -wit h -real-t im e-exam ples.h t m l
15 /15