Java试题.docx

上传人:b****5 文档编号:3234389 上传时间:2022-11-20 格式:DOCX 页数:18 大小:18.95KB
下载 相关 举报
Java试题.docx_第1页
第1页 / 共18页
Java试题.docx_第2页
第2页 / 共18页
Java试题.docx_第3页
第3页 / 共18页
Java试题.docx_第4页
第4页 / 共18页
Java试题.docx_第5页
第5页 / 共18页
点击查看更多>>
下载资源
资源描述

Java试题.docx

《Java试题.docx》由会员分享,可在线阅读,更多相关《Java试题.docx(18页珍藏版)》请在冰豆网上搜索。

Java试题.docx

Java试题

博大正方公司

JAVA开发人员招聘试题

姓名:

分数:

一、基本概念题(共30分)

1、请说出2种J2EE服务器(2分)

 

2、什么是JSP(JavaServerPages)技术?

JSP技术是如何工作的?

(5分)

 

3、请说出JSP规范中定义的四种对象作用域。

(4分)

 

4.请说明下面两种JSP注释的区别。

(2分)

--COMMENT-->

<%--COMMENT--%>

 

5.填空(3分)

Directives语法:

<%___directive%>

Declarations语法:

<%___declaration%>

Expressions语法:

<%___expression%>

6.填空(5分)

当用户A,B两个用户先后调用同一个SERVLET,假定B用户在A用户不再使用此SERVLET之后才提交请求,请对以下流程排序

A、用户A发出HTMLPOST请求

B、SERVLET响应请求,并返回处理结果

C、初始化SERVLET,调用INIT方法

D、用户B发出HTMLPOST请求

E、装载SERVLET

_____________________

7.填空(4分)

在java程序中访问数据库一定要哪个包?

Ajava.sql

Bjava.database

Coracle.jdbc.driver

Djava.database.sql

8.填空(5分,每空1分)

classSimpleExample{

publicstaticvoidmain(__A__){

Stringurl=".......";

try{

class.forName(".....");

___B___b=DriverManager.getConnection(url,"user","password");

Stringsqlstr="select*fromtest";

___C___c=b.createStatement();

___D___d=c.executeQuery(sql);

.........

}catch(__E___e){

System.out.println("Error");

}

}

}

二、素质试题(共70分,每小题3.5分,多选或少选均不得分)

Question1:

Giventhefollowingclassdefinition:

classA{

protectedinti;

A(inti){

this.i=i;

}

}

Whichofthefollowingwouldbeavalidinnerclassforthisclass?

Selectallvalidanswers.

 

a)

classB{

}

b)

classBextendsA{

}

c)

classB{

B(){

System.out.println("i="+i);

}

}

d)

classB{

classA{

}

}

e)

classA{

}

Answer____________

Question2:

Whatstatementsaretrueconcerningthemethodnotify()thatisusedinconjunctionwithwait()?

Selectallvalidanswers.

 

a)ifthereismorethanonethreadwaitingonacondition,onlythethreadthathasbeenwaitingthelongestisnotified

 

b)ifthereismorethanonethreadwaitingonacondition,thereisnowaytopredictwhichthreadwillbenotifed

 

c)notify()isdefinedintheThreadclass

 

d)itisnotstrictlynecessarytoownthelockfortheobjectyouinvokenotify()for

 

e)notify()shouldonlybeinvokedfromwithinawhileloop

 

Answer____________

Question3:

Giventhefollowingclass:

classCounter{

publicintstartHere=1;

publicintendHere=100;

publicstaticvoidmain(String[]args){

newCounter().go();

}

voidgo(){

//A

Threadt=newThread(a);

t.start();

}

}

WhatblockofcodecanyoureplaceatlineAabovesothatthisprogramwillcountfromstartHeretoendHere?

Selectallvalidanswers.

 

a)

Runnablea=newRunnable(){

publicvoidrun(){

for(inti=startHere;i<=endHere;i++){

System.out.println(i);

}

}

};

 

b)

aimplementsRunnable{

publicvoidrun(){

for(inti=startHere;i<=endHere;i++){

System.out.println(i);

}

}

};

 

c)

Threada=newThread(){

publicvoidrun(){

for(inti=startHere;i<=endHere;i++){

System.out.println(i);

}

}

};

Answer____________

Question4:

Whatiswrittentothestandardoutputgiventhefollowingstatement:

System.out.println(4|7);

Selecttheonerightanswer.

 

a)4

 

b)5

 

c)6

 

d)7

 

e)0

 

Answer____________

Question5:

Giventhefollowingclass:

classCounter{

publicstaticvoidmain(String[]args){

Threadt=newThread(newCounterBehavior());

t.start();

}

}

WhichofthefollowingisavaliddefinitionofCounterBehaviorthatwouldmakeCounter’smain()methodcountfrom1to100,countingoncepersecond?

 Selecttheonerightanswer.

 

a)ThisclassisaninnerclasstoCounter:

 

classCounterBehavior{

for(inti=1;i<=100;i++);

try{

System.out.println(i);

Thread.sleep(1000);

}catch(InterruptedExceptionx){}

}

}

 

b)ThisclassisaninnerclasstoCounter:

 

classCounterBehaviorimplementsRunnable{

publicvoidrun(){

for(inti=1;i<=100;i++);

try{

System.out.println(i);

Thread.sleep(1000);

}catch(InterruptedExceptionx){}

}

}

}

 

c)Thisclassisatop-levelclass:

 

staticclassCounterBehaviorimplementsRunnable{

publicvoidrun(){

try{

for(inti=1;i<=100;i++){

System.out.println(i);

Thread.sleep(1000);

}

}catch(InterruptedExceptionx){}

}

}

Answer____________

 

Question6:

Giventhefollowingclassdefinition:

classA{

publicintx;

privateinty;

classB{

protectedvoidmethod1(){

}

classC{

privatevoidmethod2(){

}

}

}

}

 

classDextendsA{

publicfloatz;

}

 

Whatcanmethod2()accessdirectly,withoutareferencetoanotherinstance?

Selectallvalidanswers.

 

a)thevariablexdefinedinA

 

b)thevariableydefinedinA

 

c)method1definedinB

 

d)thevariablezdefinedinD

 

Answer____________

 

Question7:

Youhavean8-bitfileusingthecharactersetdefinedbyISO8859-8.YouarewritinganapplicationtodisplaythisfileinaTextArea.Thelocalencodingisalreadysetto8859-8.Howcanyouwriteachunkofcodet

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

当前位置:首页 > 幼儿教育 > 唐诗宋词

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1