下載本文檔
版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
WhatisthemostimportantfeatureofJava?Javaisaplatformindependentlanguage.Whatdoyoumeanbyplatformindependence?Platformindependencemeansthatwecanwriteandcompilethejavacodeinoneplatform(egWindows)andcanexecutetheclassinanyothersupportedplatformeg(Linux,Solaris,etc).WhatisaJVM?JVMisJavaVirtualMachinewhichisaruntimeenvironmentforthecompiledjavaclassfiles.AreJVM'splatformindependent?JVM'sarenotplatformindependent.JVM'sareplatformspecificruntimeimplementationprovidedbythevendor.WhatisthedifferencebetweenaJDKandaJVM?JDKisJavaDevelopmentKitwhichisfordevelopmentpurposeanditincludesexecutionenvironmentalso.ButJVMispurelyaruntimeenvironmentandhenceyouwillnotbeabletocompileyoursourcefilesusingaJVM.WhatisapointeranddoesJavasupportpointers?Pointerisareferencehandletoamemorylocation.ImproperhandlingofpointersleadstomemoryleaksandreliabilityissueshenceJavadoesn'tsupporttheusageofpointers.Whatisthebaseclassofallclasses?java.!ang.ObjectDoesJavasupportmultipleinheritance?Javadoesn'tsupportmultipleinheritance.IsJavaapureobjectorientedlanguage?Javausesprimitivedatatypesandhenceisnotapureobjectorientedlanguage.Arearraysprimitivedatatypes?InJava,Arraysareobjects.WhatisdifferencebetweenPathandClasspath?PathandClasspathareoperatingsystemlevelenvironmentvariales.Pathisuseddefinewherethesystemcanfindtheexecutables(.exe)filesandclasspathisusedtospecifythelocation.classfiles.Whatarelocalvariables?Localvaraiablesarethosewhicharedeclaredwithinablockofcodelikemethods.Localvariablesshouldbeinitialisedbeforeaccessingthem.Whatareinstancevariables?Instancevariablesarethosewhicharedefinedattheclasslevel.Instancevariablesneednotbeinitializedbeforeusingthemastheyareautomaticallyinitializedtotheirdefaultvalues.HowtodefineaconstantvariableinJava?Thevariableshouldbedeclaredasstaticandfinal.Soonlyonecopyofthevariableexistsforallinstancesoftheclassandthevaluecan'tbechangedalso.staticfinalintMAX_LENGTH=50;isanexampleforconstant.Shouldamain()methodbecompulsorilydeclaredinalljavaclasses?Nonotrequired.main()methodshouldbedefinedonlyifthesourceclassisajavaapplication.Whatisthereturntypeofthemain()method?Main()methoddoesn'treturnanythinghencedeclaredvoid.Whyisthemain()methoddeclaredstatic?main()methodiscalledbytheJVMevenbeforetheinstantiationoftheclasshenceitisdeclaredasstatic.Whatisthearguementofmain()method?main()methodacceptsanarrayofStringobjectasarguement.Canamain()methodbeoverloaded?Yes.Youcanhaveanynumberofmain〇methodswithdifferentmethodsignatureandimplementationintheclass.Canamain()methodbedeclaredfinal?Yes.Anyinheritingclasswillnotbeabletohaveit'sowndefaultmain〇method.Doestheorderofpublicandstaticdeclarationmatterinmain()method?No.Itdoesn'tmatterbutvoidshouldalwayscomebeforemain().
Canasourcefilecontainmorethanoneclassdeclaration?YesasinglesourcefilecancontainanynumberofClassdeclarationsbutonlyoneoftheclasscanbedeclaredaspublic.Whatisapackage?Packageisacollectionofrelatedclassesandinterfaces.packagedeclarationshouldbefirststatementinajavaclass.Whichpackageisimportedbydefault?java.langpackageisimportedbydefaultevenwithoutapackagedeclaration.Canaclassdeclaredasprivatebeaccessedoutsideit'spackage?Notpossible.Canaclassbedeclaredasprotected?Theprotectedaccessmodifiercannotbeappliedtoclassandinterfaces.Methods,fieldscanbedeclaredprotected,howevermethodsandfieldsinainterfacecannotbedeclaredprotected.Whatistheaccessscopeofaprotectedmethod?Aprotectedmethodcanbeaccessedbytheclasseswithinthesamepackageorbythesubclassesoftheclassinanypackage.Whatisthepurposeofdeclaringavariableasfinal?Afinalvariable'svaluecan'tbechanged,finalvariablesshouldbeinitializedbeforeusingthem.Whatistheimpactofdeclaringamethodasfinal?Amethoddeclaredasfinalcan'tbeoverridden.Asubclasscan'thavethesamemethodsignaturewithadifferentimplementation.Idon'twantmyclasstobeinheritedbyanyotherclass.Whatshouldido?Youshoulddeclaredyourclassasfinal.Butyoucan'tdefineyourclassasfinal,ifitisanabstractclass.Aclassdeclaredasfinalcan'tbeextendedbyanyotherclass.31.CanyougivefewexamplesoffinalclassesdefinedinJavaAPI?java.lang.String,java.lang.MatharefinalClasses.finalisamodifierwhichcanbeappliedtoaclassoramethodoravariable,finalclasscan'tbeinherited,finalmethodcan*tbeoverriddenandfinalvariablecan'tbechanged.finallyisanexceptionhandlingcodesectionwhichgetsexecutedwhetheranexceptionisraisedornotbythetryblockcodesegment.finalize()isamethodofObjectclasswhichwillbeexecutedbytheJVMjustbeforegarbagecollectingobjecttogiveafinalchanceforresourcereleasingactivity.Canaclassbedeclaredasstatic?Wecannotdeclaretoplevelclassasstatic,butonlyinnerclasscanbedeclaredstatic.publicclassTest:(staticclassInnerClass:(publicstaticvoidlnnerMethod()?{System,out.printIn(**StaticInner:Class!n);)TOC\o"1-5"\h\z: }publicstaticvoidmain(Stringargs[]): (ITest.InnerClass.InnerMethod();■:) }//output:StaticInnerClass!Whenwillyoudefineamethodasstatic?Whenamethodneedstobeaccessedevenbeforethecreationoftheobjectoftheclassthenweshoulddeclarethemethodasstatic.Whataretherestrictionimposedonastaticmethodorastaticblockofcode?Astaticmethodshouldnotrefertoinstancevariableswithoutcreatinganinstanceandcannotuse"this"operatortorefertheinstance.IwanttoprintMHelloMevenbeforemain()isexecuted.Howwillyouacheivethat?Printthestatementinsideastaticblockofcode.Staticblocksgetexecutedwhentheclassgetsloadedintothememoryandevenbeforethecreationofanobject.Henceitwillbeexecutedbeforethemain〇method.Anditwillbeexecutedonlyonce.Whatistheimportanceofstaticvariable?32.Howisfinaldifferentfromfinallyandfinalize()?staticvariablesareclasslevelvariableswhereallobjectsoftheclassrefertothesamevariable.Ifoneobjectchangesthevaluethenthechangegetsreflectedinalltheobjects.
32.Howisfinaldifferentfromfinallyandfinalize()?Canwedeclareastaticvariableinsideamethod?Staticvaraiblesareclasslevelvariablesandtheycan'tbedeclaredinsideamethod.Ifdeclared,theclasswillnotcompile.WhatisanAbstractClassandwhatisit'spurpose?AClasswhichdoesn'tprovidecompleteimplementationisdefinedasanabstractclass.Abstractclassesenforceabstraction.Canaabstractclassbedeclaredfinal?Notpossible.Anabstractclasswithoutbeinginheritedisofnouseandhencewillresultincompiletimeerror.Whatisuseofaabstractvariable?Variablescan'tbedeclaredasabstract,onlyclassesandmethodscanbedeclaredasabstract.Canyoucreateanobjectofanabstractclass?Notpossible.Abstractclassescan'tbeinstantiated.Canaabstractclassbedefinedwithoutanyabstractmethods?Yesit*spossible.Thisisbasicallytoavoidinstancecreationoftheclass.ClassCimplementsInterfaceIcontainingmethodmlandm2declarations.ClassChasprovidedimplementationformethodm2.CanicreateanobjectofClassC?Nonotpossible,classcshouldprovideimplementationforallthemethodsintheinterfacei.Sinceciasscdidn*tprovideimplementationformimethod,ithastobedeclaredasabstract.Abstractclassescan*tbeinstantiated.CanamethodinsideaInterfacebedeclaredasfinal?Nonotpossible.Doingsowillresultincompilationerror,publicandabstractaretheonlyapplicablemodifiersformethoddeclarationinaninterface.CananInterfaceimplementanotherInterface?Intefacesdoesn'tprovideimplementationhenceainterfacecannotimplementanotherinterface.CananInterfaceextendanotherInterface?YesanInterfacecaninheritanotherInterface,forthatmatteranInterfacecanextendmorethanoneInterface.CanaClassextendmorethanoneClass?Notpossible.AClasscanextendonlyoneclassbutcanimplementanynumberofInterfaces.WhyisanInterfacebeabletoextendmorethanoneInterfacebutaClasscan'textendmorethanoneClass?BasicallyJavadoesn'tallowmultipleinheritance,soaClassisrestrictedtoextendonlyoneClass.ButanInterfaceisapureabstractionmodelanddoesn'thaveinheritancehierarchylikeclasses(dorememberthatthebaseclassofallclassesisObject).SoanInterfaceisallowedtoextendmorethanoneInterface.CananInterfacebefinal?Notpossible.Doingsosow川resultincompilationerror.CanaclassbedefinedinsideanInterface?Yesit'spossible.CananInterfacebedefinedinsideaclass?Yesit'spossible.WhatisaMarkerInterface?AnInterfacewhichdoesn'thaveanydeclarationinsidebutstillenforcesamechanism.WhichobjectorientedConceptisachievedbyusingoverloadingandoverriding?Polymorphism.WhydoesJavanotsupportoperatoroverloading?Operatoroverloadingmakesthecodeverydifficulttoreadandmaintain.Tomaintaincodesimplicity,Javadoesn'tsupportoperatoroverloading.Canwedefineprivateandprotectedmodifiersforvariablesininterfaces?No.WhatisExternalizable?ExternalizableisanInterfacethatextendsSerializableInterface.AndsendsdataintoStreamsinCompressedFormat.Ithastwomethods,writeExternal(ObjectOuputout)andreadExternal(Objectlnputin)WhatmodifiersareallowedformethodsinanInterface?Onlypublicandabstractmodifiersareallowedformethodsininterfaces.Whatisalocal,memberandaclassvariable?Variablesdeclaredwithinamethodare"local'*variables.Variablesdeclaredwithintheclassi.enotwithinanymethodsareMmember"variables(globalvariables).Variablesdeclaredwithintheclassi.enotwithinanymethodsandaredefinedas"static"areclassvariables.Whatisanabstractmethod?Anabstractmethodisamethodwhoseimplementationisdeferredtoasubclass.?Whatvaluedoesread()returnwhenithasreachedtheendofafile?Theread〇methodreturns-1whenithasreachedtheendofafile.?CanaByteobjectbecasttoadoublevalue?No,anobjectcannotbecasttoaprimitivevalue.?Whatisthedifferencebetweenastaticandanon-staticinnerclass?Anon-staticinnerclassmayhaveobjectinstancesthatareassociatedwithinstancesoftheclass*souterclass.Astaticinnerclassdoesnothaveanyobjectinstances.?Whatisanobject'slockandwhichobject'shavelocks?Anobject'slockisamechanismthatisusedbymultiplethreadstoobtainsynchronizedaccesstotheobject.Athreadmayexecuteasynchronizedmethodofanobjectonlyafterithasacquiredtheobject'slock.Allobjectsandclasseshavelocks.Aclass'slockisacquiredontheclass'sClassobject.?Whatisthe%operator?Itisreferredtoasthemoduloorremainderoperator.Itreturnstheremainderofdividingthefirstoperandbythesecondoperand.?Whencananobjectreferencebecasttoaninterfacereference?Anobjectreferencebecasttoaninterfacereferencewhentheobjectimplementsthereferencedinterface.Whichclassisextendedbyallotherclasses?TheObjectclassisextendedbyallotherclasses.Whichnon-Unicodelettercharactersmaybeusedasthefirstcharacterofanidentifier?Thenon-Unicodelettercharacters$and_mayappearasthefirstcharacterofanidentifierWhatrestrictionsareplacedonmethodoverloading?Twomethodsmaynothavethesamenameandargumentlistbutdifferentreturntypes.Whatiscasting?Therearetwotypesofcasting,castingbetweenprimitivenumerictypesandcastingbetweenobjectreferences.Castingbetweennumerictypesisusedtoconvertlargervalues,suchasdoublevalues,tosmallervalues,suchasbytevalues.Castingbetweenobjectreferencesisusedtorefertoanobjectbyacompatibleclass,interface,orarraytypereference.Whatisthereturntypeofaprogram'smain()method?void.Ifavariableisdeclaredasprivate,wheremaythevariablebeaccessed?Aprivatevariablemayonlybeaccessedwithintheclassinwhichitisdeclared.Whatdoyouunderstandbyprivate,protectedandpublic?Theseareaccessibilitymodifiers.Privateisthemostrestrictive,whilepublicistheleastrestrictive.Thereisnorealdifferencebetweenprotectedandthedefaulttype(alsoknownaspackageprotected)withinthecontextofthesamepackage,howevertheprotectedkeywordallowsvisibilitytoaderivedclassinadifferentpackage.WhatisDowncasting?Downcastingisthecastingfromageneraltoamorespecifictype,i.e.castingdownthehierarchyWhatmodifiersmaybeusedwithaninnerclassthatisamemberofanouterclass?A(non-local)innerclassmaybedeclaredaspublic,protected,private,static,final,orabstract.HowmanybitsareusedtorepresentUnicode,ASCII,UTF-16,andUTF-8characters?Unicoderequires16bitsandASCIIrequire7bitsAlthoughtheASCIIcharactersetusesonly7bits,itisusuallyrepresentedas8bits.UTF-8representscharactersusing8,16,and18bitpatterns.UTF-16uses16-bitandlargerbitpatterns.Whatrestrictionsareplacedonthelocationofapackagestatementwithinasourcecodefile?Apackagestatementmustappearasthefirstlineinasourcecodefile(excludingblanklinesandcomments).Whatisanativemethod?AnativemethodisamethodthatisimplementedinalanguageotherthanJava.Whatareorderofprecedenceandassociativity,andhowaretheyused?Orderofprecedencedeterminestheorderinwhichoperatorsareevaluatedinexpressions.Associatitydetermineswhetheranexpressionisevaluatedleft-to-rightorright-to-left.Canananonymousclassbedeclaredasimplementinganinterfaceandextendingaclass?Ananonymousclassmayimplementaninterfaceorextendasuperclass,butmaynotbedeclaredtodoboth.Whatistherangeofthechartype?Therangeofthechartypeis0to216-1(i.e.0to65535.)Whatistherangeoftheshorttype?Therangeoftheshorttypeis-(215)to215-1.(i.e.-32,768to32,767)Whyisn'tthereoperatoroverloading?BecauseC++hasprovenbyexamplethatoperatoroverloadingmakescodealmostimpossibletomaintain.Whatdoesitmeanthatamethodorfieldis"static',?Staticvariablesandmethodsareinstantiatedonlyonceperclass.Inotherwordstheyareclassvariables,notinstancevariables.Ifyouchangethevalueofastaticvariableinaparticularobject,thevalueofthatvariablechangesforallinstancesofthatclass.Staticmethodscanbereferencedwiththenameoftheclassratherthanthenameofaparticularobjectoftheclass(thoughthatworkstoo).That'showlibrarymethodslikeSystem.out.println()work,outisastaticfieldinthejava.lang.Systemclass.Isnullakeyword?Thenullvalueisnotakeyword.Whichcharactersmaybeusedasthesecondcharacterofanidentifier,butnotasthefirstcharacterofanidentifier?Thedigits0through9maynotbeusedasthefirstcharacterofanidentifierbuttheymaybeusedafterthefirstcharacterofanidentifier.Istheternaryoperatorwrittenx:y?zorx?y:z?Itiswrittenx?y:z.Howisroundingperformedunderintegerdivision?Thefractionalpartoftheresultistruncated.Thisisknownasroundingtowardzero.Ifaclassisdeclaredwithoutanyaccessmodifiers,wheremaytheclassbeaccessed?Aclassthatisdeclaredwithoutanyaccessmodifiersissaidtohavepackageaccess.Thismeansthattheclasscanonlybeaccessedbyotherclassesandinterfacesthataredefinedwithinthesamepackage.Doesaclassinherittheconstructorsofitssuperclass?Aclassdoesnotinheritconstructorsfromanyofitssuperclasses.NametheeightprimitiveJavatypes.Theeightprimitivetypesarebyte,char,short,int,long,float,double,andboolean.Whatrestrictionsareplacedonthevaluesofeachcaseofaswitchstatement?Duringcompilation,thevaluesofeachcaseofaswitchstatementmustevaluatetoavaluethatcanbepromotedtoanintvalue.Whatisthedifferencebetweenawhilestatementandadowhilestatement?Awhilestatementchecksatthebeginningofalooptoseewhetherthenextloopiterationshouldoccur.Adowhilestatementchecksattheendofalooptoseewhetherthenextiterationofaloopshouldoccur.Thedowhilestatementwillalwaysexecutethebodyofaloopatleastonce.Whatmodifierscanbeusedwithalocalinnerclass?Alocalinnerclassmaybefinalorabstract.Whendoesthecompilersupplyadefaultconstructorforaclass?Thecompilersuppliesadefaultconstructorforaclassifnootherconstructorsareprovided.Ifamethodisdeclaredasprotected,wheremaythemethodbeaccessed?Aprotectedmethodmayonlybeaccessedbyclassesorinterfacesofthesamepackageorbysubclassesoftheclassinwhichitisdeclared.Whatarethelegaloperandsoftheinstanceofoperator?Theleftoperandisanobjectreferenceornullvalueandtherightoperandisaclass,interface,orarraytype.Aretrueandfalsekeywords?Thevaluestrueandfalsearenotkeywords.WhathappenswhenyouaddadoublevaluetoaString?TheresultisaStringobject.Whatisthediffrencebetweeninnerclassandnestedclass?Whenaclassisdefinedwithinascopeodanotherclass,thenitbecomesinnerclass.Iftheaccessmodifieroftheinnerclassisstatic,thenitbecomesnestedclass.Cananabstractclassbefinal?Anabstractclassmaynotbedeclaredasfinal.Whatisnumericpromotion?Numericpromotionistheconversionofasmallernumerictypetoalargernumerictype,sothatintegerandfloating-pointoperationsmaytakeplace.Innumericalpromotion,byte,char,andshortvaluesareconvertedtointvalues.Theintvaluesarealsoconvertedtolongvalues,ifnecessary.Thelongandfloatvaluesareconvertedtodoublevalues,asrequired.Whatisthedifferencebetweenapublicandanonpublicclass?Apublicclassmaybeaccessedoutsideofitspackage.Anon-publicclassmaynotbeaccessedoutsideofitspackage.Towhatvalueisavariableofthebooleantypeautomaticallyinitialized?Thedefaultvalueofthebooleantypeisfalse.Whatisthedifferencebetweentheprefixandpostfixformsofthe++operator?Theprefixformperformstheincrementoperationandreturnsthevalueoftheincrementoperation.Thepostfixformreturnsthecurrentvaluealloftheexpressionandthenperformstheincrementoperationonthatvalue.Whatrestrictionsareplacedonmethodoverriding?Overriddenmethodsmusthavethesamename,argumentlist,andreturntype.Theoverridingmethodmaynotlimittheaccessofthemethoditoverrides.Theoverridingmethodmaynotthrowanyexceptionsthatmaynotbethrownbytheoverriddenmethod.WhatisaJavapackageandhowisitused?AJavapackageisanamingcontextforclassesandinterfaces.Apackageisusedtocreateaseparatenamespaceforgroupsofclassesandinterfaces.PackagesarealsousedtoorganizerelatedclassesandinterfacesintoasingleAPIunitandtocontrolaccessibilitytotheseclassesandinterfaces.Whatmodifiersmaybeusedwithatop-levelclass?Atop-levelclassmaybepublic,abstract,orfinal.Whatisthedifferencebetweenanifstatementandaswitchstatement?Theifstatementisusedtoselectamongtwoalternatives.Itusesabooleanexpressiontodecidewhichalternativeshouldbeexecuted.Theswitchstatementisusedtoselectamongmultiplealternatives.Itusesanintexpressiontodeterminewhichalternativeshouldbeexecuted.Whatarethepracticalbenefits,ifany,ofimportingaspecificclassratherthananentirepackage(e.g.import.*versusimport.Socket)?Itmakesnodifferenceinthegeneratedclassfilessinceonlytheclassesthatareactuallyusedarereferencedbythegeneratedclassfile.Thereisanotherpracticalbenefittoimportingsingleclasses,andthisariseswhentwo(ormore)packageshaveclasseswiththesamename.Takejava.util.Timerandjavax.swing.Timer,forexample.IfIimportjava.util.*andjavax.swing.*andthentrytouse"Timer",Igetanerrorwhilecompiling(theclassnameisambiguousbetweenbothpackages).Let'ssaywhatyoureallywantedwasthejavax.swing.Timerclass,andtheonlyclassesyouplanonusinginjava,utilareCollectionandHashMap.Inthiscase,somepeoplewillprefertoimportjava.util.Collectionandimportjava.util.HashMapinsteadofimportingjava.util.*.ThiswillnowallowthemtouseTimer,Collection,HashMap,andotherjavax.swingclasseswithoutusingfullyqualifiedclassnamesin.Canamethodbeoverloadedbasedondifferentreturntypebutsameargumenttype?No,becausethemethodscanbecalledwithoutusingtheirreturntypeinwhichcasethereisambiquityforthecompiler.Whathappenstoastaticvariablethatisdefinedwithinamethodofaclass?Can'tdoit.You'llgetacompilationerror.Howmanystaticinitializerscanyouhave?Asmanyasyouwant,butthestaticinitializersandclassvariableinitializersareexecutedintextualorderandmaynotrefertoclassvariablesdeclaredintheclasswhosedeclarationsappeartextuallyaftertheuse,eventhoughtheseclassvariablesareinscope.Whatisthedifferencebetweenmethodoverridingandoverloading?Overridingisamethodwiththesamenameandargumentsasinaparent,whereasoverloadingisthesamemethodnamebutdifferentargumentsWhatisconstructorchainingandhowisitachievedinJava?Achildobjectconstructoralwaysfirstneedstoconstructitsparent(whichinturncallsitsparentconstructor.).InJavaitisdoneviaanimplicitcalltotheno-argsconstructorasthefirststatement.WhatisthedifferencebetweentheBoolean&operatorandthe&&operator?IfanexpressioninvolvingtheBoolean&operatorisevaluated,bothoperandsareevaluated.Thenthe&operatorisappliedtotheoperand.Whenanexpressioninvolvingthe&&operatorisevaluated,thefirstoperandisevaluated.Ifthefirstoperandreturnsavalueoftruethenthesecondoperandisevaluated.The&&operatoristhenappliedtothefirstandsecondoperands.Ifthefirstoperandevaluatestofalse,theevaluationofthesecondoperandisskipped.WhichJavaoperatorisrightassociative?The=operatorisrightassociative.Canadoublevaluebecasttoabyte?Yes,adoublevaluecanbecasttoabyte.Whatisthedifferencebetweenabreakstatementandacontinuestatement?Abreakstatementresultsintheterminationofthestatementtowhichitapplies(switch,for,do,orwhile).Acontinuestatementisusedtoendthecurrentloopiterationandreturncontroltotheloopstatement.Canaforstatementloopindefinitely?Yes,aforstatementcanloopindefinitely.Forexample,considerthefollowing:for(;;);TowhatvalueisavariableoftheStringtypeautomaticallyinitialized?ThedefaultvalueofanStringtypeisnull.Whatisthedifferencebetweenafieldvariableandalocalvariable?Afieldvariableisavariablethatisdeclaredasamemberofaclass.Alocalvariableisavariablethatisdeclaredlocaltoamethod.Howarethis()andsuper()usedwithconstructors?this()isusedtoinvokeaconstructorofthesameclass.super()isusedtoinvokeasuperclassconstructor.Whatdoesitmeanthataclassormemberisfinal?Afinalclasscannotbeinherited.Afinalmethodcannotbeoverriddeninasubclass.Afinalfieldcannotbechangedafterit'sinitialized,anditmustincludeaninitializerstatementwhereit'sdeclared.Whatdoesitmeanthatamethodorclassisabstract?Anabstractclasscannotbeinstantiated.Abstractmethodsmayonlybeincludedinabstractclasses.However,anabstractclassisnotrequiredtohaveanyabstractmethods,thoughmostofthemdo.Eachsubclassofanabstractclassmustoverridetheabstractmethodsofitssuperclassesoritalsoshouldbedeclaredabstract.Whatisatransientvariable?Transientvariableisavariablethatmaynotbeserialized.HowdoesJavahandleintegeroverflowsandunderflows?Itusesthoseloworderbytesoftheresultthatcanfitintothesizeofthetypeallowedbytheoperation.Whatisthedifferencebetweenthe?and?>operators?The?operatorcarriesthesignbitwhenshiftingright.The?>zero-fillsbitsthathavebeenshiftedout.Issizeofakeyword?Thesizeofoperatorisnotakeyword.Whatisthedifferencebetweenaconstructorandamethod?Aconstructorisamemberfunctionofaclassthatisusedtocreateobjectsofthatclass.Ithasthesamenameastheclassitself,hasnoreturntype,andisinvokedusingthenewoperator.Amethodisanordinarymemberfunctionofaclass.Ithasitsownname,areturntype(whichmaybevoid),andisinvokedusingthedotoperator.WhatisthepurposeofgarbagecollectioninJava,andwhenisitused?Thepurposeofgarbagecollectionistoidentifyanddiscardobjectsthatarenolongerneededbyaprogramsothattheirresourcescanbereclaimedandreused.AJavaobjectissubjecttogarbagecollectionwhenitbecomesunreachabletotheprograminwhichitisused.Describesynchronizationinrespecttomultithreading.Withrespecttomultithreading,synchronizationisthecapabilitytocontroltheaccessofmultiplethreadstosharedresources.Withoutsynchonization,itispossibleforonethreadtomodifyasharedvariablewhileanotherthreadisintheprocessofusingorupdatingsamesharedvariable.Thisusuallyleadstosignificanterrors.Whatisanabstractclass?Abstractclassmustbeextended/subclassed(tobeuseful).Itservesasatemplate.Aclassthatisabstractmaynotbeinstantiated(ie.youmaynotcallitsconstructor),abstractclassmaycontainstaticdata.Anyclasswithanabstractmethodisautomaticallyabstractitself,andmustbedeclaredassuch.Aclassmaybedeclaredabstractevenifithasnoabstractmethods.Thispreventsitfrombeinginstantiated.WhatisthedifferencebetweenanInterfaceandanAbstractclass?Anabstractclasscanhaveinstancemethodsthatimplementadefaultbehavior.AnInterfacecanonlydeclareconstantsandinstancemethods,butcannotimplementdefaultbehaviorandallmethodsareimplicitlyabstract.Aninterfacehasallpublicmembersandnoimplementation.Anabstractclassisaclasswhichmayhavetheusualflavorsofclassmembers(private,protected,etc.),buthassomeabstractmetho
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 政府部門專屬辦公用品招標(biāo)
- 產(chǎn)業(yè)園區(qū)通信系統(tǒng)招標(biāo)
- 美術(shù)課程任課教師招聘合同
- 辦公樓通風(fēng)系統(tǒng)安裝合同
- 礦產(chǎn)資源開發(fā)招投標(biāo)中心回顧
- 區(qū)塊鏈技術(shù)應(yīng)用項(xiàng)目招投標(biāo)協(xié)議
- 成都市超市租賃合同
- 燃?xì)夤こ陶型稑?biāo)合作框架協(xié)議
- 婚禮攝影臨時(shí)場(chǎng)地租賃合同
- 藝術(shù)館建設(shè)合同
- 新湘科版小學(xué)三年級(jí)科學(xué)上冊(cè)-全冊(cè)教案
- 2023飛輪儲(chǔ)能技術(shù)在新能源一次調(diào)頻上的應(yīng)用
- 第7講-化學(xué)工程的倫理問(wèn)題-201912092040097
- 激素類藥物使用規(guī)范
- 全面預(yù)算管理項(xiàng)目啟動(dòng)培訓(xùn)課件PPT
- 北師大版2023-2024五年級(jí)數(shù)學(xué)上冊(cè)期中測(cè)試卷
- 第十六章-組織創(chuàng)新-管理學(xué)馬工程-課件
- 全球航路的開辟(共31張)
- 東方管理智慧儒道禪的視閾
- 初中數(shù)學(xué)華東師大版七年級(jí)上冊(cè)整式的加減課件
- 無(wú)人機(jī)高光譜遙感水稻氮營(yíng)養(yǎng)的診斷方法
評(píng)論
0/150
提交評(píng)論