您好,欢迎访问三七文档
英文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
本文标题:Java英文面试题
链接地址:https://www.777doc.com/doc-5539411 .html