Java英文面试题

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

英文Javatm试题Question:Whatistransientvariable?Answer:Transientvariable臼n'tbeserialize.ForexampleifavariableisdeclaredastransientinaSerializablec1assandthec1assiswrittentoanObjectStream,thevalueofthevariablecan'tbewn忧entothestreaminsteadwhenthec1assisretrievedfromtheObjectStreamthevalueofthevariablebecomesnullQuestion:NamethecontainerswhichusesBorderLayoutastheirdefaultlayout?Answer:ContainerswhichusesBorderLayoutastheirdefaultare:window,FrameandDialogc1asses.Question:WhatdoyouunderstandbySynchronization?Answer:Synchronizationisaprocessofcontrollingtheaccessofsharedresourcesbythemultiplethreadsinsuchamannerthatonlyonethreadcanaccessoneresourceatatime.Innonsynchronizedmultithreadedapplication,itispossibleforonethreadtomodifyasharedobjectwhileanotherthreadisintheprocessofusingorupdatingtheobject'svalue.SynchronizationpreventssuchtypeofdatacorruptionE.g.Synchronizingafunction:publicsynchronizedvoidMethodl0{jjAppropriatemethod-relatedcode.E.g.Synchronizingablockofcodeinsideafunction:publicmyFunctionO{synchronized(this){jjSynchronizedcodehere.Question:WhatisCollectionAPI?Answer:TheCollectionAPIisasetofc1assesandinterfacesthatsupportoperationoncollectionsofobjects.Theseclassesandinterfacesaremoreflexi.ble,morepowerfu,lthevectors,arrays,andhashtablesife仔'ectivelyreplaces.andmoreregularthanExampleofc1asses:HashSet,HashMap,ArrayList,LinkedList,TreeSetandTreeMap.Exampleofinterfaces:Collection,5时,ListandMap.Question:IsIteratoraClassorInterface?Whatisitsuse?Answer:IteratorisaninterfacewhichisusedtostepthroughtheelementsofaCollection.Question:WhatissimilaritiesjdifferencebetweenanAbstractc1assandInterface?Answer:Differencesareasfollows:Interfacesprovideaformofmultipleinheritance.AclasscanextendonlyoneotherclassInterfacesarelimitedtopublicmethodsandconstantswithnoimplementation.Abstractclassescanhaveapartialimplementation,protectedparts,staticmethods,etc.AClassmayimplementseveralinterfaces.Butincaseofabstractclass,aclassmayextendonlyoneabstractclass.Interfacesareslowasitrequiresextraindirectiontofindcorrespondingmethodintheactualclass.Abstractclassesarefast.Similarities:NeitherAbstractclassesorInterfacecanbeinstantiated.Question:HowtodefineanAbstractclass?Answer:AclasscontainingabstractmethodiscalledAbstractclass.AnAbstractclasscan'tbeinstantiated.ExampleofAbstractclass:abstractclasstestAbstractClass{protectedStringmyString;publicStringgetMγStringO{returnmyString;publicabstractstringanyAbstractFunctionO;Question:HowtodefineanInterface?Answer:InJavaInterfacedefinesthemethodsbutdoesnotimplementthem.Interfacecanincludeconstants.AclassthatimplementstheinterfacesisboundtoimplementallthemethodsdefinedinInterface.EmapleofInterface:publicinterfacesamplelnterface{publicvoidfunctionOneO;publiclongCONSTANT_ONE=1000;Question:ExplaintheuserdefinedExceptions?Answer:UserdefinedExceptionsaretheseparateExceptionclassesdefinedbytheuserforspecificpurposed.Anuserdefinedcancreatedbysimplysub-classingittotheExceptionclass.Thisallowscustomexceptionstobegenerated(usingthrow)andcaughtinthesamewayasnormalexceptions.Example:classmyCustomExceptionextendsException{//TheclasssimplyhastoexisttobeanexceptionQuestion:ExplainthenewFeaturesofJDBC2.0CoreAPI?Answer:TheJDBC2.0APIincludesthecompleteJDBCAPI,whichincludesbothcoreandOptionalPackageAPI,andprovidesinductrial-strengthdatabasecomputingcapabilitiesNewFeaturesinJDBC2.0CoreAPI:Scrollableresultsets-usingnewmethodsintheResultSetinterfaceallowsprogrammaticallymovethetoparticularrowortoapositionrelativetoitscurrentpositionJDBC2.0CoreAPIprovidestheBatchUpdatesfunctionalitytothejavaapplicationsJavaapplicationscannowusetheResultSet.updateXXXmethods.Newdatatypes-interfacesmappingtheSQL3datatypesCustommappingofuser-definedtypes(UTDs)Miscellaneousfeatures,includingperformancehints,theuseofcharacterstreams,fullprecisionforjava.math.BigDecimalvalues,additionalsecurity,andsupportfortimezonesindate,time,andtimestampvalues.Question:Explaingarbagecollection?Answer:GarbagecollectionisoneofthemostimportantfeatureofJava.GarbagecollectionisalsocalledautomaticmemorymanagementasJVMautomaticallyremovestheunusedvariables/objects(valueisnull)fromthememory.Userprogramcann'tdirectlyfreetheobjectfrommemory,insteaditisthejobofthegarbagecollectortoautomaticallyfreetheobjectsthatarenolongerreferencedbyaprogram.Everyclassinheritsfinalize()methodfromjava.lang.Object,thefinalize()methodiscalledbygarbagecollectorwhenitdeterminesnomorereferencestotheobjectexists.InJava,itisgoodideatoexplicitlyassignnullintoavariablewhennomoreinuse.IJavaoncallingSystem.gc()andRuntime.gc(),JVMtriestorecycletheunusedobjects,butthereisnoguaranteewhenalltheobjectswillgarbagecollected.Question:Howyoucanforcethegarbagecollection?Answer:Garbagecollectionautomaticprocessandcan'tbeforced.Question:WhatisOOPS?Answer:OOPisthecommonabbreviationforObject-OrientedProgramming.Question:DescribetheprinciplesofOOPSAnswer:TherearethreemainprincipalsofoopswhicharecalledPolymorphism,InheritanceandQuestion:ExplaintheEncapsulationprinciple.Answer:Encapsulationisaprocessofbindingorwr

1 / 24
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功