Java英文面试题经典Word格式.docx
《Java英文面试题经典Word格式.docx》由会员分享,可在线阅读,更多相关《Java英文面试题经典Word格式.docx(20页珍藏版)》请在冰豆网上搜索。
Transientvariablecan'
tbeserialize.ForexampleifavariableisdeclaredastransientinaSerializableclassandtheclassiswrittentoanObjectStream,thevalueofthevariablecan'
tbewrittentothestreaminsteadwhentheclassisretrievedfromtheObjectStreamthevalueofthevariablebecomesnull.
NamethecontainerswhichusesBorderLayoutastheirdefaultlayout?
ContainerswhichusesBorderLayoutastheirdefaultare:
window,FrameandDialogclasses.
WhatdoyouunderstandbySynchronization?
Synchronizationisaprocessofcontrollingtheaccessofsharedresources
TheCollectionAPIisasetofclassesandinterfacesthatsupportoperationoncollectionsofobjects.Theseclassesandinterfacesaremoreflexible,morepowerful,andmoreregularthanthevectors,arrays,andhashtablesifeffectivelyreplaces.
Exampleofclasses:
HashSet,HashMap,ArrayList,LinkedList,TreeSetandTreeMap.
Exampleofinterfaces:
Collection,Set,ListandMap.
IsIteratoraClassorInterface?
Whatisitsuse?
IteratorisaninterfacewhichisusedtostepthroughtheelementsofaCollection.
Whatissimilarities/differencebetweenanAbstractclassandInterface?
Differencesareasfollows:
Interfacesprovideaformofmultipleinheritance.Aclasscanextendonlyoneotherclass.
Interfacesarelimitedtopublicmethodsandconstantswithnoimplementation.Abstractclassescanhaveapartialimplementation,protectedparts,staticmethods,etc.
AClassmayimplementseveralinterfaces.Butincaseofabstractclass,aclassmayextendonlyoneabstractclass.
Interfacesareslowasitrequiresextraindirectiontofindcorrespondingmethodintheactualclass.Abstractclassesarefast.
Similarities:
NeitherAbstractclassesorInterfacecanbeinstantiated.
HowtodefineanAbstractclass?
AclasscontainingabstractmethodiscalledAbstractclass.AnAbstractclasscan'
tbeinstantiated.
ExampleofAbstractclass:
abstractclasstestAbstractClass{
protectedStringmyString;
publicStringgetMyString(){
returnmyString;
}
publicabstractstringanyAbstractFunction();
}
HowtodefineanInterface?
InJavaInterfacedefinesthemethodsbutdoesnotimplementthem.Interfacecanincludeconstants.AclassthatimplementstheinterfacesisboundtoimplementallthemethodsdefinedinInterface.
EmapleofInterface:
publicinterfacesampleInterface{
publicvoidfunctionOne();
publiclongCONSTANT_ONE=1000;
ExplaintheuserdefinedExceptions?
UserdefinedExceptionsaretheseparateExceptionclassesdefinedbytheuserforspecificpurposed.Anuserdefinedcancreatedbysimplysub-classingittotheExceptionclass.Thisallowscustomexceptionstobegenerated(usingthrow)andcaughtinthesamewayasnormalexceptions.
Example:
classmyCustomExceptionextendsException{
//Theclasssimplyhastoexisttobeanexception
}
ExplainthenewFeaturesofJDBC2.0CoreAPI?
TheJDBC2.0APIincludesthecompleteJDBCAPI,whichincludesbothcoreandOptionalPackageAPI,andprovidesinductrial-strengthdatabasecomputingcapabilities.
NewFeaturesinJDBC2.0CoreAPI:
Scrollableresultsets-usingnewmethodsintheResultSetinterfaceallowsprogrammaticallymovethetoparticularrowortoapositionrelativetoitscurrentposition
JDBC2.0CoreAPIprovidestheBatchUpdatesfunctionalitytothejavaapplications.
JavaapplicationscannowusetheResultSet.updateXXXmethods.
Newdatatypes-interfacesmappingtheSQL3datatypes
Custommappingofuser-definedtypes(UTDs)
Miscellaneousfeatures,includingperformancehints,theuseofcharacterstreams,fullprecisionforjava.math.BigDecimalvalues,additionalsecurity,andsupportfortimezonesindate,time,andtimestampvalues.
Explaingarbagecollection?
GarbagecollectionisoneofthemostimportantfeatureofJava.GarbagecollectionisalsocalledautomaticmemorymanagementasJVMautomaticallyremovestheunusedvariables/objects(valueisnull)fromthememory.Userprogramcann'
tdirectlyfreetheobjectfrommemory,insteaditisthejobofthegarbagecollectortoautomaticallyfreetheobjectsthatarenolongerreferencedbyaprogram.Everyclassinheritsfinalize()methodfromjava.lang.Object,thefinalize()methodiscalledbygarbagecollectorwhenitdeterminesnomorereferencestotheobjectexists.InJava,itisgoodideatoexplicitlyassignnullintoavariablewhennomoreinuse.IJavaoncallingSystem.gc()andRuntime.gc(),JVMtriestorecycletheunusedobjects,butthereisnoguaranteewhenalltheobjectswillgarbagecollected.