exam2

更新时间:2024-04-24 22:14:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

题号 分数 Java项目实训理论阶段考试

姓名:_______________ 学员编号:________________

以下由阅卷老师填写: 第一部分 第二部分 总分 阅卷人 一 二 小计 一 二 三 四 小计 评语 第一部分(共40分)

一、(10x3分)单选题,选择最适合的答案 1. For the code below: class Test { private int m; public static void fun() { // some code… } }

How to make the member variable m be visited by the function fun()? (B) (A) Change private int m to protected int m (B) Change private int m to public int m (C) Change private int m to static int m (D) Change private int m to int m 2. For code below:

class DataServer extends Server { public String serverName; public DataServer() { serverName = \ super(serverName); } }

Which statement is right? ( ) A. Code can pass the compilation B. Code can pass the compilation but a fault would happen in creating object of DataServer C. Code can NOT pass the compilation for the error in the 2nd line D. Code can NOT pass the compilation for the error in the 5th line 3. Which statement below is incorrect: ( ) A. float a = 2.0 B. double b=2.0 C. int c=2 D. long d=2

4. Which one below is correct to define and create an array? ( ) A. int a[5]; B. int a[] = new [5]; C. int a[] = {1,2,3,4,5}; D. int a = new int[5];

5. For the code below, which one can replace the line 7? ( ) public class Base { int w,x,y,z; public Base(int a, int b) { x=a;y=b;

1

} public Base(int a, int b, int c, int d) { x=a; y=b; // line 7 w=d; z=c; } } A. Base(a,b) B. this(a,b,x,y) C. this(a,b) D. Base(x,y) 6. For code below: String s = \

which of the following is true ? A:s += \B:char c = s[1];

C:int len = s.length; D:byte t = s[0];

7. If a method defined in a derived class has the same name, return type and parameters with the base one, we call this situation as: ( ) A. overload B. override C. inheritance D. construction

8. Which line is the right sequence to declare in one compile unit? ( ) A. package,import,class B. class,import,package C. import,package,class D. package,class,import

9. What will happen if you try to compile and execute B’s main() method?( ) class A { int i; A(int i) { this.i = i * 2; } }

class B extends A { public static void main(String[] args) { B b = new B(2); } B(int x) { System.out.println(x); } } A. The instance variable i is set to 4 B. The instance variable i is set to 2 C. The instance variable i is set to 0 D. This code will not compile

10. For the code below, which statement is right? ( ) public class MyClass { static int myArg = 1; public static void main(String[] args) { int myArg; System.out.println(myArg); } } A. Compiles, result is 1 B. Compiles, result is 0 C. Compile error for no initialization for myArg D. Compile error for local variable myArg has the same name with a static one

2

二、(5*2分) 完成程序。

1、简单介绍下jdk1.5引入的新特性和这些新特性的基本用法。(5分)

2、写一个类,保证用户只能拿到这个类的唯一的实例. (5

分) 3

第二部分(共60分) 一、数据库(10分) 1、有如下两张表:

部门表dept (deptId --部门编号 ,dName--部门名称 );

员工表emp (empNo--部门编号, eName- 员工名称, deptId--部门编号) 注意: emp的deptId 是dept表 deptId的外键),dname并没有唯一性约束。 用一条sql语句查询每个部门共有多少人. 并且显示的部门要求人数>3.(3分) 结果如下:

dName employeeNum 人力资源部 5 财务部 6 销售部 4 … …

2、有以下三个表:

学生基本信息表:有学号,姓名,班级,年龄 :student(stuid,sname , class, age ); 课程表:有课程编号,课程名称: course (courseid , cname )

学生选课表:有学号,课程编号,成绩: stu_cou (stuid,courseid, score ) 用一句sql找出选了全部课程的学生的姓名和年龄.(3分)

用一句sql找出不合格课程在两门以上的学生姓名和平均分. (3分)

4

二、jsp 和 servlet(15分)

1、JSP有几大内置对象,举例说明,每个对象常用的方法有哪些?(5分)

2、描述JSP和Servlet的区别、共同点、各自应用的范围。(5分)

3、请问Servlet线程安全吗? 如果说是线程安全的话,它是怎么来实现线程安全的? 如果是线程不安全的话,Servlet中的线程不安全是因为什么引起的,有哪几种解决方案.请详细解答?(5分)

5

三、Struts2(10分)

1、STRUTS2是一个什么样的框架,在项目开发当中,工作在哪个层次?struts2框架线程安全吗?它在JAVA WEB开发中的作用是什么?简述一下struts2的原理及流程(5分)

2、如果要在JAVA WEB项目中运用struts2技术,至少需要两个XML配置文件,请说明这两个配置文件的文件名,以及这两个配置文件需要配置的大概内容及其作用 (5分)

6

四、Hibernate(10分)

1、看以下hbm配置文件片断:

请问Hiberante是一个什么样的框架,在项目开发当中,工作在哪个层次?以上代码当中inverse属性的含义是什么?cascade属性又是什么含义?(5分)

2、请看以下hbm配置文件片断

请问这里lazy属性的含义,默认值是多少?请举例说明hibernate批量加载的含义,如何设置?如果我设置了延迟加载为true,如果在session关闭之后才去关联的对象,是否会出错,怎么解决?(5分)

7

五、Spring(15分)

1、简述你对IoC(Inversion of Control)的理解,描述一下Spring中实现DI(Dependency Injection)的几种方式。(5分)。

2、Spring提倡面向切面编程,请讲一下你对它的理解,它有什么好处。在你做的项目中有用到AOP吗,有的话又是用AOP实现了什么功能?(5分)

8

3、SSH指的是什么?我们在进行SSH整合时,需要注意些什么?Spring又提供了哪些功能?经spring代理后的Action线程安全吗?(5分)

9

本文来源:https://www.bwwdw.com/article/2sgp.html

Top