java考核题
时间:2017-02-22 下载该word文档
1. 下面关于java.lang.Exception类的说法正确的是(A) A 继承自Throwable B Serialable CD 不记得,反正不正确
2. 下面程序的运行结果是(B)
String str1 = "hello"; String str2 = "he" + new String("llo"; System.err.println(str1 == str2; A .true B.false C.1 D.0 3 下列说法正确的有(C)
A. class中的constructor不可省略
B. constructor必须与class同名,但方法不能与class同名 C. constructor在一个对象被new时执行 D.一个class只能定义一个constructor 4.下面程序的运行结果:(B)
public static void main(String args[] {
Thread t = new Thread( {
public void run( { pong(; } };
t.run(; System.out.print("ping";
}
static void pong( {
System.out.print("pong";
}
A pingpong B pongping C pingpong和pongping都有可能5. 下列属于关系型数据库的是(AB)
都不输出 D
A. Oracle B MySql C IMS D MongoDB 6. 存在使i + 1 < i的数吗(A) A 存在 B 不存在
7. 0.6332的数据类型是(B)
A float B double C Float D Double
8. 下面哪个流类属于面向字符的输入流( D A BufferedWriter B FileInputStream C ObjectInputStream
D InputStreamReader
8. Java接口的修饰符可以为(D)
A private B protected C final D abstract 9. 不通过构造函数也能创建对象吗(A) A 是 B 否
10.新建一个流对象,下面哪个选项的代码是错误的?(D) A)new BufferedWriter(new FileWriter("a.txt"; B)new BufferedReader(new FileInputStream("a.dat"; C)new GZIPOutputStream(new FileOutputStream("a.zip"; D)new ObjectInputStream(new FileInputStream("a.dat"; 11. 下面程序的运行结果是什么()
class HelloA {
public HelloA( { System.out.println("HelloA"; } { System.out.println("I'm A class"; } static { System.out.println("static A"; } }
public class HelloB extends HelloA { public HelloB( { System.out.println("HelloB"; } { System.out.println("I'm B class"; } static { System.out.println("static B"; } public static void main(String[] args { new HelloB(; }
} static A static B HelloA I'm A class HelloB I'm B class 12. 下面代码的运行结果为:(C)
import java.io.*; import java.util.*;
public class foo{
public static void main (String[] args{
String s;
System.out.println("s=" + s;
} }
A 代码得到编译,并输出“s=” B 代码得到编译,并输出“s=null”
C 由于String s没有初始化,代码不能编译通过 D 代码得到编译,但捕获到 NullPointException异常
13.下面的方法,当输入为2的时候返回值是多少?(D)
public static 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; }
A0 B2 C4 D10 14.下面是People和Child类的定义和构造方法,每个构造方法都输出编号。在执行new Child("mike"的时候都有哪些构造方法被顺序调用?请选择输出结果 (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 + ":F";
}
public Child( { System.out.print(4; } } A312 B 32 C 432 D 132 15.接口和抽象类的区别是什么?
抽象类是在普通类中有了抽象方法所以变成了抽象类,抽象类可以有私有的属