java工程师考试Word下载.docx
- 文档编号:21230973
- 上传时间:2023-01-28
- 格式:DOCX
- 页数:12
- 大小:19.27KB
java工程师考试Word下载.docx
《java工程师考试Word下载.docx》由会员分享,可在线阅读,更多相关《java工程师考试Word下载.docx(12页珍藏版)》请在冰豆网上搜索。
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,whichstatementscanbeinsertedatpositionIwithoutcausingthecodetofailcompilation?
publicclassQ6db8{
inta;
intb=0;
staticintc;
publicvoidm(){
intd;
inte=0;
//Position1
1)a++
2)b++
3)c++
4)d++
5)e++
7、Whatiswrongwiththefollowingcode?
ClassMyExceptionextendsException{}
Publicclassqb4ab{
Publicvoidfoo(){
Try{
Bar();
}finally{
Baz();
}catch(MyExceptione){
Publicvoidbar()throwsMyException{
ThrownewException();
Publicvoidbaz()throwsRuntimeException{
ThrownewRuntimeException();
4、)Sincethemethodfoo()doesnotcatchtheexceptiongeneratedbythemethodbaz(),itmustdeclaretheRuntimeExceptioninitsthrowsclause.
5、)Athetryblockcannotbefollowedbybothacatchandafinallyblock.
6、)Anemptycatchblockisnotallowed.
7、)Acatchblockcannotfollowafinallyblock.
8、)Afinallyblockmustalwaysfollowoneormorecatchblocks.
5、WhatwillhappenwhenyouattempttocompileandrunthefollowingprogrambypassingtheTestclasstotheJavainterpreter?
ClassTest{
Publicstaticvoidmain{
System.out.print(“hello”);
Selecttheonerightanswer.
6.theprogramdoesnotcompilebecausemain()isnotdefinedcorrectly.
7.Theprogramcompilesbutwhenyoutrytoruntheinterpretercompliesthatitcannotfindthemain()methoditneedstorun.
C)theprogramcompilesbutyoucannotrunitbecausetheclassisnotdeclaredaspublic.
D)theprogramcompilesandrunswithoutanerrorbutdoesnotdisplayanythinginthestandardoutput.
E)theprogramcompilesanddisplays“hello”inthestandardoutputwhenyouinrunit.
6、Givethosecodesnippets:
Booleanb1=newBoolean(true);
Booleanb2=newBoolean(true);
WhichexpressionsarelegalJavaexpressionsthatreturntrue?
Selectallvalidanswer.
3.b1=b2
4.b1.equals(b2)
C)b1&
b2
D)b1|b2
E)b1&
&
F)b1||b2
7、Giventhiscodesnippet:
try{
tryThis();
return;
}catch(IOExceptionx1){
System.out.println("
exception1"
);
return;
}catch(Exceptionx2){
exception2"
finally"
WhatwillappearinthestandardoutputiftryThis()throwsaNumberFormatException?
a)Nothing
b)"
followedby"
c)"
d)"
e)"
选择:
C
8、Givertheseclassdefinitions;
classSuperclass{}
classSubclass1extendsSuperclass{}
classSubclass2extendsSuperclass{}
andtheseobjects;
Superclassa=newSuperclass();
Subclass1b=newSubclass1();
Subclass2c=newSubclass2();
whichofthefollowingexplainstheresultofthestatement;
b=(Subclass1)c;
Selectedtheonerightanswer;
a)Illegalatcompiletime
b)Legalatcompiletimebutpossiblyillegalatruntime
c)Definitelylegalatruntime
9、简述以下代码是在做什么事情?
Publicstaticjavax.ejb.EJBHomegetEJBHome(StringJNDIName)throwsNameNotFoundException,NamingException
{
java.util.Hashtableenv=newjava.util.Hashtable
(1);
env.put(javax.naming.context.INITIAI_CONTEXT_FACTORY,”com.kivasoft.eb.jndi.GDSInitContextFactory”);
Javax.naming.ContextinitContext=newjavax.naming.InitalContext(env);
If(initContext==null){
ThrownewRuntimeException(“getEJBHomecould’tretrieveinitialcontext”);
return(javax.ejb.EJBHome)initContext.lookup(JNDIName);
10:
请从空白处填写代码,满足以下功能:
A)从请求中得到用户名和口令(请求通过web浏览器中的HTML页面提交,页面中用户名对象名为userName,口令对象名为password)
B)如果用户名为”admin”,口令为password,则讲登陆成功,将页面转到loginSuccess.jsp页面,并在session存放用户名(username)和密码(password)
C(如果用户名和空灵为其他值,转到error.jsp
PublicclassTestServletextendsHttpServlet
Publicvoidservice(HttpServletRequestrequest,HttpServletResponseresopnse)throwsServletException,IOException
//Includefollowinglinsinallservlet......
Try{
//请在此添写代码
If(userName.equals(“admin”)&
password.equals(“password”)){
request.getsession..setAttribute("
username"
”admin”);
password"
”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卷的同学那了解到的,主要的考点如下:
考点名称
考试频率
难易度
备注
数组
高
易
值传递与址传递
中
Main函数
低
线程
难
Swing与awt
Ascii码
请务必记住常用ascii码,代码题都有考
运算符优先级
去网上XX一下
Oop思想
方法重载与重写
包
方法与类的命名规则
逻辑思维
其他的记得不是很清楚了,不过不会超过基础知识这个范围,但光靠书(accp6.0)上那些还不够,建议找些参考书学习一下,越基础越好。
以下是A卷代码阅读题
8、建一个数组,顺序输出10位数,然后把这10位数再倒序输出
publicclassTest{
publicstaticvoidmain(String[]args){
int[]arr=newint[]{1,2,3,4,5,6,7,8,9,10};
System.out.println("
-------顺序输出------"
for(inti=0;
i<
arr.length;
i++){
System.out.print(arr[i]+"
"
}
System.out.println();
-------倒叙输出------"
for(intj=arr.length-1;
j>
=0;
j--){
System.out.print(arr[j]+"
9、考的是方法重载,它是将两个方法的参数顺序颠倒了一下,看题的时候要注意。
3.
publicclassTest5{
publicstaticvoidmain(String[]args){
int[]arr=newint[]{1,2,3,4,5,6,7,8};
a(arr);
b(arr);
staticvoida(intarr[]){
for(inttemp:
arr){
System.out.println(temp);
}
staticvoidb(intarr[]){
for(inti=0;
i<
arr.length;
i++){
arr[i]*=i;
输出结果是:
56
以下是A卷手写代码题:
8.请用1、2、3、4组成N个数值不重复且个十百位都不重复的3位数,一共有几个?
分别是什么?
共有:
24个
分别是:
123,124,132,134,142,143,213,214,231,234,241,243,312,314,321,324,341,342,412,413,421,423,431,432,
参考答案:
Intcount=0;
For(inti=1;
=4;
For(intj=1;
j<
j++){
For(intk=1;
k<
k++){
If(i!
=j&
i!
=k&
j!
=k){
Count++;
System.out.println(i*100+j*10+k);
一共有24个,公式:
4*3*2=24,具体数学公式请见排列算法。
9.查询子串在父串中出现的次数:
设:
str1为父串,str2为字串,则:
publicclassTest6{
Stringstr1="
hdsajkfhuisadhifnokfasdfdasdoksdfsdsfsok"
;
Stringstr2="
ok"
Stringtemp="
"
intcount=0;
for(temp=str1;
temp!
=null&
str2.length()<
=str1.length();
){
if(str1.indexOf(str2)==0){
System.out.println(str1.indexOf(str2));
count++;
}
str1=str1.substring
(1);
System.out.println("
共出现了:
+count+"
次"
以下是B卷手写代码题:
9、如果有“123空格abc空格zzz空格”,求数字、英文字符、空格在这个字符串中出现的次数:
intstrCount=0;
intnumberCount=0;
intnulCount=0;
Stringstr="
123abcasdAZ"
char[]arr=str.toCharArray();
inttemp=(int)arr[i];
if(temp>
=65&
temp<
=122){
strCount++;
=49&
=57){
numberCount++;
if(temp==32){
nulCount++;
System.out.println(strCount);
System.out.println(numberCount);
System.out.println(nulCount);
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- java 工程师 考试
![提示](https://static.bdocx.com/images/bang_tan.gif)