笔试题

  • 格式:docx
  • 大小:20.04 KB
  • 文档页数:10
笔试题姓名:
JAVA部分(将答案标红即可)
1.下面哪些是Thread类的方法()
A start() B run() C exit() D getPriority()
2.下面程序的运行结果是()
String str1 = "hello";
String str2 = "he" + new String("llo");
14.不通过构造函数也能创建对象吗()
A是B否
15.ArrayList list = new ArrayList(20);中的list扩充几次()
A 0 B 1 C 2 D 3
16.下面哪些是对称加密算法()
A DES B AES C DSA D RSA
17.新建一个流对象,下面哪个选项的代码是错误的?()
D)new ObjectInputStream(new FileInputStream("a.dat"));
18.下面程序能正常运行吗()
public class NULL {
public static void haha(){
System.out.println("haha");
}
public static void main(String[] args) {
A)new BufferedWriter(new FileWriter("a.txt"));
B)new BufferedReader(new FileInputStream("a.dat"));
C)new GZIPOutputStream(new FileOutputStream("a.zip"));
public int constInt = 5;
//add code here
public void method() {
}
}
A)public abstract void method(int a);
B)constInt = constInt + 5;
C)public int method();
D)public abstract void anotherMethod() {}
8.下列说法正确的是()
A LinkedList继承自ListB AbstractSet继承自Set
C HashSet继承自AbstractSetD WeakMap继承自HashMap
9.存在使i + 1 < i的数吗()
10.存在使i > j || i <= j不成立的数吗()
11.0.6332的数据类型是()
Example ex = new Example();
ex.change(ex.str, ex.ch);
System.out.print(ex.str + " and ");
System.out.print(ex.ch);
}
public void change(String str, char ch[]) {
case 2:
result = result + i * 2;
case 3:
result = result + i * 3;
}
return result;
}
A0 B2 C4 D10
27.选项中哪一行代码可以替换题目中//add code here而不产生编译错误?()
public abstract class MyClass {
}
public class HelloB extends HelloA {
public HelloB() {
System.out.println("HelloB");
}
{ System.out.println("I'm B class"); }
static { System.out.println("static B"); }
D RandomAccessFile in=new RandomAccessFile("file.dat"); in.skip(9); int c=in.readByte();
25.下列哪种异常是检查型异常,需要在编写程序时声明()
A)NullPointerException B)ClassCastException
public static void main(String[] args) {
new HelloB();
}
}
20.getCustomerInfo()方法如下,try中可以捕获三种类型的异常,如果在该方法运行中产生了一个IOException,将会输出什么结果()
public void getCustomerInfo() {
6.如何修改SESSION的生存时间
7.在HTTP 1.0中,状态码401的含义是(?);如果返回“找不到文件”的提示,则可用header函数,其语句为(?);
8.谈谈asp,php,jsp的优缺点
9.请说明php中传值与传引用的区别。什么时候传值什么时候传引用?
10.请写一个函数验证电子邮件的格式是否正确
C)FileNotFoundException D)IndexOutOfBoundsException
26.下面的方法,当输入为2的时候返回值是多少?()
public static int getValue(int i) {
int result = 0;
switch (i) {
case 1:
result = result + i;
A 52 B7 C2 D5
23.指出下列程序运行的结果()
public class Example {
String str = new String("good");
char[] ch = { 'a', 'b', 'c' };
public static void main(String args[]) {
try {
// do something that may cause an Exception
} catch (java.io.FileNotFoundException ex) {
System.out.print("FileNotFoundException!");
} catch (java.io.IOException ex) {
A float B double C Float D Double
12.下面哪个流类属于面向字符的输入流( )
A BufferedWriter B FileInputStream C ObjectInputStream D InputStreamReader
13.Java接口的修饰符可以为()
A private B protected C final D abstract
4.下面程序的运行结果:()
public static void main(String args[]) {
Thread t = new Thread() {
public void run() {
pong();
}
};
t.run();
System.out.print("ping");
}
static void pong() {
28.阅读Shape和Circle两个类的定义。在序列化一个Circle的对象circle到文件时,下面哪个字段会被保存到文件中?( )
class Shape {
public String name;
}
class Circle extends Shape implements Serializable{
11.简述如何得到当前执行脚本路径。
12.JS的转向函数是?怎么引入一个外部JS文件?
((NULL)null).haha();
}
}
19.下面程序的运行结果是什么()
class HelloA {
public HelloA() {
System.out.println("HelloA");
}
{ System.out.println("I'm A class"); }
static { System.out.println("static A"); }
People father;
public Child(String name) {
System.out.print(3);
= name;
father = new People(name + ":F");
}
public Child() {
System.out.print(4);
}
}
System.out.print("IOException!");
} catch (ng.Exception ex) {
System.out.print("Exception!");
}
}
A)IOException!
B)IOException!Exception!
C)FileNotFoundException!IOException!
D)FileNotFoundException!IOException!Exception!
21.下面代码的运行结果为:()
import java.io.*;