1.Java Application(Java 应用程序)源程序文件编译后的字节码文件的扩展名是( )。
A.java
B.class
C.exe
D.jar
2.下面有关java classloader说法错误的是?
A.Java默认提供的三个ClassLoader是BootStrap ClassLoader,Extension ClassLoader,App ClassLoader
B.ClassLoader使用的是双亲委托模型来搜索类的
C.JVM在判定两个class是否相同时,只用判断类名相同即可,和类加载器无关
D.ClassLoader就是用来动态加载class文件到内存当中用的
3.下面代码运行结果是()
public class Test{
public int add(int a,int b){
try {
return a+b;
}
catch (Exception e) {
System.out.println("catch语句块");
}
finally{
System.out.println("finally语句块");
}
return 0;
}
public static void main(String argv[]){
Test test =new Test();
System.out.println("和是:"+test.add(9, 34));
}
}
A.catch语句块 和是:43
B.编译异常
C.finally语句块 和是:43
D.和是:43 finally语句块
4.运行下面代码,输出的结果是()
class A {
public A() {
System.out.println("class A");
}
{ System.out.println("I'm A class"); }
static { System.out.println("class A static"); }
}
public class B extends A {
public B() {
System.out.println("class B");
}
{ System.out.println("I'm B class"); }
static { System.out.println("class B static"); }
public static void main(String[] args) {
new B();
}
}
5.一个Java源程序文件中定义几个类和接口,则编译该文件后生成几个以.class为后缀的字节码文件。
A.正确
B.错误
6.For which of these values of ais the expression(a != 3 && a != 4 && a != 5 && a != 6)false?
I. 4
II.6
III. 8
A.I only
B.II only
C.III only
D.I and II only
E.I, II, and III
7.下列代码编译和运行的结果是:()
public class Threads4{
public static void main(String[] args){
new Threads4().go();
}
public void go(){
Runnable r=new Runnable(){
public void run(){
System.out.print("foo");
}
};
Thread t=new Thread(r);
t.start();
}
}
A.编译错误
B.抛出运行时异常
C.输出:foo
D.代码正常运行,但是无输出
8.what is the result of the following code?
enum AccountType
{
SAVING, FIXED, CURRENT;
private AccountType()
{
System.out.println(“It is a account type”);
}
}
class EnumOne
{
public static void main(String[]args)
{
System.out.println(AccountType.FIXED);
}
}
A.Compiles fine and output is prints”It is a account type”once followed by”FIXED”
B.Compiles fine and output is prints”It is a account type”twice followed by”FIXED”
C.Compiles fine and output is prints”It is a account type”thrice followed by”FIXED”
D.Compiles fine and output is prints”It is a account type”four times followed by”FIXED”
E.Compilation fails
9.如果希望监听TCP端口9000,服务器端应该怎样创建socket?
A.new Socket("localhost",9000);
B.new ServerSocket(9000);
C.new Socket(9000);
D.new ServerSocket("localhost",9000);
10.下列关于系列化和反序列化描述正确的是:
A.序列化是将数据转为n个 byte序列的过程
B.反序列化是将n个 byte转换为数据的过程
C.将类型int转换为4 byte是反序列化过程
D.将8个字节转换为long类型的数据为序列化过程