1、
if (x>0) {
System.out.println("first");
}else if (x>-3) {
System.out.println("second");
}else {
System.out.println("third");
}
Which range of x value would print the string "second"?
A. x > 0
B. x > -3
C. x <= -3
D. x <= 0 & x > -3
2、
Which is corrected argument of main() method of application?
A. String args
B. String ar[]
C. Char args[][]
D. StringBuffer arg[]
3、
What will be written to the standard output when the following program is run?
public class Qd803 {
public static void main(String args[]) {
String word = "restructure";
System.out.println(word.substring(2, 3));
}
}
A.est
B.es
C.str
D.st
E.s
4、
Which line contains a constructor in this class definition?
public class Counter { // (1)
int current, step;
public Counter(int startValue, int stepValue) { // (2)
set(startValue);
setStepValue(stepValue);
}
public int get() { return current; } // (3)
public void set(int value) { current = value; } //(4)
public void setStepValue(int stepValue) {
step = stepValue;
} // (5)
}
A. Code marked with (1) is a constructor
B. Code marked with (2) is a constructor
C. Code marked with (3) is a constructor
D. Code marked with (4) is a constructor
E. Code marked with (5) is a Constructor
5、
哪些是将一个十六进制值赋值给一个long型变量:
A. long number = 345L;
B. long number = 0345;
C. long number = 0345L;
D. long number = 0x345L;
6、
Float s=new Float(0.9F);
Float t=new Float(0.9F);
Double u=new Double(0.9);
Which expression?s result is true?
A. s==t
B. s.equals(t)
C. s==u
D. t.equals(u)
7、
Consider the following class:
1. class Test(int i) {
2. void test(int i) {
3. System.out.println(“I am an int.”);
4. }
5. void test(String s) {
6. System.out.println(“I am a string.”);
7. }
8.
9. public static void main(String args[]) {
10. Test t=new Test();
11. char ch='y';
12. t.test(ch);
13. }
14. }
Which of the statements below is true?(Choose one.)
A. Line 5 will not compile, because void methods cannot be overridden.
B. Line 12 will not compile, because there is no version of test() that rakes a char argument.
C. The code will compile but will throw an exception at line 12.
D. The code will compile and produce the following output: I am an int.
E. The code will compile and produce the following output: I am a String.
8、
When creating a class that associates a set of keys with a set of values, which of these interfaces is most applicable?
A. Collection
B. Set
C. SortedSet
D. Map
9、What will be written to the standard output when the following program is run?
class Base {
int i;
Base() {
add(1);
}
void add(int v) {
i += v;
}
void print() {
System.out.println(i);
}
}
class Extension extends Base {
Extension() {
add(2);
}
void add(int v) {
i += v*2;
}
}
public class Qd073 {
public static void main(String args[]) {
bogo(new Extension());
}
static void bogo(Base b) {
b.add(8);
b.print();
}
}
A. 9
B. 18
C. 20
D. 21
E. 22
10、What will be written to the standard output when the following program is run?
public class Q03e4 {
public static void main(String args[]) {
String space = " ";
String composite = space + "hello" + space + space;
composite.concat("world");
String trimmed = composite.trim();
System.out.println(trimmed.length());
}
}
A. 5
B. 6
C. 7
D. 12
E. 13
11、假设在helloapp应用中有一个HelloServlet类,它在web.xml文件中的配置如下:
<servlet>
<servlet-name> HelloServlet </servlet-name>
<servlet-class>org.javathinker.HelloServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name> HelloServlet </servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping>
那么在浏览器端访问HelloServlet的URL是什么?
选项:
A. http://localhost:8080/HelloServlet
B. http://localhost:8080/helloapp/HelloServlet
C. http://localhost:8080/helloapp/org/javathinker/hello
D. http://localhost:8080/helloapp/hello
12、HttpServletRequest对象是由谁创建的?
选项:
A.由Servlet容器负责创建,对于每个HTTP请求,Servlet容器都会创建一个HttpServletRequest对象
B.由JavaWeb应用的Servlet或JSP组件负责创建,当Servlet或JSP组件响应HTTP请求时,先创建HttpServletRequest对象
13、jspForward1.jsp要把请求转发给jspForward2.jsp,应该在jspForward1.jsp中如何实现?
选项:
A. <a href=“jspForward2.jsp”>jspForward2.jsp </a>
B. <jsp:forward page=“jspForward2.jsp”>
14、从HTTP请求中,获得请求参数,应该调用哪个方法?
选项:
A. 调用HttpServletRequest对象的getAttribute()方法
B. 调用ServletContext对象的getAttribute()方法
C. 调用HttpServletRequest对象的getParameter()方法
15、假设在helloapp应用中有一个HelloServlet类,它位于org.javathinker包下,那么这个类的class文件应该放在什么目录下?
选项:
A. helloapp/HelloServlet.class
B. helloapp/WEB-INF/HelloServlet.class
C. helloapp/WEB-INF/classes/HelloServlet.class
D. helloapp/WEB-INF/classes/org/javathinker/HelloServlet.class
16、以下代码能否编译通过,假如能编译通过,运行时得到什么打印结果?
request.setAttribute("count",new Integer(0));
Integer count = request.getAttribute("count");
选项:
A. 不能编译通过
B. 能编译通过,并正常运行
C. 编译通过,但运行时抛出ClassCastException
17、"事务的所有操作在数据库中要么全部正确反映出来要么全部不反映",这是事务的哪一个特性?
A. 原子性
B. 一致性
C. 隔离性
D. 持久性
18、为数据表创建索引的目的是()
A、提高查询的检索性能
B、创建唯一索引
C、创建主键
D、归类
19、已知成绩关系如下所示。
成绩:
学号 课程号 分数
S1 C1 80
S1 C2 75
S2 C1 null
S2 C2 55
S3 C3 90
执行SQL语句:
SELECT COUNT(DISTINCT 学号)
FROM 成绩
WHERE 分数>60
查询结果中包含的元组数目是( )
A 1
B 2
C 3
D 4
二、多选题,每小题4分,共40分
20、In SQL, the results of a _____ statement can be used to process a _____ statement.
A. INSERT, SELECT
B. SELECT, INSERT
C. INSERT, DELETE
D. DELETE, INSERT
21、Choose the three valid identifiers from those listed below.
A. IDoLikeTheLongNameClass
B. $byte
C. const
D. _ok
E. 3_case
22、Which of these are keywords in Java?
A. default
B. NULL
C. String
D. throws
E. long
23、下面关于继承的叙述,正确的是:
A. In Java programming language only allows single inheritance.
B. In Java programming language allows a class to implement only one interface.
C. In Java programming language a class cannot extend a class and implement a interface together.
D. In Java programming language single inheritance makes code more reliable
24、Give the code fragment:
1) switch(x){
2) case 1:System.out.println(“Test 1”);break;
3) case 2:
4) case 3:System.out.println(“Test 2”);break;
5) default:System.out.println(“end”);
6) }
which value of x would cause “Test 2” to the output:
A. 1
B. 2
C. 3
D. default
25、Give the following method:
public void example(){
try{
unsafe();
System.out.println(“Test1”);
}catch(SafeException e){System.out.println(“Test 2”);
}finally{System.out.println(“Test 3”);}
System.out.println(“Test 4”);
}
Which will display if method unsafe () run normally?
A. Test 1
B. Test 2
C. Test 3
D. Test 4
26、给出下面的代码片断:
1) public void create() {
2) Vector myVect;
3) myVect = new Vector();
4) }
下面的哪些陈述为true(真)?
A. The declaration on line 2 does not allocate memory space for the variable myVect.
B. The declaration on line 2 allocates memory space for a reference to a Vector object.
C. The statement on line 2 creates an object of class Vector.
D. The statement on line 3 creates an object of class Vector.
E. The statement on line 3 allocates memory space for an object of class Vector
27、class Person {
private int a;
public int change(int m){ return m; }
}
public class Teacher extends Person {
public int b;
public static void main(String arg[]){
Person p = new Person();
Teacher t = new Teacher();
int i;
// point x
}
}
在// point x处的哪些申明是句法上合法的:
A. i = m;
B. i = b;
C. i = p.a;
D. i = p.change(30);
E. i = t.b.
28、客户请求访问HTML页面与访问Servlet有什么异同?
选项:
A.相同:都使用HTTP协议
B.区别:前者Web服务器直接返回HTML页面,后者Web服务器调用Servlet的方法,由Servlet动态生成HTML页面
C.相同:前者Web服务器直接返回HTML页面,后者Web服务器直接返回Servlet的源代码。
D.区别:后者需要在web.xml中配置URL路径。
E.区别:前者使用HTTP协议,后者使用RMI协议。
29、下面对于关系的叙述中,哪些正确的?
A 关系中的每个属性是不可分解的
B 在关系中元组的顺序是无关紧要的
C 任意的一个二维表都是一个关系
D 每一个关系只有一种记录类型
30、设有"学生-选课-课程"三个关系如下:
S(S#,SNAME,SEX,AGE),
SC(S#,C#,GRADE),
C(C#,CNAME,TEACHER)
若要求查找姓名中第一个字为'王'的学生号和姓名。下面列出的SQL语句中,哪个(些)是正确的?
A.SELECT S#,SNAME FROM S WHERE SNAME=′王%′
B.SELECT S#,SNAME FROM S WHERE SNAME LIKE ′王%′
C.SELECT S#,SNAME FROM S WHERE SNAME LIKE ′王_′
D.以上全部