![java工程師考試試題_第1頁(yè)](http://file4.renrendoc.com/view7/M00/32/33/wKhkGWa3_QGAe_iqAAF4eUlijCg494.jpg)
![java工程師考試試題_第2頁(yè)](http://file4.renrendoc.com/view7/M00/32/33/wKhkGWa3_QGAe_iqAAF4eUlijCg4942.jpg)
![java工程師考試試題_第3頁(yè)](http://file4.renrendoc.com/view7/M00/32/33/wKhkGWa3_QGAe_iqAAF4eUlijCg4943.jpg)
![java工程師考試試題_第4頁(yè)](http://file4.renrendoc.com/view7/M00/32/33/wKhkGWa3_QGAe_iqAAF4eUlijCg4944.jpg)
![java工程師考試試題_第5頁(yè)](http://file4.renrendoc.com/view7/M00/32/33/wKhkGWa3_QGAe_iqAAF4eUlijCg4945.jpg)
版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
第一題:(過(guò)程可以寫(xiě)在后面)
學(xué)校的畢業(yè)話劇演出由四個(gè)小美女來(lái)出演小紅帽、美羊羊、女巫和公主的角
色。沒(méi)人在排練時(shí)的角色與演出時(shí)的角色不同。
排練時(shí)出演小紅帽的人會(huì)撒謊,通過(guò)如下消息,請(qǐng)判斷四人在演出和排練時(shí)
分別出演什么角色。
梅:“排練時(shí),蘭的角色是演出時(shí)竹的角色。”
蘭:“菊排練時(shí)扮演的是美羊羊?!?/p>
竹:“演出時(shí)我演公主?!?/p>
菊:“蘭演出時(shí)扮演的是美羊羊?!?/p>
第二題:解數(shù)獨(dú)題
(數(shù)獨(dú)是九宮格(即3格寬x3格高))正方形狀,每一格又細(xì)分為一個(gè)九宮
格,在沒(méi)一個(gè)小九宮格中,分別填上廣9個(gè)數(shù)字,讓每一個(gè)大九宮格沒(méi)一列,沒(méi)
一行的數(shù)字都不重復(fù)。
8174
69
483
385
2756
96
6
51
183
1>Whichlinecontainsaconstructorinthisclassdefinition?
publicclassCounter!//(1)
intcurrent,step;
publicCounter(intstartVaue,intstepValue){//(2)
set(startValue);
setStepValue(steValue);
publicintget(){returncurrent;}//(3)
publicvoidset(intvalue){current==value;}//(4)
publicvoidsetStepValue(intstepValue){step==stepValue;}//(5)
1)Codemarkedwith(1)isaconstructor
2)Codemarkedwith(2)isaconstructor
3)Codemarkedwith(3)isaconstructor
4)Codemarkedwith(4)isaconstructor
5)Codemarkedwith(5)isaconstructor
2、Aninstancemember...
1)isalsocalledastaticmember
2)isalwaysavariable
3)isneveramethod
4)belongstoasingleinstance,nottotheclassasawhole
5)alwaysrepresentsanoperation
3、Giventhefollowingclass,whichstatementscanbeinsertedat
positionIwithoutcausingthecodetofailcompilation?
publicclassQ6db8{
inta
intb=0;
staticintc;
publicvoidm(){
intd;
inte=0;
//Position1
1)a++
2)b++
3)c++
4)d++
5)e++
7、Whatiswrongwiththefollowingcode?
ClassMyExceptionextendsException1!
Publicclassqb4ab{
Publicvoidfoo(){
Try{
Bar();
}finally{
Baz();
}catch(MyExceptione){
}
Publicvoidbar()throwsMyException{
ThrownewException();
}
Publicvoidbaz()throwsRuntimeException{
ThrownewRuntimeException();
4、)Sincethemethodfoo()doesnotcatchtheexceptiongeneratedby
themethodbaz(),itmustdeclaretheRuntimeExceptioninitsthrows
clause.
5、)Athetryblockcannotbefollowedbybothacatchandafinally
block.
6、)Anemptycatchblockisnotallowed.
7、)Acatchblockcannotfollowafinallyblock.
8、)Afinallyblockmustalwaysfollowoneormorecatchblocks.
5、Whatwillhappenwhenyouattempttocompileandrunthe
followingprogrambypassingtheTestclasstotheJavainterpreter?
ClassTest{
Publicstaticvoidmain{
(“hello");
}
}
Selecttheonerightanswer.
6.theprogramdoesnotcompilebecausemain()isnotdefined
correctly.
7.Theprogramcompilesbutwhenyoutrytoruntheinterpreter
compliesthatitcannotfindthemain()methoditneedstorun.
C)theprogramcompilesbutyoucannotrunitbecausetheclassisnot
declaredaspublic.
D)theprogramcompilesandrunswithoutanerrorbutdoesnotdisplay
anythinginthestandardoutput.
E)theprogramcompilesanddisplays“hello“inthestandardoutput
whenyouinrunit.
6、Givethosecodesnippets:
Booleanbl=newBoolean(true);
Booleanb2=newBoolean(true);
WhichexpressionsarelegalJavaexpressionsthatreturntrue?
Selectallvalidanswer.
3.bl=b2
4.bl.equals(b2)
C)bl&b2
D)bl|b2
E)bl&&b2
F)bl||b2
7、Giventhiscodesnippet:
try{
tryThis();
return;
}catch(lOExceptionxl){
("exception1〃);
return;
}catch(Exceptionx2){
("exception2〃);
return;
}finally{
("finally");
}
WhatwillappearinthestandardoutputiftryThis()throwsa
NumberFormatException?
Selecttheonerightanswer.
a)Nothing
b)“exceptionl/z,followedby"finally”
c)“exception2/z,followedby"finally”
d)“exception1〃
e)“exception2〃
選擇:C
8、Givertheseclassdefinitions;
classSuperclass{}
classSubclasslextendsSuperclass{}
classSubclass2extendsSuperclass{}
andtheseobjects;
Superclassa=newSuperclass();
Subclasslb=newSubclassl();
Subclass2c=newSubclass2();
whichofthefollowingexplainstheresultofthestatement;
b=(Subclassl)c;
Selectedtheonerightanswer;
a)Illegalatcompiletime
b)Legalatcompiletimebutpossiblyillegalatruntime
c)Definitelylegalatruntime
9、簡(jiǎn)述以下代碼是在做什么事情?
PublicstaticgetEJBHome(StringJNDIName)throws
NameNotFoundException,NamingException
(
env=new(1);
initContext=new(env);
If(initContext==null){
ThrownewRuntimeException("getEJBHomecould'tretrieveinitial
context");
return()initContext.lookup(JNDIName);
}
10:請(qǐng)從空白處填寫(xiě)代碼,滿足以下功能:
A)從請(qǐng)求中得到用戶名和口令(請(qǐng)求通過(guò)web瀏覽器中的HTML頁(yè)面提交,頁(yè)
面中用戶名對(duì)象名為userName,口令對(duì)象名為password)
B)如果用戶名為"admin",口令為password,則講登陸成功,將頁(yè)面轉(zhuǎn)到
loginSuccess.jsp頁(yè)面,并在session存放用戶名(username)和密碼
(password)
C(如果用戶名和空靈為其他值,轉(zhuǎn)到error.jsp
PublicclassTestServletextendsHttpServlet
(
Publicvoidservice(HttpServletRequestrequest,HttpServletResponse
resopnse)throwsServletException,lOException
(
//Includefollowinglinsinallservlet.....
Try{
//請(qǐng)?jiān)诖颂韺?xiě)代碼
If(userName.equals("admin")&&
password,equals("password")){
request,getsession..setAttribute("username",^^admin");
request,getsession..setAttribute("passworcT,“password");
Request.sendRedirect("loginSuccess.jsp");
}else{
Request.sendRedirect("error.jsp");
)
}catch(Exceptione){
典道的筆試分A-B卷,題型有:
1.選擇題30道(每道2分共60分)
2.代碼閱讀題4道(每道5分共20分)
3.程序邏輯題2道(每道10分共20分)
不管是A-B卷,考察的范圍都是基礎(chǔ)知識(shí),這個(gè)是和幾個(gè)做B卷的同學(xué)那了解到
的,主要的考點(diǎn)如下:
考點(diǎn)名稱考試頻率難易度備注
數(shù)組高易
值傳遞與址高中
傳遞
Main函數(shù)低中
線程低難
Swing與awt低中
Ascii碼高難請(qǐng)務(wù)必記住
常用ascii
碼,代碼題
都有考
運(yùn)算符優(yōu)先低中去網(wǎng)上百度
級(jí)一下
Oop思想高中
方法重載與高易
重寫(xiě)
包低易
方法與類的低易
命名規(guī)則
邏輯思維高難
其他的記得不是很清楚了,不過(guò)不會(huì)超過(guò)基礎(chǔ)知識(shí)這個(gè)范圍,但光靠書(shū)
(accp6.0)上那些還不夠,建議找些參考書(shū)學(xué)習(xí)一下,越基礎(chǔ)越好。
以下是A卷代碼閱讀題
8、建一個(gè)數(shù)組,順序輸出10位數(shù),然后把這10位數(shù)再倒序輸出
publicclassTest{
publicstaticvoidmain(String[]args){
int[]arr=newint[]{1,2,3,4,5,6,7,8,9,10};
System.out.printIn("-------1l頁(yè)序輸出-------");
for(inti=0;i<arr.length;i++){
System.out.print(arr[i];
)
System.out.printIn();
System.out.printIn("-------倒敘輸出-------");
for(intj=arr.length-1;j>=0;j--){
System.out.print(arr[j];
)
)
9、考的是方法重載,它是將兩個(gè)方法的參數(shù)順序顛倒了一下,看題的時(shí)候要注
屆、O
3.
publicclassTest5{
publicstaticvoidmain(String[]args){
int[]arr=newint口{1,2,3,4,5,6,7,8};
a(arr);
b(arr);
a(arr);
)
staticvoida(intarr[]){
for(inttemp:arr){
System.out.printin(temp);
}
)
staticvoidb(intarr[]){
for(inti=0;i<arr.length;i++){
arr[i]*=i;
輸出結(jié)果是:56
以下是A卷手寫(xiě)代碼題:
8.請(qǐng)用1、2、3、4組成N個(gè)數(shù)值不重復(fù)且個(gè)十百位都不重復(fù)的3位數(shù),一共有幾
個(gè)?分別是什么?
共有:24個(gè)
分別是:
123,124,132,134,142,143,213,214,231,234,241,243,312,314,321,3
24,341,342,412,413,421,423,431,432,
參考答案:
Intcount=0;
For(inti=l;i<=4;i++){
For(intj=l;j<=4;j++){
For(intk=l;k<=4;k-F+){
If(i!=j&&i!=k&&j!=k){
Count++;
(i*100+j*10+k);
一共有24個(gè),公式:4*3*2=24,具體數(shù)學(xué)公式請(qǐng)見(jiàn)排列算法。
9.查詢子串在父串中出現(xiàn)的次數(shù):
參考答案:
設(shè):strl為父串,str2為字串,貝U:
publicclassTest6{
publicstaticvoidmain(String[]args){
String
strl=HhdsajkfhuisadhifnokfasdfdasdoksdfsdsfsokH;
Stringstr2=nok";
Stringtemp="H;
intcount=0;
for(temp=strl;temp!=null&&str2.length()<=strl.length()
;)
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 如何獲取期刊論文格式
- 入團(tuán)申請(qǐng)書(shū)高中1000字
- 大學(xué)生創(chuàng)業(yè)項(xiàng)目訓(xùn)練計(jì)劃
- 上海大學(xué)生餐飲創(chuàng)業(yè)項(xiàng)目
- ktv雙十一活動(dòng)策劃書(shū)(第二稿)
- 第5章 一元一次方程單元測(cè)試(含解析)-七年級(jí)數(shù)學(xué)下冊(cè)(華師大版)
- 音樂(lè)的本質(zhì)探索
- 藝術(shù)與生活模板
- 聘任申請(qǐng)書(shū)養(yǎng)護(hù)工
- 初級(jí)銀行業(yè)法律法規(guī)與綜合能力-初級(jí)銀行從業(yè)資格考試《法律法規(guī)與綜合能力》押題密卷4
- 2025年酒店總經(jīng)理崗位職責(zé)與薪酬協(xié)議
- 綠色能源項(xiàng)目融資計(jì)劃書(shū)范文
- 大樹(shù)扶正施工方案
- 2024年全國(guó)職業(yè)院校技能大賽中職組(母嬰照護(hù)賽項(xiàng))考試題庫(kù)(含答案)
- 課題申報(bào)參考:全齡友好視角下的社區(qū)語(yǔ)言景觀評(píng)估及空間優(yōu)化研究
- 五年級(jí)下冊(cè)語(yǔ)文四大名著??贾R(shí)點(diǎn)
- 2024年上海普陀區(qū)司法局招聘人民調(diào)解員考試真題
- 光伏發(fā)電項(xiàng)目施工組織設(shè)計(jì)方案及技術(shù)措施
- 駕照考試題庫(kù)及答案(完整版)
- 2025年1月日歷表(含農(nóng)歷-周數(shù)-方便記事備忘)
- 2025中國(guó)鐵塔公司社會(huì)招聘85人高頻重點(diǎn)提升(共500題)附帶答案詳解
評(píng)論
0/150
提交評(píng)論