Master list of Java interview questions115 questionsWord下载.docx

上传人:b****2 文档编号:3830046 上传时间:2023-05-02 格式:DOCX 页数:18 大小:27.97KB
下载 相关 举报
Master list of Java interview questions115 questionsWord下载.docx_第1页
第1页 / 共18页
Master list of Java interview questions115 questionsWord下载.docx_第2页
第2页 / 共18页
Master list of Java interview questions115 questionsWord下载.docx_第3页
第3页 / 共18页
Master list of Java interview questions115 questionsWord下载.docx_第4页
第4页 / 共18页
Master list of Java interview questions115 questionsWord下载.docx_第5页
第5页 / 共18页
Master list of Java interview questions115 questionsWord下载.docx_第6页
第6页 / 共18页
Master list of Java interview questions115 questionsWord下载.docx_第7页
第7页 / 共18页
Master list of Java interview questions115 questionsWord下载.docx_第8页
第8页 / 共18页
Master list of Java interview questions115 questionsWord下载.docx_第9页
第9页 / 共18页
Master list of Java interview questions115 questionsWord下载.docx_第10页
第10页 / 共18页
Master list of Java interview questions115 questionsWord下载.docx_第11页
第11页 / 共18页
Master list of Java interview questions115 questionsWord下载.docx_第12页
第12页 / 共18页
Master list of Java interview questions115 questionsWord下载.docx_第13页
第13页 / 共18页
Master list of Java interview questions115 questionsWord下载.docx_第14页
第14页 / 共18页
Master list of Java interview questions115 questionsWord下载.docx_第15页
第15页 / 共18页
Master list of Java interview questions115 questionsWord下载.docx_第16页
第16页 / 共18页
Master list of Java interview questions115 questionsWord下载.docx_第17页
第17页 / 共18页
Master list of Java interview questions115 questionsWord下载.docx_第18页
第18页 / 共18页
亲,该文档总共18页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

Master list of Java interview questions115 questionsWord下载.docx

《Master list of Java interview questions115 questionsWord下载.docx》由会员分享,可在线阅读,更多相关《Master list of Java interview questions115 questionsWord下载.docx(18页珍藏版)》请在冰点文库上搜索。

Master list of Java interview questions115 questionsWord下载.docx

-Objectorientedprogrammingorganizesaprogramarounditsdata,i.e.,objectsandasetofwelldefinedinterfacestothatdata.Anobject-orientedprogramcanbecharacterizedasdatacontrollingaccesstocode.

5.WhatareClass,ConstructorandPrimitivedatatypes?

-Classisatemplateformultipleobjectswithsimilarfeaturesanditisablueprintforobjects.Itdefinesatypeofobjectaccordingtothedatatheobjectcanholdandtheoperationstheobjectcanperform.Constructorisaspecialkindofmethodthatdetermineshowanobjectisinitializedwhencreated.Primitivedatatypesare8typesandtheyare:

byte,short,int,long,float,double,boolean,char.

6.WhatisanObjectandhowdoyouallocatememorytoit?

-Objectisaninstanceofaclassanditisasoftwareunitthatcombinesastructuredsetofdatawithasetofoperationsforinspectingandmanipulatingthatdata.Whenanobjectiscreatedusingnewoperator,memoryisallocatedtoit.

7.Whatisthedifferencebetweenconstructorandmethod?

-Constructorwillbeautomaticallyinvokedwhenanobjectiscreatedwhereasmethodhastobecalledexplicitly.

8.Whataremethodsandhowaretheydefined?

-Methodsarefunctionsthatoperateoninstancesofclassesinwhichtheyaredefined.Objectscancommunicatewitheachotherusingmethodsandcancallmethodsinotherclasses.Methoddefinitionhasfourparts.Theyarenameofthemethod,typeofobjectorprimitivetypethemethodreturns,alistofparametersandthebodyofthemethod.Amethod’ssignatureisacombinationofthefirstthreepartsmentionedabove.

