B. giveMes C. whataQuiz D. $d2000_
5. 下面哪一个是合法的数组声明和构造语句( C ) A. int[] ages = [100];
B. int ages = new int[100]; C. int[] ages = new int[100]; D. int() ages = new int(100);
6. 下面说法不正确的是( C )
A. 一个子类的对象可以接收父类对象能接收的消息;
B. 当子类对象和父类对象能接收同样的消息时,它们针对消息产生的行为可能不同; C. 父类比它的子类的方法更多;
D. 子类在构造函数中可以使用super( )来调用父类的构造函数;
7. 给出下面代码段, 哪行将引起一个编译时错误?( D ) 1) public class Test { 2) int n = 0; 3) int m = 0;
4) public Test(int a) { m=a; }
5) public static void main(String arg[]) { 6) Test t1,t2; 7) int j,k; 8) j=3; k=5;
9) t1=new Test(); 10) t2=new Test(k); 11) } 12) }
A. 行1 B. 行4 C. 行6 D. 行9 8. 下面程序中类ClassDemo中定义了一个静态变量sum,分析程序段的输出结果。( C )
class ClassDemo {
public static int sum=1; public ClassDemo() { sum = sum + 5; } }
public class ClassDemoTest{
public static void main(String args[]) { ClassDemo demo1=new ClassDemo(); ClassDemo demo2=new ClassDemo(); System.out.println(demo1.sum); } }
A. 0 B. 6 C. 11 D. 2 9.下面这些类型的应用,那个不使用Java语言来编写? ( A )
A)JavaScript B)Applet C)Servlet D)Java Swing
10. 声明成员变量时,如果不使用任何访问控制符(public, protected, private),则以下哪种类型的类不能对该成员进行直接访问 ( D )
A)同一类 B)同一包中的子类 C)同一包中的非子类 D)不同包中的子类
11. 下列哪种异常是检查型异常,需要在编写程序时声明 ( C ) A)NullPointerException B)ClassCastException
C)FileNotFoundException D) IndexOutOfBoundsException 12. 下面哪个流类属于面向字符的输入流( D ) A)BufferedWriter B)FileInputStream C)ObjectInputStream D) InputStreamReader
13. 下面关于数组声明和初始化的语句那个有语法错误?( C ) A)int a1[]={3,4,5};
B)String a2[]={\C)String a3[]=new String(3); D)int[][] a4=new int[3][3];
14. 下面哪一行代码正确的声明了一个类方法(静态方法)?( D ) A)public int method(int i) B)protected method(int i)
C)public static method(String s)
D)protected static void method(Integer i)
15. 下面的方法,当输入为2的时候返回值是多少?( D ) public int getValue(int i) { int result = 0; switch (i) { case 1:
result = result + i; case 2:
result = result + i * 2; case 3:
result = result + i * 3; }
return result; }
A)0 B)2 C)4 D)10 16. getCustomerInfo()方法如下,try中可以捕获三种类型的异常,如果在该方法运行中产生了一个IOException,将会输出什么结果( A ) public void getCustomerInfo() { try {
// do something that may cause an Exception } catch (java.io.FileNotFoundException ex){
System.out.print(\ } catch (java.io.IOException ex){
System.out.print(\ } catch (java.lang.Exception ex){ System.out.print(\ } }
A)IOException!
B)IOException!Exception!
C)FileNotFoundException!IOException!
D)FileNotFoundException!IOException!Exception!
17. 新建一个流对象,下面哪个选项的代码是错误的?( B ) A)new BufferedWriter(new FileWriter(\
B)new BufferedReader(new FileInputStream(\
C)new GZIPOutputStream(new FileOutputStream(\D)new ObjectInputStream(new FileInputStream(\
18. Java的集合框架中重要的接口java.util.Collection定义了许多方法。选项中哪个方法不是Collection接口所定义的?( C ) A)int size()
B)boolean containsAll(Collection c) C)compareTo(Object obj) D)boolean remove(Object obj)
19. 一个线程在任何时刻都处于某种线程状态(thread state),例如运行状态、阻塞状态、就绪状态等。一个线程可以由选项中的哪种线程状态直接到达运行状态?( D ) A)死亡状态
B)阻塞状态(对象lock池内) C)阻塞状态(对象wait池内) D)就绪状态
20. 选项中哪一行代码可以替换题目中//add code here而不产生编译错误?( A ) public abstract class MyClass {
public int constInt = 5; //add code here
public void method() { } }
A)public abstract void method(int a); B)value = value + 5; C)public int method();
D)public abstract void anotherMethod() {}
21. File类是IO包中唯一表示磁盘文件信息的对象,它定义了一些与平台无关的方法来操纵文件。通过调用File类提供的各种方法,我们能够创建、删除文件、重命名文件、判断文件的读写权限及是否存在,设置和查询文件的最近修改时间等。下面的代码片段实现的是什么功能?( B )
File file = new File(\ if (file.exists()) { file.delete();
} A)创建C:\\test.dat。 B) 删除C:\\test.dat。
C) 打开C:\\test.dat文件输出流。 D) 移动C:\\test.dat
22. 阅读Shape和Circle两个类的定义。在序列化一个Circle的对象circle到文件时,下面哪个字段会被保存到文件中? ( B ) class Shape {
public String name; }
class Circle extends Shape implements Serializable{ private float radius; transient int color;
public static String type = \}
A)name B)radius C)color D)type
23. 下面是People和Child类的定义和构造方法,每个构造方法都输出编号。在执行new Child(\的时候都有哪些构造方法被顺序调用?请选择输出结果 ( D ) class People {
String name;
public People() { System.out.print(1); } public People(String name) { System.out.print(2); this.name = name; } }
class Child extends People { People father;
public Child(String name) { System.out.print(3); this.name = name;
father = new People(name + \ }
public Child(){ System.out.print(4); } }
A)312 B) 32 C) 432 D) 132
24. 下面哪个选项中的代码没有定义内部类,或者错误的定义了内部类? ( C ) A)public Class Line { int length;
Class Point {//内部类代码}
}
B) public Class Line {
public Point getPoint() {
return new Point(){//内部类代码}; } }
C) public Class Line { //外部类代码 }
Class Point {//内部类代码} D) public Class Line {
public int calcLength() {
Class Point {//内部类代码} } }
25. list是一个ArrayList的对象,哪个选项的代码填写到//todo delete处,可以在Iterator遍历的过程中正确并安全的删除一个list中保存的对象?( D ) Iterator it = list.iterator(); int index = 0;
while (it.hasNext()){
Object obj = it.next();
if (needDelete(obj)) { //needDelete返回boolean,决定是否要删除 //todo delete }
index ++; }
A)list.remove(obj); B)list.remove(index); C)list.remove(it.next()); D)it.remove();
面试就不说了,就笔试而言,参加的很多招聘给我的感觉就是和学校期末考基本没什么区别,大都考一些很基本的东西,当然是对应届生而言,除此之外就是多出来一些智力题和IT名词,对于智力题,用同事的话来说是用来玩你的,在我看来也无关紧要,IT名词的话可以多用GOOGLE查看一下,费点时间,也不是很难记,大概了解一下有东西扯就OK.就突击基础知识而言,我是没有兴趣从头到尾看一遍JAVA的,话说回来,现在的笔试出题者和期末考的命题者一样懒,很多都是网上流传N久的东西,所以我决定从网上捞一些试题做做,排查知识点的盲区,这样比较有针对性. 一、单项选择题
1.Java是从()语言改进重新设计。 A.Ada B.C++ C.Pasacal D.BASIC
答案:B 这个题没什么难度,虽然我只了解C++,当初老师也就只拿JAVA和C++比较.