exam2

2019-01-27 11:50

题号 分数 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


exam2.doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:2007年化学成分分析和力学性能测量结果不确定度培训计划

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: