资源描述:
《java面试题目(java interview topics)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、java面试题目(Javainterviewtopics)1,cana.Javafilecontainmultipleclasses(notaninternalclass)?What'sthelimit?Answer:youcanhavemultipleclasses,butthereisonlyonepublicclass,andthepublicclasscanonlybethesameasthefilename.2.DoesJavahavegoto?Answer:gotoinJavaasr
2、eservedword,butnot.Talkaboutthedifferencebetweenthe3,andthe&&&.Answer:&&&isthelogicandtherelationshipbetweenthesideoftheequationaretruewhenitistrue,orfalse,Andhasashortcircuitfunction,iffalseexpressionisinfront,sonocalculationbehind,thisequationisfal
3、se,if&thenbackwouldhavebeenexecutedExpression(str!=null&&str.equals(""")),ifSTRisnull,nonullpointexceptionwillappear,andifthereis-thentherewillbenullpointerexceptions.WhenbothsidesoftheexpressionarenotBooleantypes,theycanbebitwiseandoperation4.Howdoy
4、oujumpoutofthecurrentmultiplenestedloopsinJAVA?Answer:youcandefineOK:thenrecycleit,makeaconditionallimit,jumpitoutwithbreak,andthecodeisasfollowsSystem.out.println("begin>>>>>>>>");Ok:For(inti=1;i<10;i++){For(intj=0;J<10;j++){System.out.println("i=",
5、"+i+","----------j="+j);If(i==2&&j==3){Breakok;}}}System.out.println("end>>>>>>>>");5,whethertheswitchstatementcanworkonbyte,canitworkonthelong,canitworkontheString?Answer:thereareint,short,byte,andsomeenumerationtypesthatcanbeusedinswitchSwitch(colo
6、r){Caseyellow:Color=yellow;Break;Casered:Red;Break;Casegreen:Color=green;Break;}6,shortS1=1;S1=S1+1;what'swrong?ShortS1=1;S1=1;what'swrong?Answer:1.s1+1willautomaticallyupgradetothetypeofint,whenassignedtoS1willappearerrors2.+=isanoperatordefinedbyth
7、eJavalanguage,andthejavacompilerhandlesitspecially,soitcanbecompiledcorrectly7,canchartypevariablesstoreaChinesecharacter?Why?Answer:Yes,andcanstorejustoneChinesecharacter!Charc='';8.Usethemostefficientmethodtocalculate2multipliedby8equaltoafew?Answe
8、r:2<<3;movethreebittotheleft!9,theuseoffinalkeywordmodifyavariable,thereferencecannotchange,ortheobjectcannotbechangedreference?Answer:whenyoumodifyavariablewiththefinalkeyword,thereferencevariablecannotchange,butthereferencedobjectcanchange.10,"=="e