9/6/2015 115JavaInterviewQuestionsandAnswersTheULTIMATEList
http://www.javacodegeeks.com/2014/04/javainterviewquestionsandanswers.html 1/28
HomeJavaCoreJava115JavaInterviewQuestionsandAnswersTheULTIMATEList(PDFDownload)
ABOUT SOTIRIOS-EFSTATHIOS MANEASSotiriosEfstathios(Stathis)ManeasisapostgraduatestudentattheDepartmentofInformaticsandTelecommunicationsofTheNationalandKapodistrianUniversityofAthens.Hismaininterestsincludedistributedsystems,webcrawling,modelchecking,operatingsystems,programminglanguagesandwebapplications.
115 Java Interview Questions and Answers The ULTIMATE List (PDFDownload) Postedby:SotiriosEfstathiosManeas inCoreJava April7th,2014
InthistutorialwewilldiscussaboutdifferenttypesofquestionsthatcanbeusedinaJavainterview,inorderfortheemployertotestyourskillsinJavaandobjectorientedprogrammingingeneral.
Inthefollowingsectionswewilldiscussaboutobjectorientedprogramminganditscharacteristics,generalquestionsregardingJavaanditsfunctionality,collectionsinJava,garbagecollectors,exceptionhandling,Javaapplets,Swing,JDBC,RemoteMethodInvocation(RMI),ServletsandJSP.
Letsgo!
JavaInterviewComingUp?SubscribetoournewsletteranddownloadtheUltimateJavainterviewquestionsandanswerscollectionrightnow!
InordertogetyoupreparedforyournextJavaInterview,wehavecompiledahugelistofrelevantQuestionsandtheirrespectiveAnswers.BesidesstudyingthemonlineyoumaydownloadtheeBookinPDFformat!
Emailaddress:
Youremailaddress
Signup
TipAreyoulookingforcareeropportunitiesinJava?VisitourJobBoardtosearchandreviewahandpickedselectionofJavajobsforITprofessionalsaroundtheworld.AdditionallyyoucanaddyourresumetoourResumesBoardpromotingyourskillstoawiderangeofJavajobrecruitersaroundtheworld.
TableofContents
NEWSLETTER
100189insidersarealreadyenjoyingweeklyupdatesandcomplimentarywhitepapers!JointhemnowtogainexclusiveaccesstothelatestnewsintheJavaworld,aswellasinsightsaboutAndroid,Scala,Groovyandotherrelatedtechnologies.
Emailaddress:
Youremailaddress
Signup
JOIN US
ANDROID JAVA JVM LANGUAGES SOFTWARE DEVELOPMENT AGILE CAREER COMMUNICATIONS DEVOPS META JCG
Search... KnowledgeBase JobBoard JoinUs About
9/6/2015 115JavaInterviewQuestionsandAnswersTheULTIMATEList
http://www.javacodegeeks.com/2014/04/javainterviewquestionsandanswers.html 2/28
ObjectOrientedProgramming(OOP)GeneralQuestionsaboutJavaJavaThreadsJavaCollectionsGarbageCollectorsExceptionHandlingJavaAppletsSwingJDBCRemoteMethodInvocation(RMI)ServletsJSP
ObjectOrientedProgramming(OOP)Javaisacomputerprogramminglanguagethatisconcurrent,classbasedandobjectoriented.Theadvantagesofobjectorientedsoftwaredevelopmentareshownbelow:
Modulardevelopmentofcode,whichleadstoeasymaintenanceandmodification.
Reusabilityofcode.
Improvedreliabilityandflexibilityofcode.
Increasedunderstandingofcode.
Objectorientedprogrammingcontainsmanysignificantfeatures,suchasencapsulation,inheritance,polymorphismandabstraction.Weanalyzeeachfeatureseparatelyinthefollowingsections.
EncapsulationEncapsulationprovidesobjectswiththeabilitytohidetheirinternalcharacteristicsandbehavior.Eachobjectprovidesanumberofmethods,whichcanbeaccessedbyotherobjectsandchangeitsinternaldata.InJava,therearethreeaccessmodifiers:public,privateandprotected.Eachmodifierimposesdifferentaccessrightstootherclasses,eitherinthesameorinexternalpackages.Someoftheadvantagesofusingencapsulationarelistedbelow:
Theinternalstateofeveryobjectedisprotectedbyhidingitsattributes.
Itincreasesusabilityandmaintenanceofcode,becausethebehaviorofanobjectcanbeindependentlychangedorextended.
Itimprovesmodularitybypreventingobjectstointeractwitheachother,inanundesiredway.
Youcanrefertoourtutorialhereformoredetailsandexamplesonencapsulation.
PolymorphismPolymorphismistheabilityofprogramminglanguagestopresentthesameinterfacefordifferingunderlyingdatatypes.Apolymorphictypeisatypewhoseoperationscanalsobeappliedtovaluesofsomeothertype.
InheritanceInheritanceprovidesanobjectwiththeabilitytoacquirethefieldsandmethodsofanotherclass,calledbaseclass.Inheritanceprovidesreusabilityofcodeandcanbeusedtoaddadditionalfeaturestoanexistingclass,withoutmodifyingit.
AbstractionAbstractionistheprocessofseparatingideasfromspecificinstancesandthus,developclassesintermsoftheirownfunctionality,insteadoftheirimplementationdetails.Javasupportsthecreationandexistenceofabstractclassesthatexposeinterfaces,withoutincludingtheactualimplementationofallmethods.Theabstractiontechniqueaimstoseparatetheimplementationdetailsofaclassfromitsbehavior.
DifferencesbetweenAbstractionandEncapsulationAbstractionandencapsulationarecomplementaryconcepts.Ontheonehand,abstractionfocusesonthebehaviorofanobject.Ontheotherhand,encapsulationfocusesontheimplementationofanobjectsbehavior.Encapsulationisusuallyachievedbyhidinginformationabouttheinternalstateofanobjectandthus,canbeseenasastrategyusedinordertoprovideabstraction.
GeneralQuestionsaboutJava1.WhatisJVM?WhyisJavacalledthePlatformIndependentProgrammingLanguage?AJavavirtualmachine(JVM)isaprocessvirtualmachinethatcanexecuteJavabytecode.EachJavasourcefileiscompiledintoabytecodefile,whichisexecutedbytheJVM.Javawasdesignedtoallowapplicationprogramstobebuiltthatcouldberunonanyplatform,withouthavingtoberewrittenor
With 1,240,600uniquevisitorsandover500 authorsweareplacedamongthetopJavarelatedsitesaround.Constantlybeingonthelookoutforpartnersweencourageyoutojoinus.SoIfyouhaveablogwith
uniqueandinterestingcontentthenyoushouldcheckoutourJCGpartnersprogram.YoucanalsobeaguestwriterforJavaCodeGeeksandhoneyourwritingskills!
CAREER OPPORTUNITIES
What:
title,keywords
Where:
city,state,orzip
FindJobs
SeniorJavaDeveloperSeniorBackend...CapitalOneSanFrancisco,CA
SeniorSoftwareArchitect/EngineerBankofAmericaPennington,NJ
SeniorWebSoftwareEngineerHPSeattle,WA
ApplicationDeveloper(200082Exempt)IntelSantaClara,CA
SoftwareDeveloper3OracleRocklin,CA
ITAnalyst/ProgrammerJobMayoClinicRochester,MN
SeniorSoftwareDeveloperAnalystLockheedMartinBethesda,MD
SoftwareEngineer2ShutterflySantaClara,CA
DeveloperJavaStateofOregonHillsboro,OR
ProgrammerAnalyst3BoeingSt.Louis,MO12345678910Next
9/6/2015 115JavaInterviewQuestionsandAnswersTheULTIMATEList
http://www.javacodegeeks.com/2014/04/javainterviewquestionsandanswers.html 3/28
recompiledbytheprogrammerforeachseparateplatform.AJavavirtualmachinemakesthispossible,becauseitisawareofthespecificinstructionlengthsandotherparticularitiesoftheunderlyinghardwareplatform.
2.WhatistheDifferencebetweenJDKandJRE?TheJavaRuntimeEnvironment(JRE)isbasicallytheJavaVirtualMachine(JVM)whereyourJavaprogramsarebeingexecuted.Italsoincludesbrowserpluginsforappletexecution.TheJavaDevelopmentKit(JDK)isthefullfeaturedSoftwareDevelopmentKitforJava,includingtheJRE,thecompilersandtools(likeJavaDoc
,andJava Debugger
),inorderforausertodevelop,compileandexecuteJavaapplications.
3.Whatdoesthestatickeywordmean?CanyouoverrideprivateorstaticmethodinJava?Thestatickeyworddenotesthatamembervariableormethodcanbeaccessed,withoutrequiringaninstantiationoftheclasstowhichitbelongs.AusercannotoverridestaticmethodsinJava,becausemethodoverridingisbasedupondynamicbindingatruntimeandstaticmethodsarestaticallybindedatcompiletime.Astaticmethodisnotassociatedwithanyinstanceofaclasssotheconceptisnotapplicable.
4.Canyouaccessnonstaticvariableinstaticcontext?AstaticvariableinJavabelongstoitsclassanditsvalueremainsthesameforallitsinstances.AstaticvariableisinitializedwhentheclassisloadedbytheJVM.Ifyourcodetriestoaccessanonstaticvariable,withoutanyinstance,thecompilerwillcomplain,becausethosevariablesarenotcreatedyetandtheyarenotassociatedwithanyinstance.
5.WhataretheDataTypessupportedbyJava?WhatisAutoboxingandUnboxing?TheeightprimitivedatatypessupportedbytheJavaprogramminglanguageare:
byte
short
int
long
float
double
boolean
char
Autoboxing
istheautomaticconversionmadebytheJavacompilerbetweentheprimitivetypesandtheircorrespondingobjectwrapperclasses.Forexample,thecompilerconvertsaninttoanInteger
,adoubletoaDouble
,andsoon.Iftheconversiongoestheotherway,thisoperationiscalledunboxing
.
6.WhatisFunctionOverridingandOverloadinginJava?MethodoverloadinginJavaoccurswhentwoormoremethodsinthesameclasshavetheexactsamename,butdifferentparameters.Ontheotherhand,methodoverridingisdefinedasthecasewhenachildclassredefinesthesamemethodasaparentclass.Overriddenmethodsmusthavethesamename,argumentlist,andreturntype.Theoverridingmethodmaynotlimittheaccessofthemethoditoverrides.
7.WhatisaConstructor,ConstructorOverloadinginJavaandCopyConstructor?Aconstructorgetsinvokedwhenanewobjectiscreated.Everyclasshasaconstructor.Incasetheprogrammerdoesnotprovideaconstructorforaclass,theJavacompiler(Javac)createsadefaultconstructorforthatclass.TheconstructoroverloadingissimilartomethodoverloadinginJava.Differentconstructorscanbecreatedforasingleclass.Eachconstructormusthaveitsownuniqueparameterlist.Finally,JavadoessupportcopyconstructorslikeC++,butthedifferenceliesinthefactthatJavadoesntcreateadefaultcopyconstructorifyoudontwriteyourown.
8.DoesJavasupportmultipleinheritance?No,Javadoesnotsupportmultipleinheritance.Eachclassisabletoextendonlyononeclass,butisabletoimplementmorethanoneinterfaces.
9.WhatisthedifferencebetweenanInterfaceandanAbstractclass?Javaprovidesandsupportsthecreationbothofabstractclassesandinterfaces.Bothimplementationssharesomecommoncharacteristics,buttheydifferinthefollowingfeatures:
Allmethodsinaninterfaceareimplicitlyabstract.Ontheotherhand,anabstractclassmaycontainbothabstractandnonabstractmethods.
AclassmayimplementanumberofInterfaces,butcanextendonlyoneabstractclass.
Inorderforaclasstoimplementaninterface,itmustimplementallitsdeclaredmethods.However,aclassmaynotimplementalldeclaredmethodsofanabstractclass.Though,inthiscase,thesubclassmustalsobedeclaredasabstract.
Abstractclassescanimplementinterfaceswithoutevenprovidingtheimplementationofinterfacemethods.
VariablesdeclaredinaJavainterfaceisbydefaultfinal.Anabstractclassmaycontainnonfinalvariables.
MembersofaJavainterfacearepublicbydefault.Amemberofanabstractclasscaneitherbeprivate,protectedorpublic.
jobsby
KickstartYourJSFProjectswithourFREEeBook!
9/6/2015 115JavaInterviewQuestionsandAnswersTheULTIMATEList
http://www.javacodegeeks.com/2014/04/javainterviewquestionsandanswers.html 4/28
Aninterfaceisabsolutelyabstractandcannotbeinstantiated.Anabstractclassalsocannotbeinstantiated,butcanbeinvokedifitcontainsamainmethod.
AlsocheckouttheAbstractclassandInterfacedifferencesforJDK8.
10.Whatarepassbyreferenceandpassbyvalue?Whenanobjectispassedbyvalue,thismeansthatacopyoftheobjectispassed.Thus,evenifchangesaremadetothatobject,itdoesntaffecttheoriginalvalue.Whenanobjectispassedbyreference,thismeansthattheactualobjectisnotpassed,ratherareferenceoftheobjectispassed.Thus,anychangesmadebytheexternalmethod,arealsoreflectedinallplaces.
JavaThreads11.Whatisthedifferencebetweenprocessesandthreads?Aprocessisanexecutionofaprogram,whileaThread
isasingleexecutionsequencewithinaprocess.Aprocesscancontainmultiplethreads.AThread
issometimescalledalightweightprocess.
12.Explaindifferentwaysofcreatingathread.Whichonewouldyoupreferandwhy?TherearethreewaysthatcanbeusedinorderforaThread
tobecreated:
AclassmayextendtheThread
class.
AclassmayimplementtheRunnable
interface.
AnapplicationcanusetheExecutor
framework,inordertocreateathreadpool.
TheRunnable
interfaceispreferred,asitdoesnotrequireanobjecttoinherittheThread
class.Incaseyourapplicationdesignrequiresmultipleinheritance,onlyinterfacescanhelpyou.Also,thethreadpoolisveryefficientandcanbeimplementedandusedveryeasily.
13.Explaintheavailablethreadstatesinahighlevel.Duringitsexecution,athreadcanresideinoneofthefollowingstates
:
NEW
:Thethreadbecomesreadytorun,butdoesnotnecessarilystartrunningimmediately.
RUNNABLE
:TheJavaVirtualMachine(JVM)isactivelyexecutingthethreadscode.
BLOCKED
:Thethreadisinablockedstatewhilewaitingforamonitorlock.
WAITING
:Thethreadwaitsforanotherthreadtoperformaparticularaction.
TIMED_WAITING
:Thethreadwaitsforanotherthreadtoperformaparticularactionuptoaspecifiedwaitingtime.
9/6/2015 115JavaInterviewQuestionsandAnswersTheULTIMATEList
http://www.javacodegeeks.com/2014/04/javainterviewquestionsandanswers.html 5/28
TERMINATED
:Thethreadhasfinisheditsexecution.
14.Whatisthedifferencebetweenasynchronizedmethodandasynchronizedblock?InJavaprogramming,eachobjecthasalock.Athreadcanacquirethelockforanobjectbyusingthesynchronizedkeyword.Thesynchronizedkeywordcanbeappliedinamethodlevel(coarsegrainedlock)orblocklevelofcode(finegrainedlock).
15.Howdoesthreadsynchronizationoccursinsideamonitor?Whatlevelsofsynchronizationcanyouapply?TheJVMuseslocksinconjunctionwithmonitors.Amonitorisbasicallyaguardianthatwatchesoverasequenceofsynchronizedcodeandensuringthatonlyonethreadatatimeexecutesasynchronizedpieceofcode.Eachmonitorisassociatedwithanobjectreference.Thethreadisnotallowedtoexecutethecodeuntilitobtainsthelock.
16.Whatsadeadlock?Aconditionthatoccurswhentwoprocessesarewaitingforeachothertocomplete,beforeproceeding.Theresultisthatbothprocesseswaitendlessly.
17.HowdoyouensurethatNthreadscanaccessNresourceswithoutdeadlock?AverysimplewaytoavoiddeadlockwhileusingNthreadsistoimposeanorderingonthelocksandforceeachthreadtofollowthatordering.Thus,ifallthreadslockandunlockthemutexesinthesameorder,nodeadlockscanarise.
JavaCollections18.WhatarethebasicinterfacesofJavaCollectionsFramework?Java Collections Framework
providesawelldesignedsetofinterfacesandclassesthatsupportoperationsonacollectionsofobjects.ThemostbasicinterfacesthatresideintheJavaCollectionsFrameworkare:
Collection
,whichrepresentsagroupofobjectsknownasitselements.
Set
,whichisacollectionthatcannotcontainduplicateelements.
List
,whichisanorderedcollectionandcancontainduplicateelements.
Map
,whichisanobjectthatmapskeystovaluesandcannotcontainduplicatekeys.
19.WhyCollectiondoesntextendCloneableandSerializableinterfaces?TheCollection
interfacespecifiesgroupsofobjectsknownaselements.EachconcreteimplementationofaCollection
canchooseitsownwayofhowtomaintainandorderitselements.Somecollectionsallowduplicatekeys,whilesomeothercollectionsdont.Thesemanticsandtheimplicationsofeithercloningorserializationcomeintoplaywhendealingwithactualimplementations.Thus,theconcreteimplementationsofcollectionsshoulddecidehowtheycanbeclonedorserialized.
20.WhatisanIterator?TheIterator
interfaceprovidesanumberofmethodsthatareabletoiterateoveranyCollection
.EachJavaCollection
containstheiterator
methodthatreturnsanIterator
instance.Iteratorsarecapableofremovingelementsfromtheunderlyingcollectionduringtheiteration.21.WhatdifferencesexistbetweenIteratorandListIterator?Thedifferencesoftheseelementsarelistedbelow:
An
9/6/2015 115JavaInterviewQuestionsandAnswersTheULTIMATEList
http://www.javacodegeeks.com/2014/04/javainterviewquestionsandanswers.html 6/28
Iterator
canbeusedtotraversetheSet
andList
collections,whiletheListIterator
canbeusedtoiterateonlyoverLists
.
TheIterator
cantraverseacollectiononlyinforwarddirection,whiletheListIterator
cantraverseaList
inbothdirections.
TheListIterator
implementstheIterator
interfaceandcontainsextrafunctionality,suchasaddinganelement,replacinganelement,gettingtheindexpositionforpreviousandnextelements,etc.
22.Whatisdifferencebetweenfailfastandfailsafe?TheIterator's
failsafepropertyworkswiththecloneoftheunderlyingcollectionandthus,itisnotaffectedbyanymodificationinthecollection.Allthecollectionclassesinjava.utilpackagearefailfast,whilethecollectionclassesinjava.util.concurrentarefailsafe.FailfastiteratorsthrowaConcurrentModificationException
,whilefailsafeiteratorneverthrowssuchanexception.
23.HowHashMapworksinJava?AHashMapinJavastoreskeyvaluepairs.TheHashMap
requiresahashfunctionanduseshashCode
andequalsmethods,inordertoputandretrieveelementstoandfromthecollectionrespectively.Whentheputmethodisinvoked,theHashMap
calculatesthehashvalueofthekeyandstoresthepairintheappropriateindexinsidethecollection.Ifthekeyexists,itsvalueisupdatedwiththenewvalue.SomeimportantcharacteristicsofaHashMap
areitscapacity,itsloadfactorandthethresholdresizing.
24.WhatistheimportanceofhashCode()andequals()methods?InJava,aHashMap
usesthehashCode
andequals
9/6/2015 115JavaInterviewQuestionsandAnswersTheULTIMATEList
http://www.javacodegeeks.com/2014/04/javainterviewquestionsandanswers.html 7/28
methodstodeterminetheindexofthekeyvaluepairandtodetectduplicates.Morespecifically,thehashCode
methodisusedinordertodeterminewherethespecifiedkeywillbestored.Sincedifferentkeysmayproducethesamehashvalue,theequals
methodisused,inordertodeterminewhetherthespecifiedkeyactuallyexistsinthecollectionornot.Therefore,theimplementationofbothmethodsiscrucialtotheaccuracyandefficiencyoftheHashMap
.
25.WhatdifferencesexistbetweenHashMapandHashtable?BoththeHashMap
andHashtable
classesimplementtheMapinterfaceandthus,haveverysimilarcharacteristics.However,theydifferinthefollowingfeatures:
AHashMap
allowstheexistenceofnullkeysandvalues,whileaHashtable
doesntallowneithernullkeys,nornullvalues.
AHashtable
issynchronized,whileaHashMap
isnot.Thus,HashMap
ispreferredinsinglethreadedenvironments,whileaHashtable
issuitableformultithreadedenvironments.
AHashMap
providesitssetofkeysandaJavaapplicationcaniterateoverthem.Thus,aHashMap
isfailfast.Ontheotherhand,aHashtable
providesanEnumeration
ofitskeys.
TheHashtable
classisconsideredtobealegacyclass.
26.WhatisdifferencebetweenArrayandArrayList?WhenwillyouuseArrayoverArrayList?TheArray
andArrayList
classesdifferonthefollowingfeatures:
Arrays
9/6/2015 115JavaInterviewQuestionsandAnswersTheULTIMATEList
http://www.javacodegeeks.com/2014/04/javainterviewquestionsandanswers.html 8/28
cancontainprimitiveorobjects,whileanArrayList
cancontainonlyobjects.
Arrays
havefixedsize,whileanArrayList
isdynamic.
AnArrayList
providesmoremethodsandfeatures,suchasaddAll
,removeAll
,iterator
,etc.
Foralistofprimitivedatatypes,thecollectionsuseautoboxingtoreducethecodingeffort.However,thisapproachmakesthemslowerwhenworkingonfixedsizeprimitivedatatypes.
27.WhatisdifferencebetweenArrayListandLinkedList?BoththeArrayList
andLinkedList
classesimplementtheListinterface,buttheydifferonthefollowingfeatures:
AnArrayList
isanindexbaseddatastructurebackedbyanArray
.ItprovidesrandomaccesstoitselementswithaperformanceequaltoO(1).Ontheotherhand,aLinkedList
storesitsdataaslistofelementsandeveryelementislinkedtoitspreviousandnextelement.Inthiscase,thesearchoperationforanelementhasexecutiontimeequaltoO(n).
TheInsertion,additionandremovaloperationsofanelementarefasterinaLinkedList
comparedtoanArrayList
,becausethereisnoneedofresizinganarrayorupdatingtheindexwhenanelementisaddedinsomearbitrarypositioninsidethecollection.
ALinkedList
consumesmorememorythananArrayList
,becauseeverynodeinaLinkedList
storestworeferences,oneforitspreviouselementandoneforitsnextelement.
CheckalsoourarticleArrayListvs.LinkedList.
28.WhatisComparableandComparatorinterface?Listtheirdifferences.Javaprovidesthe
9/6/2015 115JavaInterviewQuestionsandAnswersTheULTIMATEList
http://www.javacodegeeks.com/2014/04/javainterviewquestionsandanswers.html 9/28
Comparable
interface,whichcontainsonlyonemethod,calledcompareTo
.Thismethodcomparestwoobjects,inordertoimposeanorderbetweenthem.Specifically,itreturnsanegativeinteger,zero,orapositiveintegertoindicatethattheinputobjectislessthan,equalorgreaterthantheexistingobject.JavaprovidestheComparator
interface,whichcontainstwomethods,calledcompare
andequals
.Thefirstmethodcomparesitstwoinputargumentsandimposesanorderbetweenthem.Itreturnsanegativeinteger,zero,orapositiveintegertoindicatethatthefirstargumentislessthan,equalto,orgreaterthanthesecond.Thesecondmethodrequiresanobjectasaparameterandaimstodecidewhethertheinputobjectisequaltothecomparator.Themethodreturnstrue,onlyifthespecifiedobjectisalsoacomparatoranditimposesthesameorderingasthecomparator.
29.WhatisJavaPriorityQueue?ThePriorityQueue
isanunboundedqueue,basedonapriorityheapanditselementsareorderedintheirnaturalorder.Atthetimeofitscreation,wecanprovideaComparatorthatisresponsiblefororderingtheelementsofthePriorityQueue
.APriorityQueue
doesntallownullvalues,thoseobjectsthatdoesntprovidenaturalordering,orthoseobjectsthatdonthaveanycomparatorassociatedwiththem.Finally,theJavaPriorityQueue
isnotthreadsafeanditrequiresO(log(n))timeforitsenqueinganddequeingoperations.
30.WhatdoyouknowaboutthebigOnotationandcanyougivesomeexampleswithrespecttodifferentdatastructures?TheBigOnotationsimplydescribeshowwellanalgorithmscalesorperformsintheworstcasescenarioasthenumberofelementsinadatastructureincreases.TheBigOnotationcanalsobeusedtodescribeotherbehaviorsuchasmemoryconsumption.Sincethecollectionclassesareactuallydatastructures,weusuallyusetheBigOnotationtochosethebestimplementationtouse,basedontime,memoryandperformance.BigOnotationcangiveagoodindicationaboutperformanceforlargeamountsofdata.
31.Whatisthetradeoffbetweenusinganunorderedarrayversusanorderedarray?ThemajoradvantageofanorderedarrayisthatthesearchtimeshavetimecomplexityofO(logn),comparedtothatofanunorderedarray,whichisO(n).ThedisadvantageofanorderedarrayisthattheinsertionoperationhasatimecomplexityofO(n),becausetheelementswithhighervaluesmustbemovedtomakeroomforthenewelement.Instead,theinsertionoperationforanunorderedarraytakesconstanttimeofO(1).
32.WhataresomeofthebestpracticesrelatingtotheJavaCollectionframework?
Choosingtherighttypeofthecollectiontouse,basedontheapplicationsneeds,isverycrucialforitsperformance.Forexampleifthesizeoftheelementsisfixedandknowapriori,weshalluseanArray
,insteadofanArrayList
.
Somecollectionclassesallowustospecifytheirinitialcapacity.Thus,ifwehaveanestimationonthenumberofelementsthatwillbestored,wecanuseittoavoidrehashingorresizing.
AlwaysuseGenericsfortypesafety,readability,androbustness.Also,byusingGenericsyouavoidtheClassCastException
duringruntime.
UseimmutableclassesprovidedbytheJavaDevelopmentKit(JDK)asakeyinaMap,inordertoavoidtheimplementationofthehashCode
andequalsmethodsforourcustomclass.
Programintermsofinterfacenotimplementation.
Returnzerolengthcollectionsorarraysasopposedtoreturninganullincasetheunderlyingcollectionisactuallyempty.
9/6/2015 115JavaInterviewQuestionsandAnswersTheULTIMATEList
http://www.javacodegeeks.com/2014/04/javainterviewquestionsandanswers.html 10/28
33.WhatsthedifferencebetweenEnumerationandIteratorinterfaces?Enumeration
istwiceasfastascomparedtoanIteratorandusesverylessmemory.However,theIterator
ismuchsafercomparedtoEnumeration
,becauseotherthreadsarenotabletomodifythecollectionobjectthatiscurrentlytraversedbytheiterator.Also,Iterators
allowthecallertoremoveelementsfromtheunderlyingcollection,somethingwhichisnotpossiblewithEnumerations
.
34.WhatisthedifferencebetweenHashSetandTreeSet?TheHashSet
isImplementedusingahashtableandthus,itselementsarenotordered.Theadd,remove,andcontainsmethodsofaHashSet
haveconstanttimecomplexityO(1).Ontheotherhand,aTreeSet
isimplementedusingatreestructure.TheelementsinaTreeSet
aresorted,andthus,theadd,remove,andcontainsmethodshavetimecomplexityofO(logn).
GarbageCollectors35.WhatisthepurposeofgarbagecollectioninJava,andwhenisitused?Thepurposeofgarbagecollectionistoidentifyanddiscardthoseobjectsthatarenolongerneededbytheapplication,inorderfortheresourcestobereclaimedandreused.
36.WhatdoesSystem.gc()andRuntime.gc()methodsdo?ThesemethodscanbeusedasahinttotheJVM,inordertostartagarbagecollection.However,thisitisuptotheJavaVirtualMachine(JVM)tostartthegarbagecollectionimmediatelyorlaterintime.
37.Whenisthefinalize()called?Whatisthepurposeoffinalization?Thefinalizemethodiscalledbythegarbagecollector,justbeforereleasingtheobjectsmemory.Itisnormallyadvisedtoreleaseresourcesheldbytheobjectinsidethefinalizemethod.
38.Ifanobjectreferenceissettonull,willtheGarbageCollectorimmediatelyfreethememoryheldbythatobject?No,theobjectwillbeavailableforgarbagecollectioninthenextcycleofthegarbagecollector.
39.WhatisstructureofJavaHeap?WhatisPermGenspaceinHeap?TheJVMhasaheapthatistheruntimedataareafromwhichmemoryforallclassinstancesandarraysisallocated.ItiscreatedattheJVMstartup.Heapmemoryforobjectsisreclaimedbyanautomaticmemorymanagementsystemwhichisknownasagarbagecollector.Heapmemoryconsistsofliveanddeadobjects.Liveobjectsareaccessiblebytheapplicationandwillnotbeasubjectofgarbagecollection.Deadobjectsarethosewhichwillneverbeaccessiblebytheapplication,buthavenotbeencollectedbythegarbagecollectoryet.Suchobjectsoccupytheheapmemoryspaceuntiltheyareeventuallycollectedbythegarbagecollector.
40.WhatisthedifferencebetweenSerialandThroughputGarbagecollector?Thethroughputgarbagecollectorusesaparallelversionoftheyounggenerationcollectorandismeanttobeusedwithapplicationsthathavemediumtolargedatasets.Ontheotherhand,theserialcollectorisusuallyadequateformostsmallapplications(thoserequiringheapsofuptoapproximately100MBonmodernprocessors).
41.WhendoesanObjectbecomeseligibleforGarbagecollectioninJava?AJavaobjectissubjecttogarbagecollectionwhenitbecomesunreachabletotheprograminwhichitiscurrentlyused.
42.DoesGarbagecollectionoccurinpermanentgenerationspaceinJVM?GarbageCollectiondoesoccurinPermGenspaceandifPermGenspaceisfullorcrossathreshold,itcantriggerafullgarbagecollection.Ifyoulookcarefullyattheoutputofthegarbagecollector,youwillfindthatPermGenspaceisalsogarbagecollected.ThisisthereasonwhycorrectsizingofPermGenspaceisimportanttoavoidfrequentfullgarbagecollections.AlsocheckourarticleJava8:PermGentoMetaspace.
ExceptionHandling43.WhatarethetwotypesofExceptionsinJava?Whicharethedifferencesbetweenthem?Javahastwotypesofexceptions:checkedexceptionsanduncheckedexceptions.Uncheckedexceptionsdonotneedtobedeclaredinamethodoraconstructorsthrowsclause,iftheycanbethrownbytheexecutionofthemethodortheconstructor,andpropagateoutsidethemethodorconstructorboundary.Ontheotherhand,checkedexceptionsmustbedeclaredinamethodoraconstructorsthrowsclause.SeeherefortipsonJavaexceptionhandling.
9/6/2015 115JavaInterviewQuestionsandAnswersTheULTIMATEList
http://www.javacodegeeks.com/2014/04/javainterviewquestionsandanswers.html 11/28
44.WhatisthedifferencebetweenExceptionandErrorinjava?Exception
andError
classesarebothsubclassesoftheThrowable
class.TheException
classisusedforexceptionalconditionsthatausersprogramshouldcatch.TheError
classdefinesexceptionsthatarenotexceptedtobecaughtbytheuserprogram.
45.Whatisthedifferencebetweenthrowandthrows?Thethrowkeywordisusedtoexplicitlyraiseaexceptionwithintheprogram.Onthecontrary,thethrowsclauseisusedtoindicatethoseexceptionsthatarenothandledbyamethod.Eachmethodmustexplicitlyspecifywhichexceptionsdoesnothandle,sothecallersofthatmethodcanguardagainstpossibleexceptions.Finally,multipleexceptionsareseparatedbyacomma.
45.Whatistheimportanceoffinallyblockinexceptionhandling?Afinallyblockwillalwaysbeexecuted,whetherornotanexceptionisactuallythrown.Eveninthecasewherethecatchstatementismissingandanexceptionisthrown,thefinallyblockwillstillbeexecuted.LastthingtomentionisthatthefinallyblockisusedtoreleaseresourceslikeI/Obuffers,databaseconnections,etc.
46.WhatwillhappentotheExceptionobjectafterexceptionhandling?TheException
objectwillbegarbagecollectedinthenextgarbagecollection.
47.Howdoesfinallyblockdifferfromfinalize()method?Afinallyblockwillbeexecutedwhetherornotanexceptionisthrownandisusedtoreleasethoseresourcesheldbytheapplication.FinalizeisaprotectedmethodoftheObjectclass,whichiscalledbytheJavaVirtualMachine(JVM)justbeforeanobjectisgarbagecollected.
JavaApplets48.WhatisanApplet?AjavaappletisprogramthatcanbeincludedinaHTMLpageandbeexecutedinajavaenabledclientbrowser.Appletsareusedforcreatingdynamicandinteractivewebapplications.
49.ExplainthelifecycleofanApplet.Anappletmayundergothefollowingstates:
Init
:Anappletisinitializedeachtimeisloaded.
Start
:Begintheexecutionofanapplet.
Stop
:Stoptheexecutionofanapplet.
Destroy
:Performafinalcleanup,beforeunloadingtheapplet.
50.Whathappenswhenanappletisloaded?Firstofall,aninstanceoftheappletscontrollingclassiscreated.Then,theappletinitializesitselfandfinally,itstartsrunning.
51.WhatisthedifferencebetweenanAppletandaJavaApplication?Appletsareexecutedwithinajavaenabledbrowser,butaJavaapplicationisastandaloneJavaprogramthatcanbeexecutedoutsideofabrowser.However,theybothrequiretheexistenceofaJavaVirtualMachine(JVM).Furthermore,aJavaapplicationrequiresamainmethodwithaspecificsignature,inordertostartitsexecution.Javaappletsdontneedsuchamethodtostarttheirexecution.Finally,Javaappletstypicallyusearestrictivesecuritypolicy,whileJavaapplicationsusuallyusemorerelaxedsecuritypolicies.
52.WhataretherestrictionsimposedonJavaapplets?Mostlyduetosecurityreasons,thefollowingrestrictionsareimposedonJavaapplets:
Anappletcannotloadlibrariesordefinenativemethods.
Anappletcannotordinarilyreadorwritefilesontheexecutionhost.
Anappletcannotreadcertainsystemproperties.
Anappletcannotmakenetworkconnectionsexcepttothehostthatitcamefrom.
9/6/2015 115JavaInterviewQuestionsandAnswersTheULTIMATEList
http://www.javacodegeeks.com/2014/04/javainterviewquestionsandanswers.html 12/28
Anappletcannotstartanyprogramonthehostthatsexecutingit.
53.Whatareuntrustedapplets?UntrustedappletsarethoseJavaappletsthatcannotaccessorexecutelocalsystemfiles.Bydefault,alldownloadedappletsareconsideredasuntrusted.
54.Whatisthedifferencebetweenappletsloadedovertheinternetandappletsloadedviathefilesystem?Regardingthecasewhereanappletisloadedovertheinternet,theappletisloadedbytheappletclassloaderandissubjecttotherestrictionsenforcedbytheappletsecuritymanager.Regardingthecasewhereanappletisloadedfromtheclientslocaldisk,theappletisloadedbythefilesystemloader.Appletsloadedviathefilesystemareallowedtoreadfiles,writefilesandtoloadlibrariesontheclient.Also,appletsloadedviathefilesystemareallowedtoexecuteprocessesandfinally,appletsloadedviathefilesystemarenotpassedthroughthebytecodeverifier.
55.Whatistheappletclassloader,andwhatdoesitprovide?Whenanappletisloadedovertheinternet,theappletisloadedbytheappletclassloader.TheclassloaderenforcestheJavanamespacehierarchy.Also,theclassloaderguaranteesthatauniquenamespaceexistsforclassesthatcomefromthelocalfilesystem,andthatauniquenamespaceexistsforeachnetworksource.Whenabrowserloadsanappletoverthenet,thatappletsclassesareplacedinaprivatenamespaceassociatedwiththeappletsorigin.Then,thoseclassesloadedbytheclassloaderarepassedthroughtheverifier.TheverifierchecksthattheclassfileconformstotheJavalanguagespecification.Amongotherthings,theverifierensuresthattherearenostackoverflowsorunderflowsandthattheparameterstoallbytecodeinstructionsarecorrect.
56.Whatistheappletsecuritymanager,andwhatdoesitprovide?TheappletsecuritymanagerisamechanismtoimposerestrictionsonJavaapplets.Abrowsermayonlyhaveonesecuritymanager.Thesecuritymanagerisestablishedatstartup,anditcannotthereafterbereplaced,overloaded,overridden,orextended.
Swing57.WhatisthedifferencebetweenaChoiceandaList?AChoiceisdisplayedinacompactformthatmustbepulleddown,inorderforausertobeabletoseethelistofallavailablechoices.OnlyoneitemmaybeselectedfromaChoice.AListmaybedisplayedinsuchawaythatseveralListitemsarevisible.AListsupportstheselectionofoneormoreListitems.
58.Whatisalayoutmanager?Alayoutmanageristheusedtoorganizethecomponentsinacontainer.
59.WhatisthedifferencebetweenaScrollbarandaJScrollPane?AScrollbar
isaComponent
,butnotaContainer
.AScrollPane
isaContainer
.AScrollPane
handlesitsowneventsandperformsitsownscrolling.
60.WhichSwingmethodsarethreadsafe?Thereareonlythreethreadsafemethods:repaint,revalidate,andinvalidate.
61.NamethreeComponentsubclassesthatsupportpainting.TheCanvas
,Frame
,Panel
,andAppletclassessupportpainting.
62.Whatisclipping?Clippingisdefinedastheprocessofconfiningpaintoperationstoalimitedareaorshape.
63.WhatisthedifferencebetweenaMenuItemandaCheckboxMenuItem?TheCheckboxMenuItem
classextendstheMenuItem
classandsupportsamenuitemthatmaybeeithercheckedorunchecked.
9/6/2015 115JavaInterviewQuestionsandAnswersTheULTIMATEList
http://www.javacodegeeks.com/2014/04/javainterviewquestionsandanswers.html 13/28
64.HowaretheelementsofaBorderLayoutorganized?TheelementsofaBorderLayout
areorganizedattheborders(North,South,East,andWest)andthecenterofacontainer.
65.HowaretheelementsofaGridBagLayoutorganized?TheelementsofaGridBagLayout
areorganizedaccordingtoagrid.Theelementsareofdifferentsizesandmayoccupymorethanoneroworcolumnofthegrid.Thus,therowsandcolumnsmayhavedifferentsizes.
66.WhatisthedifferencebetweenaWindowandaFrame?TheFrame
classextendstheWindowclassanddefinesamainapplicationwindowthatcanhaveamenubar.
67.Whatistherelationshipbetweenclippingandrepainting?WhenawindowisrepaintedbytheAWTpaintingthread,itsetstheclippingregionstotheareaofthewindowthatrequiresrepainting.
68.Whatistherelationshipbetweenaneventlistenerinterfaceandaneventadapterclass?Aneventlistenerinterfacedefinesthemethodsthatmustbeimplementedbyaneventhandlerforaparticularevent.Aneventadapterprovidesadefaultimplementationofaneventlistenerinterface.
69.HowcanaGUIcomponenthandleitsownevents?AGUIcomponentcanhandleitsownevents,byimplementingthecorrespondingeventlistenerinterfaceandaddingitselfasitsowneventlistener.
70.WhatadvantagedoJavaslayoutmanagersprovideovertraditionalwindowingsystems?Javauseslayoutmanagerstolayoutcomponentsinaconsistentmanner,acrossallwindowingplatforms.Sincelayoutmanagersarenttiedtoabsolutesizingandpositioning,theyareabletoaccomodateplatformspecificdifferencesamongwindowingsystems.
71.WhatisthedesignpatternthatJavausesforallSwingcomponents?ThedesignpatternusedbyJavaforallSwingcomponentsistheModelViewController(MVC)pattern.
JDBC72.WhatisJDBC?JDBCisanabstractionlayerthatallowsuserstochoosebetweendatabases.JDBCenablesdeveloperstowritedatabaseapplicationsinJava,withouthavingtoconcernthemselveswiththeunderlyingdetailsofaparticulardatabase.
73.ExplaintheroleofDriverinJDBC.TheJDBCDriverprovidesvendorspecificimplementationsoftheabstractclassesprovidedbytheJDBCAPI.Eachdrivermustprovideimplementationsforthefollowingclassesofthejava.sqlpackage:Connection
,Statement
,PreparedStatement
,CallableStatement
,ResultSet
andDriver
.
74.WhatisthepurposeClass.forNamemethod?Thismethodisusedtomethodisusedtoloadthedriverthatwillestablishaconnectiontothedatabase.
75.WhatistheadvantageofPreparedStatementoverStatement?PreparedStatementsareprecompiledandthus,theirperformanceismuchbetter.Also,PreparedStatementobjectscanbereusedwithdifferentinputvaluestotheirqueries.
76.WhatistheuseofCallableStatement?Namethemethod,whichisusedtoprepareaCallableStatement.ACallableStatement
isusedtoexecutestoredprocedures.Storedproceduresarestoredandofferedbyadatabase.Storedproceduresmaytakeinputvaluesfromtheuserandmayreturnaresult.Theusageofstoredproceduresishighlyencouraged,becauseitofferssecurityandmodularity.ThemethodthatpreparesaCallableStatement
9/6/2015 115JavaInterviewQuestionsandAnswersTheULTIMATEList
http://www.javacodegeeks.com/2014/04/javainterviewquestionsandanswers.html 14/28
isthefollowing:
77.WhatdoesConnectionpoolingmean?Theinteractionwithadatabasecanbecostly,regardingtheopeningandclosingofdatabaseconnections.Especially,whenthenumberofdatabaseclientsincreases,thiscostisveryhighandalargenumberofresourcesisconsumed.Apoolofdatabaseconnectionsisobtainedatstartupbytheapplicationserverandismaintainedinapool.Arequestforaconnectionisservedbyaconnectionresidinginthepool.Intheendoftheconnection,therequestisreturnedtothepoolandcanbeusedtosatisfyfuturerequests.
RemoteMethodInvocation(RMI)78.WhatisRMI?TheJavaRemoteMethodInvocation(JavaRMI)isaJavaAPIthatperformstheobjectorientedequivalentofremoteprocedurecalls(RPC),withsupportfordirecttransferofserializedJavaclassesanddistributedgarbagecollection.RemoteMethodInvocation(RMI)canalsobeseenastheprocessofactivatingamethodonaremotelyrunningobject.RMIofferslocationtransparencybecauseauserfeelsthatamethodisexecutedonalocallyrunningobject.ChecksomeRMITipshere.
79.WhatisthebasicprincipleofRMIarchitecture?TheRMIarchitectureisbasedonaveryimportantprinciplewhichstatesthatthedefinitionofthebehaviorandtheimplementationofthatbehavior,areseparateconcepts.RMIallowsthecodethatdefinesthebehaviorandthecodethatimplementsthebehaviortoremainseparateandtorunonseparateJVMs.
80.WhatarethelayersofRMIArchitecture?TheRMIarchitectureconsistsofthefollowinglayers:
Stub and Skeleton layer
:Thislayerliesjustbeneaththeviewofthedeveloper.ThislayerisresponsibleforinterceptingmethodcallsmadebytheclienttotheinterfaceandredirectthesecallstoaremoteRMIService.
Remote Reference Layer
:ThesecondlayeroftheRMIarchitecturedealswiththeinterpretationofreferencesmadefromtheclienttotheserversremoteobjects.Thislayerinterpretsandmanagesreferencesmadefromclientstotheremoteserviceobjects.Theconnectionisaonetoone(unicast)link.
Transport layer
:ThislayerisresponsibleforconnectingthetwoJVMparticipatingintheservice.ThislayerisbasedonTCP/IPconnectionsbetweenmachinesinanetwork.Itprovidesbasicconnectivity,aswellassomefirewallpenetrationstrategies.
81.WhatistheroleofRemoteInterfaceinRMI?TheRemoteinterfaceservestoidentifyinterfaceswhosemethodsmaybeinvokedfromanonlocalvirtualmachine.Anyobjectthatisaremoteobjectmustdirectlyorindirectlyimplementthisinterface.Aclassthatimplementsaremoteinterfaceshoulddeclaretheremoteinterfacesbeingimplemented,definetheconstructorforeachremoteobjectandprovideanimplementationforeachremotemethodinallremoteinterfaces.
82.Whatistheroleofthejava.rmi.NamingClass?Thejava.rmi.Namingclassprovidesmethodsforstoringandobtainingreferencestoremoteobjectsintheremoteobjectregistry.EachmethodoftheNamingclasstakesasoneofitsargumentsanamethatisaStringinURLformat.
83.WhatismeantbybindinginRMI?Bindingistheprocessofassociatingorregisteringanameforaremoteobject,whichcanbeusedatalatertime,inordertolookupthatremoteobject.AremoteobjectcanbeassociatedwithanameusingthebindorrebindmethodsoftheNamingclass.
84.Whatisthedifferencebetweenusingbind()andrebind()methodsofNamingClass?Thebindmethodbindisresponsibleforbindingthespecifiednametoaremoteobject,whiletherebindmethodisresponsibleforrebindingthespecifiednametoanewremoteobject.Incaseabindingexistsforthatname,thebindingisreplaced.
85.WhatarethestepsinvolvedtomakeworkaRMIprogram?ThefollowingstepsmustbeinvolvedinorderforaRMIprogramtoworkproperly:
Compilationofallsourcefiles.
Generatationofthestubsusingrmic.
Startthermiregistry.
StarttheRMIServer.
Runtheclientprogram.
86.WhatistheroleofstubinRMI?Astubforaremoteobjectactsasaclientslocalrepresentativeorproxyfortheremoteobject.Thecallerinvokesamethodonthelocalstub,whichisresponsibleforexecutingthemethodontheremoteobject.Whenastubsmethodisinvoked,itundergoesthefollowingsteps:
ItinitiatesaconnectiontotheremoteJVMcontainingtheremoteobject.
ItmarshalstheparameterstotheremoteJVM.
Itwaitsfortheresultofthemethodinvocationandexecution.
Itunmarshalsthereturnvalueoranexceptionifthemethodhasnotbeensuccessfullyexecuted.
Itreturnsthevaluetothecaller.
1 CallableStament.prepareCall();
9/6/2015 115JavaInterviewQuestionsandAnswersTheULTIMATEList
http://www.javacodegeeks.com/2014/04/javainterviewquestionsandanswers.html 15/28
87.WhatisDGC?Andhowdoesitwork?DGCstandsforDistributedGarbageCollection.RemoteMethodInvocation(RMI)usesDGCforautomaticgarbagecollection.SinceRMIinvolvesremoteobjectreferencesacrossJVMs,garbagecollectioncanbequitedifficult.DGCusesareferencecountingalgorithmtoprovideautomaticmemorymanagementforremoteobjects.
88.WhatisthepurposeofusingRMISecurityManagerinRMI?RMISecurityManagerprovidesasecuritymanagerthatcanbeusedbyRMIapplications,whichusedownloadedcode.TheclassloaderofRMIwillnotdownloadanyclassesfromremotelocations,ifthesecuritymanagerhasnotbeenset.
89.ExplainMarshallinganddemarshalling.Whenanapplicationwantstopassitsmemoryobjectsacrossanetworktoanotherhostorpersistittostorage,theinmemoryrepresentationmustbeconvertedtoasuitableformat.Thisprocessiscalledmarshallingandtherevertoperationiscalleddemarshalling.
90.ExplainSerializationandDeserialization.Javaprovidesamechanism,calledobjectserializationwhereanobjectcanberepresentedasasequenceofbytesandincludestheobjectsdata,aswellasinformationabouttheobjectstype,andthetypesofdatastoredintheobject.Thus,serializationcanbeseenasawayofflatteningobjects,inordertobestoredondisk,andlater,readbackandreconstituted.Deserialisationisthereverseprocessofconvertinganobjectfromitsflattenedstatetoaliveobject.
Servlets91.WhatisaServlet?TheservletisaJavaprogramminglanguageclassusedtoprocessclientrequestsandgeneratedynamicwebcontent.ServletsaremostlyusedtoprocessorstoredatasubmittedbyanHTMLform,providedynamiccontentandmanagestateinformationthatdoesnotexistinthestatelessHTTPprotocol.
92.ExplainthearchitechureofaServlet.Thecoreabstractionthatmustbeimplementedbyallservletsisthejavax.servlet.Servletinterface.Eachservletmustimplementiteitherdirectlyorindirectly,eitherbyextendingjavax.servlet.GenericServletorjavax.servlet.http.HTTPServlet.Finally,eachservletisabletoservemultiplerequestsinparallelusingmultithreading.
93.WhatisthedifferencebetweenanAppletandaServlet?AnAppletisaclientsidejavaprogramthatrunswithinaWebbrowserontheclientmachine.Ontheotherhand,aservletisaserversidecomponentthatrunsonthewebserver.Anappletcanusetheuserinterfaceclasses,whileaservletdoesnothaveauserinterface.Instead,aservletwaitsforclientsHTTPrequestsandgeneratesaresponseineveryrequest.
94.WhatisthedifferencebetweenGenericServletandHttpServlet?GenericServletisageneralizedandprotocolindependentservletthatimplementstheServletandServletConfiginterfaces.ThoseservletsextendingtheGenericServletclassshalloverridetheservicemethod.Finally,inordertodevelopanHTTPservletforuseontheWebthatservesrequestsusingtheHTTPprotocol,yourservletmustextendtheHttpServletinstead.CheckServletexampleshere.
95.ExplainthelifecycleofaServlet.Oneveryclientsrequest,theServletEngineloadstheservletsandinvokesitsinitmethods,inorderfortheservlettobeinitialized.Then,theServletobjecthandlesallsubsequentrequestscomingfromthatclient,byinvokingtheservicemethodforeachrequestseparately.Finally,theservletisremovedbycallingtheserversdestroymethod.
96.WhatisthedifferencebetweendoGet()anddoPost()?doGET
:TheGETmethodappendsthenamevaluepairsontherequestsURL.Thus,thereisalimitonthenumberofcharactersandsubsequentlyonthenumberofvaluesthatcanbeusedinaclientsrequest.Furthermore,thevaluesoftherequestaremadevisibleandthus,sensitiveinformationmustnotbepassedinthatway.doPOST
:ThePOSTmethodovercomesthelimitimposedbytheGETrequest,bysendingthevaluesoftherequestinsideitsbody.Also,thereisnolimitationsonthenumberofvaluestobesentacross.Finally,thesensitiveinformationpassedthroughaPOSTrequestisnotvisibletoanexternalclient.
97.WhatismeantbyaWebApplication?AWebapplicationisadynamicextensionofaWeborapplicationserver.Therearetwotypesofwebapplications:presentationorientedandserviceoriented.ApresentationorientedWebapplicationgeneratesinteractivewebpages,whichcontainvarioustypesofmarkuplanguageanddynamiccontentinresponsetorequests.Ontheotherhand,aserviceorientedwebapplicationimplementstheendpointofawebservice.Ingeneral,aWebapplicationcanbeseenasacollectionofservletsinstalledunderaspecificsubsetoftheserversURLnamespace.
98.WhatisaServerSideInclude(SSI)?ServerSideIncludes(SSI)isasimpleinterpretedserversidescriptinglanguage,usedalmostexclusivelyfortheWeb,andisembeddedwithaservlettag.ThemostfrequentuseofSSIistoincludethecontentsofoneormorefilesintoaWebpageonaWebserver.WhenaWebpageisaccessedbyabrowser,theWebserverreplacestheservlettaginthatWebpagewiththehypertextgeneratedbythecorrespondingservlet.
99.WhatisServletChaining?ServletChainingisthemethodwheretheoutputofoneservletissenttoasecondservlet.Theoutputofthesecondservletcanbesenttoathirdservlet,andsoon.Thelastservletinthechainisresponsibleforsendingtheresponsetotheclient.
100.Howdoyoufindoutwhatclientmachineismakingarequesttoyourservlet?TheServletRequestclasshasfunctionsforfindingouttheIPaddressorhostnameoftheclientmachine.getRemoteAddr()getstheIPaddressoftheclientmachineandgetRemoteHost()getsthehostnameoftheclientmachine.Seeexamplehere.
101.WhatisthestructureoftheHTTPresponse?TheHTTPresponseconsistsofthreeparts:
StatusCode:describesthestatusoftheresponse.Itcanbeusedtocheckiftherequesthasbeensuccessfullycompleted.Incasetherequestfailed,thestatuscodecanbeusedtofindoutthereasonbehindthefailure.Ifyourservletdoesnotreturnastatuscode,thesuccessstatuscode,HttpServletResponse.SC_OK,isreturnedbydefault.
HTTPHeaders:theycontainmoreinformationabouttheresponse.Forexample,theheadersmayspecifythedate/timeafterwhichtheresponseisconsideredstale,ortheformofencodingusedtosafelytransfertheentitytotheuser.Seehowtoretrieveheadersin
9/6/2015 115JavaInterviewQuestionsandAnswersTheULTIMATEList
http://www.javacodegeeks.com/2014/04/javainterviewquestionsandanswers.html 16/28
Servlethere.Body:itcontainsthecontentoftheresponse.ThebodymaycontainHTMLcode,animage,etc.ThebodyconsistsofthedatabytestransmittedinanHTTPtransactionmessageimmediatelyfollowingtheheaders.
102.Whatisacookie?Whatisthedifferencebetweensessionandcookie?AcookieisabitofinformationthattheWebserversendstothebrowser.ThebrowserstoresthecookiesforeachWebserverinalocalfile.Inafuturerequest,thebrowser,alongwiththerequest,sendsallstoredcookiesforthatspecificWebserver.Thedifferencesbetweensessionandacookiearethefollowing:
Thesessionshouldwork,regardlessofthesettingsontheclientbrowser.Theclientmayhavechosentodisablecookies.However,thesessionsstillwork,astheclienthasnoabilitytodisablethemintheserverside.
Thesessionandcookiesalsodifferintheamountofinformationthecanstore.TheHTTPsessioniscapableofstoringanyJavaobject,whileacookiecanonlystoreStringobjects.
103.Whichprotocolwillbeusedbybrowserandservlettocommunicate?ThebrowsercommunicateswithaservletbyusingtheHTTPprotocol.
104.WhatisHTTPTunneling?HTTPTunnelingisatechniquebywhich,communicationsperformedusingvariousnetworkprotocolsareencapsulatedusingtheHTTPorHTTPSprotocols.TheHTTPprotocolthereforeactsasawrapperforachannelthatthenetworkprotocolbeingtunneledusestocommunicate.ThemaskingofotherprotocolrequestsasHTTPrequestsisHTTPTunneling.
105.WhatsthedifferencebetweensendRedirectandforwardmethods?ThesendRedirectmethodcreatesanewrequest,whiletheforwardmethodjustforwardsarequesttoanewtarget.Thepreviousrequestscopeobjectsarenotavailableafteraredirect,becauseitresultsinanewrequest.Ontheotherhand,thepreviousrequestscopeobjectsareavailableafterforwarding.FInally,ingeneral,thesendRedirectmethodisconsideredtobeslowercomparetotheforwardmethod.
106.WhatisURLEncodingandURLDecoding?TheURLencodingprocedureisresponsibleforreplacingallthespacesandeveryotherextraspecialcharacterofaURL,intotheircorrespondingHexrepresentation.Incorrespondence,URLdecodingistheexactoppositeprocedure.
JSP107.WhatisaJSPPage?AJavaServerPage(JSP)isatextdocumentthatcontainstwotypesoftext:staticdataandJSPelements.Staticdatacanbeexpressedinanytextbasedformat,suchasHTMLorXML.JSPisatechnologythatmixesstaticcontentwithdynamicallygeneratedcontent.SeeJSPexamplehere.
108.HowaretheJSPrequestshandled?OnthearrivalofaJSPrequest,thebrowserfirstrequestsapagewitha.jspextension.Then,theWebserverreadstherequestandusingtheJSPcompiler,theWebserverconvertstheJSPpageintoaservletclass.NoticethattheJSPfileiscompiledonlyonthefirstrequestofthepage,oriftheJSPfilehaschanged.Thegeneratedservletclassisinvoked,inordertohandlethebrowsersrequest.Oncetheexecutionoftherequestisover,theservletsendsaresponsebacktotheclient.SeehowtogetRequestparametersinaJSP.
109.WhataretheadvantagesofJSP?TheadvantagesofusingtheJSPtechnologyareshownbelow:
JSPpagesaredynamicallycompiledintoservletsandthus,thedeveloperscaneasilymakeupdatestopresentationcode.
JSPpagescanbeprecompiled.
JSPpagescanbeeasilycombinedtostatictemplates,includingHTMLorXMLfragments,withcodethatgeneratesdynamiccontent.
DeveloperscanoffercustomizedJSPtaglibrariesthatpageauthorsaccessusinganXMLlikesyntax.
Developerscanmakelogicchangesatthecomponentlevel,withouteditingtheindividualpagesthatusetheapplicationslogic.
110.WhatareDirectives?WhatarethedifferenttypesofDirectivesavailableinJSP?DirectivesareinstructionsthatareprocessedbytheJSPengine,whenthepageiscompiledtoaservlet.Directivesareusedtosetpagelevelinstructions,insertdatafromexternalfiles,andspecifycustomtaglibraries.Directivesaredefinedbetween< %@ and % >
.Thedifferenttypesofdirectivesareshownbelow:
Include directive
:itisusedtoincludeafileandmergesthecontentofthefilewiththecurrentpage.
Page directive
:itisusedtodefinespecificattributesintheJSPpage,likeerrorpageandbuffer.
Taglib
:itisusedtodeclareacustomtaglibrarywhichisusedinthepage.
111.WhatareJSPactions?JSPactionsuseconstructsinXMLsyntaxtocontrolthebehavioroftheservletengine.JSPactionsareexecutedwhenaJSPpageisrequested.Theycanbedynamicallyinsertedintoafile,reuseJavaBeanscomponents,forwardtheusertoanotherpage,orgenerateHTMLfortheJavaplugin.Someoftheavailableactionsarelistedbelow:
jsp:include
9/6/2015 115JavaInterviewQuestionsandAnswersTheULTIMATEList
http://www.javacodegeeks.com/2014/04/javainterviewquestionsandanswers.html 17/28
includesafile,whentheJSPpageisrequested.
jsp:useBean
findsorinstantiatesaJavaBean.
jsp:setProperty
setsthepropertyofaJavaBean.
jsp:getProperty
getsthepropertyofaJavaBean.
jsp:forward
forwardstherequestertoanewpage.
jsp:plugin
generatesbrowserspecificcode.
112.WhatareScriptlets?InJavaServerPages(JSP)technology,ascriptletisapieceofJavacodeembeddedinaJSPpage.Thescriptletiseverythinginsidethetags.Betweenthesetags,ausercanaddanyvalidscriplet.
113.WhatareDecalarations?DeclarationsaresimilartovariabledeclarationsinJava.Declarationsareusedtodeclarevariablesforsubsequentuseinexpressionsorscriptlets.Toaddadeclaration,youmustusethesequencestoencloseyourdeclarations.
114.WhatareExpressions?AJSPexpressionisusedtoinsertthevalueofascriptinglanguageexpression,convertedintoastring,intothedatastreamreturnedtotheclient,bythewebserver.Expressionsaredefinedbetween
tags.
115.Whatismeantbyimplicitobjectsandwhatarethey?JSPimplicitobjectsarethoseJavaobjectsthattheJSPContainermakesavailabletodevelopersineachpage.Adevelopercancallthemdirectly,withoutbeingexplicitlydeclared.JSPImplicitObjectsarealsocalledpredefinedvariables.ThefollowingobjectsareconsideredimplicitinaJSPpage:
application
page
request
response
session
exception
out
config
pageContext
Stillwithus?Wow,thatwasahugearticleaboutdifferenttypesofquestionsthatcanbeusedinaJavainterview.Ifyouenjoyedthis,thensubscribetoournewslettertoenjoyweeklyupdatesandcomplimentarywhitepapers!Also,checkoutJCGAcademyformoreadvancedtraining!
So,whatotherJavainterviewquestionsarethere?Letusknowinthecommentsandwewillincludetheminthearticle!Happycoding!
Taggedwith: INTERVIEW INTERVIEWQUESTIONS JAVAAPPLETS JDBC JSP RMI SERVLETS SWING ULTIMATE
DoyouwanttoknowhowtodevelopyourskillsettobecomeaJavaRockstar?
SubscribetoournewslettertostartRockingrightnow!TogetyoustartedwegiveyouourbestsellingeBooksforFREE!
9/6/2015 115JavaInterviewQuestionsandAnswersTheULTIMATEList
http://www.javacodegeeks.com/2014/04/javainterviewquestionsandanswers.html 18/28
1.JPAMiniBook2.JVMTroubleshootingGuide3.JUnitTutorialforUnitTesting4.JavaAnnotationsTutorial5.JavaInterviewQuestions6.SpringInterviewQuestions7.AndroidUIDesign
andmanymore....
Emailaddress:
Youremailaddress
Signup
LearnWebDesign&CodingLearnhowtobuildapps&websites.Startlearningforfreetoday!
Treehouse
86 COMMENTS
April11th,2014at10:05amaerobless
Thatlistseemsreallygood.IstudycomputerscienceanditlldefinitelycomeinhandyonceIstartlookingforajob.
Reply
April13th,2014at12:51pmleon
OnesmallerroronhashCodeandequals:if2instancesareequal,theymustprovidethesamehashCode,BUTtwodifferentinstancesmayreturnthesamehashCode.
HavinghashCodealwaysreturn1orsomeotherfixednumbersatisfiesthecontract,althoughitwouldkilltheperformanceofHashMapandotherhashrelatedfunctionality.
ThehashCodejustdeterminesinwhichhashmapbuckettheinstanceisput,andwithinthatbucketthecorrectinstanceisthenlookedupwiththemuchmoreexpensiveequals.
Reply
April15th,2014at1:55amteoman
perfectpost,thanksforsharing.
Reply
June19th,2014at10:55amMadirajuKrishnaChaitanya
NicePost.Thanksforsharingthiswithus.
Reply
July2nd,2014at3:21pmSumitBisht
Thisiscorrect,butmanytopicsareoutdatedhere.
Reply
August13th,2014at12:13pmJeffreyBurch
9/6/2015 115JavaInterviewQuestionsandAnswersTheULTIMATEList
http://www.javacodegeeks.com/2014/04/javainterviewquestionsandanswers.html 19/28
Yeah,thereshouldbesomequestionsaboutJava8features.Itwilltellifthecandidateputsanyeffortintoselfimprovement.
Reply
July8th,2014at1:28pmNikitha
Reallyperfectpost,thanksforsharingwithus.
Reply
July17th,2014at4:24pmRobertMartin
Thisisaqualitypeaceofwork.Thankyoufortheeffort.
Reply
August18th,2014at7:12pmVlad
ThankstotheauthorIappreciateyoureffortstowriteeverythinginoneplace
Reply
August26th,2014at7:18pmraghukumarchalla
goodveryusefultoallfreshengineeringgraduatesandexperiancedtogetintojobeasily.
Reply
September1st,2014at1:48pmM.Hagras
Thanksalot,itisveryuseful
Reply
September1st,2014at9:34pmTk
Verygoodwork.ItwouldbereallygreatifyoucouldaddmorequestionsespeciallyonthenewversionsofJava.Also,fewimplementationexamplescanbepostedfordifferentconcept.Youhavedoneagreatjob.
Reply
September11th,2014at10:57amRAVIKUMAR.M
Itisveryusefulforjobseekerstogetagreatjob.thanksforsharingwithus.
Reply
September15th,2014at5:40pmRuth
Thankssomuchforthiscompilation.Itisveryuseful.
Reply
September17th,2014at10:28pmNazim
Thanks,butfoundsomeinaccuracies:Q33OtherthreadsareabletomodifyCollectionofsomeIterator,butnextcalledmethodonIteratorwillthrowConcurrentModificationExceptionQ37Itisrecommendednottooverridefinalize()methodinordertoreleaseresourceasJVMdoesnotguaranteethismethodtobeinvoked.
Reply
9/6/2015 115JavaInterviewQuestionsandAnswersTheULTIMATEList
http://www.javacodegeeks.com/2014/04/javainterviewquestionsandanswers.html 20/28
September26th,2014at12:05pmsatishshirale
Thanks,Irefreshedmyjavaknowledgeonceagain.
Reply
September27th,2014at9:46amGuarav
Thanksveryuseful
Reply
October19th,2014at11:27amMadhu
Thankstotheauthor!Keepupdating!
Reply
October23rd,2014at4:55pmJun
nicejob.ThankYou.Thistutorialisveryusefulforpeoplewhoseekjobinprogramming.Ijustlovecoding.
Reply
October24th,2014at6:38pmAkansha
niceinfrmation
Reply
October26th,2014at1:43amAhmedMansour
niceinfrmation
Reply
October27th,2014at2:50pmManjunath
Superinformation
Reply
October27th,2014at2:51pmManjunath
Veryusefultous
Reply
November17th,2014at8:35pmSotiriosEfstathiosManeas
Thanksalotforyourcomments!
Reply
October28th,2014at6:07pmYS
Greatsourceofupdatedinfo.Keepitup.Thanks.
Reply
November17th,2014at8:35pmSotiriosEfstathiosManeas
Thanksalot!
9/6/2015 115JavaInterviewQuestionsandAnswersTheULTIMATEList
http://www.javacodegeeks.com/2014/04/javainterviewquestionsandanswers.html 21/28
Reply
October31st,2014at1:47pmvalentin
whereisthelinktodownloadthislist?
Reply
May21st,2015at4:24pmpriyanga
linkfordownload
Reply
November1st,2014at2:55pmRainerAlfldi
YouranswertotheHashMapquestion(24)iswrong.AHashMapworksevenifthekeysallreturnhashcode1.Hashcodedefinesthebuckets,equalsisusedforequalitychecking.Therearemoreproblemswithboththequestionsandtheanswers.
Reply
November17th,2014at8:39pmSotiriosEfstathiosManeas
Thanksalotforyourfeedback,Icorrectedmyresponseinquestion24.
Moreover,youaremorethanwelcometodiscussyourproblemsaboutboththequestionsandanswers.
Reply
November6th,2014at7:29amAmiruddin
WhereisthedownloadLink?
Reply
November12th,2014at3:05amsachdeva
wherecanwedownloadthis?plzsendmethelinkonmymailid.thanks
Reply
November13th,2014at1:49amtn
ThereisadetailedexplanationofHashMapinternalsathttp://javahungry.blogspot.com/2013/08/hashinghowhashmapworksinjavaor.htmlandJDK6sourcecodeisathttp://hg.openjdk.java.net/jdk6/jdk6/jdk/file/a42d6999734b/src/share/classes/java/util/HashMap.java.
RaineriscorrectinthatHashMapwillacceptmultiplekeyswiththesamehashCode.ItestedthiswithaclasswhereallinstanceshaveahashCodeof1.TosomeextentHashMapcompensatesforthisbyhashingthehashCodesofkeys.MultiplekeyscanhavethesamehashCodesinceitisusedtodeterminethebucketonlyinwhichisstoredalistofEntityobjectswhicharedistinguishedbytheresultofequalsonthevalues.TheEntityclassisdefinedasanimplementationofMap.Entrywiththeadditionofanextfieldwhichisincludedinitsconstructorandusedforiteration.
Reply
November17th,2014at8:40pmSotiriosEfstathiosManeas
Thanksalotforyourfeedback,Icorrectedmyresponseinquestion24.
Reply
November16th,2014at10:27pmJose
Hi,
Youshouldcorrecttheanswertothe13question(Explaintheavailablethreadstatesinahighlevel?).Itisquitewrong.
ItdoesnotexistastatecalledRunningorSleepeing.
9/6/2015 115JavaInterviewQuestionsandAnswersTheULTIMATEList
http://www.javacodegeeks.com/2014/04/javainterviewquestionsandanswers.html 22/28
Takealook:https://docs.oracle.com/javase/7/docs/api/java/lang/Thread.State.html
BR
Reply
November17th,2014at8:41pmSotiriosEfstathiosManeas
Iwasdescribingthestatesofathreadintheperspectiveoftheoperatingsystem,butitwasnotclear.
Iupdatedmyresponse,inordertodescribethestatesofathread,asbeingregardedbytheJavaVirtualMachine(JVM).
Reply
November17th,2014at10:10pmtn
Question39actuallyincludestwoquestionsthesecondofwhichisnotanswered.Pleaseanswerthissecondquestion,whichisWhatisPermGenspaceinHeap?.Thanks
Reply
November17th,2014at11:07pmtn
Regardingquestion39WhatisPermGenspaceinHeap?,accordingtoonereplyathttp://stackoverflow.com/questions/4223809/isjavapermgenspacepartofthetotalvmmemory,InSunsJVM,thepermanentgenerationisnotpartoftheheap.Itsadifferentspaceforclassdefinitionsandrelateddata,aswellaswhereinternedstringslive.TheJavaVMSpecificationJavaSE7Edition(https://docs.oracle.com/javase/specs/jvms/se7/jvms7.pdf)doesnotmentionpermanentgeneration,PermGen.orPermGen(caseinvariant).HoweveritdoesmentiontheMethodAreaintermsthatresemblePermGenfunctionalityandaccordingtoareplyathttp://stackoverflow.com/questions/9095748/methodareaandpermgen,theMethodAreacouldbeconsideredtobeasubsetofPermGen.ThisinducesmethinkthatPermGenisalogicalconstructthatmapstomorethanonerealmemoryareaorsubarea.
Also,PermGenimplementationmaydependonthespecificJVM.Forexample,accordingtoareplyathttp://stackoverflow.com/questions/4848669/permspacevsheapspace,JVMslikeJRocketdonthavePermGenatall,everythingisstoredinheap.OnlyinsuchcontextcanyoucallPermGenaspecialpartofheap.
Foranotherexample,inOraclesJava8JVMs,PermGenisreplacedbyMetaspace,accordingtohttp://www.javacodegeeks.com/2013/02/java8frompermgentometaspace.html.Howeverneithermetaspace,PermGen,orPermGen(caseinvariant)arementionedintheJavaVMSpecificationJavaSE8Edition(https://docs.oracle.com/javase/specs/jvms/se8/jvms8.pdf).IconcludethatMetaspaceisalogicalconstructlikePermGenwhichhasaJVMoptioninterfaceandcorrespondstooperationsovermorethanonememoryareasorregionsinthem.
ItwouldbeusefultoclarifythedistinctionbetweenactualJVMruntimeareas,asdocumentedintheJVMspecificationmanuals,andlogicalmappingstothemmadeavailablethroughJVMoptions.ButthiswouldbedifficulttodoexhaustivelyandauthoritativelyduetoaprobablelackofdetaileddocumentationanddifficultyinunderstandingJVMsourcecodeifitisavailable.SomeusefulcluesmightbeobtainedbyinspectingOpenJDKsourceswhichareavailableathttp://download.java.net/openjdk/.
However,IbelievethatthislevelofknowledgeisnotnecessaryformostJavadeveloperpositionsandwouldapplyonlyonlyforJavaJVMdeveloperpositions.
Reply
November19th,2014at2:10amyax
thankyou!
Reply
November22nd,2014at2:22amMohit
justAwesome
Reply
November22nd,2014at12:38pmLEo
WhereisthePDFlink?
Reply
November26th,2014at12:18pmHARSHRASTOGI
Hello!sir..IwanttohavesomeknowledgeaboutwhatissomewhenaprogramisrunHowtheobjectiscreated???Howtheloaderswork??Everything.Anyhelpwebepraised.
Reply
9/6/2015 115JavaInterviewQuestionsandAnswersTheULTIMATEList
http://www.javacodegeeks.com/2014/04/javainterviewquestionsandanswers.html 23/28
November26th,2014at1:06pmadada
whereisthelink?
Reply
November28th,2014at8:48pmAshot
Question37.Itsaverybadideatoreleaseresourcesinfinalize()methodbecausethereisnogarantiesthatthismethodwillbeinvoked.
Reply
December8th,2014at11:26pmTdogg
Thisistrue.Itisbesttoavoidthefinalizemethodasitsbehaviorisunreliable
Reply
December11th,2014at8:27pmabhisheksauda
Mostefficientfortheguys..whostudiesadaybeforeVivathanksman!
Reply
December13th,2014at4:05pmInstanceofjava
reallyhelpful.thnkyousomuch
Reply
December17th,2014at12:30amsmitha
Awesome..ThewayIneeded.Thanksheaps
Reply
December22nd,2014at6:49pmwojtek
Niceonemate.Veryinformative
Reply
December23rd,2014at3:08pmArisha
greatwork..iwishifyoucouldincludethequestionsaboutstrutsandhibernatealso!
Reply
December28th,2014at7:27pmBalajiKorangi
115JavaInterviewQuestionsandAnswersTheULTIMATEList(PDFDownload)
Howandwheretodownload?
Reply
January13th,2015at10:51pmSauravSingh
WhereisthelinktodownloadthePDF?
Iamalreadyasubscriber.#help
Reply
9/6/2015 115JavaInterviewQuestionsandAnswersTheULTIMATEList
http://www.javacodegeeks.com/2014/04/javainterviewquestionsandanswers.html 24/28
January16th,2015at5:58pmAndrii
SoImnotaloneinfactthatthereisno(promised)pdfaround?
btwthelistisreallygood
Reply
January17th,2015at7:17amJosRomero
Awesomecontent.Veryusefullandinteresting.
Reply
January18th,2015at2:20pmRanga
Perfectstartforbeginners.Ialsofindthisvideoveryusefulforfreshers.Coverstheimportantinterviewquestionsinvideoformat.
https://www.youtube.com/watch?v=njZ48YVkei0
Reply
January18th,2015at5:37pmAsad
Whereisthepffifyoualreadyamember?Hopethistime,Iwouldgetananswerformyquestion
Reply
January26th,2015at3:21pmkevin
verynicejob,thankyoualot.itwillbehelpfulformycomminginterveiws
Reply
January31st,2015at6:42pmPramod
Verynicequestions.veryhelpful
Reply
February6th,2015at5:50amMohdFurkan
Itisanicecollectionofquestions.Thankyoualot.
Reply
February10th,2015at11:55pmJonathan
Nicecollection.Afewcomments:Question4>Astaticmethodmayaccessaninstancevariable,butonlyifgetsaccesstoaninstanceofaclassstaticintmymethod(Aa){returna.instanceVar+2}Question8>Technically,Javadoespermitaformofmultipleinheritance,namelymultipleinheritanceoftype.Seehereformoreinfohttp://docs.oracle.com/javase/tutorial/java/IandI/multipleinheritance.htmlQuestion44>exceptedshouldbeexpected
Reply
February11th,2015at6:04amPramod
Verynicecollectionofinterviewquestions.veryhelpfulforinterview
Reply
February14th,2015at4:45pmYusuf
9/6/2015 115JavaInterviewQuestionsandAnswersTheULTIMATEList
http://www.javacodegeeks.com/2014/04/javainterviewquestionsandanswers.html 25/28
Really,whereisthePDFLink?Itsbeenaskedformanytimesbutthereisnoreply.
Reply
February22nd,2015at1:26amwahoo
Yoosoofreally?Trytobegratefulforthissiteinsteadofmakingdemandsreally.
Asfortheotherscomplainingitisoutdatedwhydontyoucomeupwithasiteyourselves.
ThanksManeas!
Reply
February22nd,2015at7:28pmYusuf
Thisisnotcompliantforthesite.Exactopposite,Imoneofthefansofthesiteandmanyarticlespublishedonit.
IjusttriedtofindoutwhyIcannotreachPDFversionsofsomearticles,evenhavingmembershipofnewsletter.ButIcouldnotseeanykindofexplanationthatByronnoticedwithbelowcomment.ThisiswhyIwrotemycomment.
Ithink,wahoo,youshouldtrytobemoreunderstandingaboutwhatpeoplearetryingtosay.
Reply
February22nd,2015at3:26amByronKiourtzoglou
Helloall,
InordertogettheeBookthePDFversionofthisarticleyouhavetosubscribetoournewsletter.Thisisclearlystatedatthebeginningofthepostwherethesubscriptionformresides.
IfyouarealreadyamemberofournewsletteranddidnotreceivetheeBook,pleaseshootusanemailatoursupportaddressandwewillhelpyouout.
Bestregards,Byron
Reply
February22nd,2015at7:33pmYusuf
ThanksByron,
Yougavetheexactanswerofmyquestion.AsImentionedinthereplyofwahooscomment,Iamalreadyamemberofnewsletter,andgotmanyPDFversionsofarticles.Butforsomearticles,likethisone,Icouldtgetit.
Iwillsendanemail.
Regards
Reply
February23rd,2015at4:04amJavaRock
PleasemailmethepdffortheJavainterviewQuestionsPDF.Nicearticle
Reply
March11th,2015at5:37pmpreeti
PleasemailmethepdfofJavainterviewquestions
Reply
March13th,2015at7:03amyash
goodeffortitsreallyhelpful
Reply
9/6/2015 115JavaInterviewQuestionsandAnswersTheULTIMATEList
http://www.javacodegeeks.com/2014/04/javainterviewquestionsandanswers.html 26/28
April1st,2015at12:15amKrishnan
Thankyousomuch!Itshouldbeincrediblyusefulforjobinterviews.
Reply
April1st,2015at1:28pmbharat
Thanksalotguys
Reply
April5th,2015at2:18pmishara
Verygoodpostthankyouverymuch
Reply
April5th,2015at10:35pmAmernath
Goodone
Reply
April7th,2015at11:50amGratian
Very,verygoodlistofquestionsandanswers.Goodjob!
Reply
April9th,2015at4:12amRR
GoodCollectionofJavaInterviewquestions.
Reply
April15th,2015at5:11pmOmar
Wellwrittenandtothepoint.Thankyou!
Reply
April18th,2015at10:24amali
Giveacompelling(technical)argumentwhythetitfortatpolicyasusedinBitTorrentisfarfromoptimalforfilesharingintheInternet
Reply
April20th,2015at7:03pmArnab
thanksithelpedalot
Reply
April28th,2015at11:00amRahulTilloo
Iamreallythankfultotheauthorforasuchagreatresource.TomorrowIhaveaninterviewforJAVASothisguidewouldbereallyhelpful.Inspiredfromyourarticleifyoudoguestpostingdoletmeknow.
Reply
May6th,2015at7:34pmAbdul
GoodJob
9/6/2015 115JavaInterviewQuestionsandAnswersTheULTIMATEList
http://www.javacodegeeks.com/2014/04/javainterviewquestionsandanswers.html 27/28
Reply
May11th,2015at4:10amd
YoudidntsendthelinktothePDFfilefortheebook.pleasedoso.
Reply
May14th,2015at2:31pmprakash
Verygoodpostthankyouverymuch
Reply
May23rd,2015at3:24pmshobs
Doesnyoneknowwhatkindofinterviewquestionscanbeaskedfrom10+yrsofexpinjava.anysamplecollection?
Reply
May28th,2015at5:31amLongwuXiao
regist
Reply
May28th,2015at5:34amLongwuXiao
canIgetthePDF?
Reply
June1st,2015at2:22pmUrgen
whereismypdfversionplease?
Reply
LEAVE A REPLY
Youremailaddresswillnotbepublished.Requiredfieldsaremarked*
Name*
Email*
Website
one=7
Notifymeoffollowupcommentsviaemail.Youcanalsosubscribewithoutcommenting.
Signmeupforthenewsletter!
PostComment
9/6/2015 115JavaInterviewQuestionsandAnswersTheULTIMATEList
http://www.javacodegeeks.com/2014/04/javainterviewquestionsandanswers.html 28/28
KNOWLEDGE BASE
Academy
Examples
Library
Resources
Tutorials
Whitepapers
PARTNERS
Mkyong
THE CODE GEEKS NETWORK
.NETCodeGeeks
JavaCodeGeeks
WebCodeGeeks
HALL OF FAME
11OnlineLearningwebsitesthatyoushouldcheckout
AdvantagesandDisadvantagesofCloudComputingCloudcomputingprosandcons
AndroidGoogleMapsTutorial
AndroidJSONParsingwithGsonTutorial
AndroidLocationBasedServicesApplicationGPSlocation
AndroidQuickPreferencesTutorial
DifferencebetweenComparatorandComparableinJava
GWT2Spring3JPA2Hibernate3.5Tutorial
JavaBestPracticesVectorvsArrayListvsHashSet
AndroidFullApplicationTutorialseries
ABOUT JAVA CODE GEEKS
JCGs(JavaCodeGeeks)isanindependentonlinecommunityfocusedoncreatingtheultimateJavatoJavadevelopersresourcecentertargetedatthetechnicalarchitect,technicalteamlead(seniordeveloper),projectmanagerandjuniordevelopersalike.JCGsservetheJava,SOA,AgileandTelecomcommunitieswithdailynewswrittenbydomainexperts,articles,tutorials,reviews,announcements,codesnippetsandopensourceprojects.
DISCLAIMER
AlltrademarksandregisteredtrademarksappearingonExamplesJavaCodeGeeksarethepropertyoftheirrespectiveowners.JavaisatrademarkorregisteredtrademarkofOracleCorporationintheUnitedStatesandothercountries.ExamplesJavaCodeGeeksisnotconnectedtoOracleCorporationandisnotsponsoredbyOracleCorporation.
JavaCodeGeeksandallcontentcopyright20102015,ExelixisMediaP.C.|TermsofUse|PrivacyPolicy|Contact
Top Related