Java-計(jì)算機(jī)軟件及應(yīng)用_第1頁(yè)
Java-計(jì)算機(jī)軟件及應(yīng)用_第2頁(yè)
Java-計(jì)算機(jī)軟件及應(yīng)用_第3頁(yè)
Java-計(jì)算機(jī)軟件及應(yīng)用_第4頁(yè)
免費(fèi)預(yù)覽已結(jié)束,剩余17頁(yè)可下載查看

下載本文檔

版權(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ì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論