9.WhatistheuseofbinandlibinJDK?

-Bincontainsalltoolssuchasjavac,appletviewer,awttool,etc.,whereaslibcontainsAPIandallpackages.

10.Whatiscasting?

-Castingisusedtoconvertthevalueofonetypetoanother.

11.Howmanywayscananargumentbepassedtoasubroutineandexplainthem?

-Anargumentcanbepassedintwoways.Theyarepassingbyvalueandpassingbyreference.Passingbyvalue:

Thismethodcopiesthevalueofanargumentintotheformalparameterofthesubroutine.Passingbyreference:

Inthismethod,areferencetoanargument(notthevalueoftheargument)ispassedtotheparameter.

12.Whatisthedifferencebetweenanargumentandaparameter?

-Whiledefiningmethod,variablespassedinthemethodarecalledparameters.Whileusingthosemethods,valuespassedtothosevariablesarecalledarguments.

13.Whataredifferenttypesofaccessmodifiers?

-public:

Anythingdeclaredaspubliccanbeaccessedfromanywhere.private:

Anythingdeclaredasprivatecan’tbeseenoutsideofitsclass.protected:

Anythingdeclaredasprotectedcanbeaccessedbyclassesinthesamepackageandsubclassesintheotherpackages.defaultmodifier:

Canbeaccessedonlytoclassesinthesamepackage.

14.Whatisfinal,finalize()andfinally?

-final:

finalkeywordcanbeusedforclass,methodandvariables.Afinalclasscannotbesubclassedanditpreventsotherprogrammersfromsubclassingasecureclasstoinvokeinsecuremethods.Afinalmethodcan’tbeoverridden.Afinalvariablecan’tchangefromitsinitializedvalue.finalize():

finalize()methodisusedjustbeforeanobjectisdestroyedandcanbecalledjustpriortogarbagecollection.finally:

finally,akeywordusedinexceptionhandling,createsablockofcodethatwillbeexecutedafteratry/catchblockhascompletedandbeforethecodefollowingthetry/catchblock.Thefinallyblockwillexecutewhetherornotanexceptionisthrown.Forexample,ifamethodopensafileuponexit,thenyouwillnotwantthecodethatclosesthefiletobebypassedbytheexception-handlingmechanism.Thisfinallykeywordisdesignedtoaddressthiscontingency.

15.WhatisUNICODE?

-Unicodeisusedforinternalrepresentationofcharactersandstringsandituses16bitstorepresenteachother.

16.WhatisGarbageCollectionandhowtocallitexplicitly?

-Whenanobjectisnolongerreferredtobyanyvariable,javaautomaticallyreclaimsmemoryusedbythatobject.Thisisknownasgarbagecollection.System.gc()methodmaybeusedtocallitexplicitly.

17.Whatisfinalize()method?

-finalize()methodisusedjustbeforeanobjectisdestroyedandcanbecalledjustpriortogarbagecollection.

18.WhatareTransientandVolatileModifiers?

-Transient:

Thetransientmodifierappliestovariablesonlyanditisnotstoredaspartofitsobject’sPersistentstate.Transientvariablesarenotserialized.Volatile:

Volatilemodifierappliestovariablesonlyandittellsthecompilerthatthevariablemodifiedbyvolatilecanbechangedunexpectedlybyotherpartsoftheprogram.

19.Whatismethodoverloadingandmethodoverriding?

-Methodoverloading:

Whenamethodinaclasshavingthesamemethodnamewithdifferentargumentsissaidtobemethodoverloading.Methodoverriding:

Whenamethodinaclasshavingthesamemethodnamewithsameargumentsissaidtobemethodoverriding.

20.Whatisdifferencebetweenoverloadingandoverriding?

