java考试题(2)

2018-12-19 22:19

}

public void methodB(){

synchronized(lock){对o1进行操作} }public void methodC(){

synchronized(lock2){对o2进行操作}

}public void methodD(){synchronized(lock2){ 对o2进行操作 }} }

D. public class Foo{

private Object lock = new Object(),lock2 = new Object(); private Object o1,o2;public void methodA(){ synchronized(lock){ 对o1进行操作 }

}public void methodB(){

synchronized(lock2){对o1进行操作} }public void methodC(){

synchronized(lock){对o2进行操作}

}public void methodD(){synchronized(lock2){对o2进行操作} }}

考生答案:C

14.以下创建线程的方式正确的是[3分]

A. 一旦一个线程被创建,它就立即开始运行

B. 使用start()方法可以使一个线程成为可运行的,但是它不一定立即开始运行

C. 当一个线程调用sleep()方法,时间到了,线程会立即开始运行。 D. 一个线程不可能从阻塞状态直接进入运行状态 考生答案:D 参考答案:BD

15.试题15以下创建线程的方式正确的是[3分]

A. class Runner implements Runnable {public void run() { 线程体?}

public static void main(String args[]) { Runner r = new Runner(); Thread t = new Thread(r); t.start(); } }

B. class Runner implements Runnable { public void run() { 线程体?}

public static void main(String args[]) {

Runner t = new Runner(); t.start(); } }

C. class Runner extends Thread { public void run() {线程体?}

public static void main(String args[]){ Thread t = new Runner(); t.start();} }

D. class Runner {

public static void main(String args[]){

Thread t = new Thread(){public void run() {线程体?} }; t.start();} }

考生答案:AC 参考答案:ACD

16.试题16题目代码的功能为:启动线程不断打印当前时间,每隔一秒打印一次,时间格式例如:

2009-12-29 09:09:09class TimerPrinter extends TimerTask {<插入代码>}[3分]

A. public void run() {

DateFormat sdf=new DateFormat(\tln(sdf.format(new Date())); }

public static void main(String args[]) { Timer t = new Timer();

t.schedule(new TimerPrinter(), 0, 1000); }

B. public void run() {

DateFormat sdf=new DateFormat(\tln(sdf.format(new Date())); }

public static void main(String args[]) { Timer t = new Timer();

t.schedule(new TimerPrinter(), 0, 1); }

C. public void run() {

SimpleDateFormat sdf=new SimpleDateFormat(\tem.out.println(sdf.format(new Date())); }

public static void main(String args[]) { Timer t = new Timer();

t.schedule(new TimerPrinter(), 0, 1000); }

D. public void run() {

SimpleDateFormat sdf=new SimpleDateFormat(\tem.out.println(sdf.format(new Date())); }

public static void main(String args[]) { Timer t = new Timer();

t.schedule(new TimerPrinter(), 0, 1); }

考生答案:C

17.试题17TCP/IP的端口号的范围是[3分] A. 0到1023

B. 1024 到 49151 C. 1024 到 49151 D. 0到65535 考生答案:D

18.试题18下列代码中正确获取到Class类的对象的是:[3分] A. String str = \B. Class c2 = int.TYPE;

C. Class c1 = Class.forName (\D.

Button b = new Button(); Class c1 = b.getClass(); Class c2 = c1.getSuperclass(); 考生答案:AD 参考答案:ACD

19.试题19关于java.io.Serializable接口说法正确的是[3分] A. 类通过实现java.io.Serializable 接口以启用其序列化功能 B. java.io.Serializable中有一个run方法,但是没属性

C. java.io.Serializable中有一个serialID属性,但是没有方法

D. java.io.Serializable接口没有方法或属性,仅用于标识可序列化的语义。 考生答案:AD

20.试题20下列代码的作用说法正确的是:

class Person implements java.io.Serializable{}[3分] A. 开启序列化功能,使得Person类的对象可以存储到文件中 B. 开启序列化功能,使得Person类的对象可以在网络上传输 C. 使得Person类的子类的对象可以被序列化 D. 导致Person的子类的对象不可以被反序列化 考生答案:C

参考答案:ABC

21.项目试题试题211)用IO包中的类打开并读取一个文本文件,每次读取一行内容。[40分]

考生答案:


java考试题(2).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:Unit 5 What colour is it Lesson 25 教学设计1

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: