![java工程師考試試題_第1頁](http://file4.renrendoc.com/view7/M00/32/33/wKhkGWa3_QGAe_iqAAF4eUlijCg494.jpg)
![java工程師考試試題_第2頁](http://file4.renrendoc.com/view7/M00/32/33/wKhkGWa3_QGAe_iqAAF4eUlijCg4942.jpg)
![java工程師考試試題_第3頁](http://file4.renrendoc.com/view7/M00/32/33/wKhkGWa3_QGAe_iqAAF4eUlijCg4943.jpg)
![java工程師考試試題_第4頁](http://file4.renrendoc.com/view7/M00/32/33/wKhkGWa3_QGAe_iqAAF4eUlijCg4944.jpg)
![java工程師考試試題_第5頁](http://file4.renrendoc.com/view7/M00/32/33/wKhkGWa3_QGAe_iqAAF4eUlijCg4945.jpg)
版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領
文檔簡介
第一題:(過程可以寫在后面)
學校的畢業(yè)話劇演出由四個小美女來出演小紅帽、美羊羊、女巫和公主的角
色。沒人在排練時的角色與演出時的角色不同。
排練時出演小紅帽的人會撒謊,通過如下消息,請判斷四人在演出和排練時
分別出演什么角色。
梅:“排練時,蘭的角色是演出時竹的角色。”
蘭:“菊排練時扮演的是美羊羊。”
竹:“演出時我演公主。”
菊:“蘭演出時扮演的是美羊羊。”
第二題:解數(shù)獨題
(數(shù)獨是九宮格(即3格寬x3格高))正方形狀,每一格又細分為一個九宮
格,在沒一個小九宮格中,分別填上廣9個數(shù)字,讓每一個大九宮格沒一列,沒
一行的數(shù)字都不重復。
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、簡述以下代碼是在做什么事情?
PublicstaticgetEJBHome(StringJNDIName)throws
NameNotFoundException,NamingException
(
env=new(1);
initContext=new(env);
If(initContext==null){
ThrownewRuntimeException("getEJBHomecould'tretrieveinitial
context");
return()initContext.lookup(JNDIName);
}
10:請從空白處填寫代碼,滿足以下功能:
A)從請求中得到用戶名和口令(請求通過web瀏覽器中的HTML頁面提交,頁
面中用戶名對象名為userName,口令對象名為password)
B)如果用戶名為"admin",口令為password,則講登陸成功,將頁面轉(zhuǎn)到
loginSuccess.jsp頁面,并在session存放用戶名(username)和密碼
(password)
C(如果用戶名和空靈為其他值,轉(zhuǎn)到error.jsp
PublicclassTestServletextendsHttpServlet
(
Publicvoidservice(HttpServletRequestrequest,HttpServletResponse
resopnse)throwsServletException,lOException
(
//Includefollowinglinsinallservlet.....
Try{
//請在此添寫代碼
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卷,考察的范圍都是基礎知識,這個是和幾個做B卷的同學那了解到
的,主要的考點如下:
考點名稱考試頻率難易度備注
數(shù)組高易
值傳遞與址高中
傳遞
Main函數(shù)低中
線程低難
Swing與awt低中
Ascii碼高難請務必記住
常用ascii
碼,代碼題
都有考
運算符優(yōu)先低中去網(wǎng)上百度
級一下
Oop思想高中
方法重載與高易
重寫
包低易
方法與類的低易
命名規(guī)則
邏輯思維高難
其他的記得不是很清楚了,不過不會超過基礎知識這個范圍,但光靠書
(accp6.0)上那些還不夠,建議找些參考書學習一下,越基礎越好。
以下是A卷代碼閱讀題
8、建一個數(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頁序輸出-------");
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、考的是方法重載,它是將兩個方法的參數(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;
輸出結果是:56
以下是A卷手寫代碼題:
8.請用1、2、3、4組成N個數(shù)值不重復且個十百位都不重復的3位數(shù),一共有幾
個?分別是什么?
共有:24個
分別是:
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個,公式:4*3*2=24,具體數(shù)學公式請見排列算法。
9.查詢子串在父串中出現(xiàn)的次數(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. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年度廣州銀行房貸合同實施細則
- 拍賣房產(chǎn)申請書
- 中國復印紙行業(yè)市場調(diào)查研究及投資前景預測報告
- 2025年度政府項目合同績效評估與資金監(jiān)管辦法
- 2025年度5G通信基礎設施建設合同-@-1
- 2018-2024年中國煙草市場行情動態(tài)分析及發(fā)展前景趨勢預測報告
- 田徑隊的申請書
- 2025年借款合同反擔保書編制手冊正范規(guī)范
- 2025年度數(shù)字經(jīng)濟股份抵押借款協(xié)議
- 名稱核準申請書
- 臨床用血管理培訓
- 介入手術室護理風險
- 小學一年級數(shù)學20以內(nèi)的口算題(可直接打印A4)
- 春季安全行車教育培訓
- 2024年6月第3套英語六級真題
- 2024年江蘇省公務員錄用考試《行測》題(A類)
- 2024年10月時政100題(附答案)
- 江蘇省無錫市2024年中考數(shù)學試卷(含答案)
- 2024年保密知識測試試題及答案(奪冠)
- 北師大版八年級下冊因式分解(分組分解法)100題及答案
- 湖南2024年湖南省衛(wèi)生健康委直屬事業(yè)單位招聘276人筆試歷年典型考題及考點附答案解析
評論
0/150
提交評論