-a)Inoverloading,thereisarelationshipbetweenmethodsavailableinthesameclasswhereasinoverriding,thereisrelationshipbetweenasuperclassmethodandsubclassmethod.b)Overloadingdoesnotblockinheritancefromthesuperclasswhereasoverridingblocksinheritancefromthesuperclass.c)Inoverloading,separatemethodssharethesamenamewhereasinoverriding,subclassmethodreplacesthesuperclass.d)Overloadingmusthavedifferentmethodsignatureswhereasoverridingmusthavesamesignature.

21.WhatismeantbyInheritanceandwhatareitsadvantages?

-Inheritanceistheprocessofinheritingallthefeaturesfromaclass.Theadvantagesofinheritancearereusabilityofcodeandaccessibilityofvariablesandmethodsofthesuperclassbysubclasses.

22.Whatisthedifferencebetweenthis()andsuper()?

-this()canbeusedtoinvokeaconstructorofthesameclasswhereassuper()canbeusedtoinvokeasuperclassconstructor.

23.Whatisthedifferencebetweensuperclassandsubclass?

-Asuperclassisaclassthatisinheritedwhereassubclassisaclassthatdoestheinheriting.

24.Whatmodifiersmaybeusedwithtop-levelclass?

-public,abstractandfinalcanbeusedfortop-levelclass.

25.Whatareinnerclassandanonymousclass?

-Innerclass:

classesdefinedinotherclasses,includingthosedefinedinmethodsarecalledinnerclasses.Aninnerclasscanhaveanyaccessibilityincludingprivate.Anonymousclass:

Anonymousclassisaclassdefinedinsideamethodwithoutanameandisinstantiatedanddeclaredinthesameplaceandcannothaveexplicitconstructors.

26.Whatisapackage?

-Apackageisacollectionofclassesandinterfacesthatprovidesahigh-levellayerofaccessprotectionandnamespacemanagement.

27.Whatisareflectionpackage?

-java.lang.reflectpackagehastheabilitytoanalyzeitselfinruntime.

28.Whatisinterfaceanditsuse?

-Interfaceissimilartoaclasswhichmaycontainmethod’ssignatureonlybutnotbodiesanditisaformalsetofmethodandconstantdeclarationsthatmustbedefinedbytheclassthatimplementsit.Interfacesareusefulfor:

a)Declaringmethodsthatoneormoreclassesareexpectedtoimplementb)Capturingsimilaritiesbetweenunrelatedclasseswithoutforcingaclassrelationship.c)Determininganobject’sprogramminginterfacewithoutrevealingtheactualbodyoftheclass.

29.Whatisanabstractclass?

-Anabstractclassisaclassdesignedwithimplementationgapsforsubclassestofillinandisdeliberatelyincomplete.

30.WhatisthedifferencebetweenIntegerandint?

-a)Integerisaclassdefinedinthejava.langpackage,whereasintisaprimitivedatatypedefinedintheJavalanguageitself.Javadoesnotautomaticallyconvertfromonetotheother.b)Integercanbeusedasanargumentforamethodthatrequiresanobject,whereasintcanbeusedforcalculations.

31.Whatisacloneableinterfaceandhowmanymethodsdoesitcontain?

-ItisnothavinganymethodbecauseitisaTAGGEDorMARKERinterface.

32.Whatisthedifferencebetweenabstractclassandinterface?

-a)Allthemethodsdeclaredinsideaninterfaceareabstractwhereasabstractclassmusthaveatleastoneabstractmethodandothersmaybeconcreteorabstract.b)Inabstractclass,keywordabstractmustbeusedforthemethodswhereasinterfaceweneednotusethatkeywordforthemethods.c)Abstractclassmusthavesubclasseswhereasinterfacecan’thavesubclasses.

33.Canyouhaveaninnerclassinsideamethodandwhatvariablescanyouaccess?

-Yes,wecanhaveaninnerclassinsideamethodandfinalvariablescanbeaccessed.

34.Whatisthedifferenceb

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 法律文书 > 调解书

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2