资源预览内容
第1页 / 共9页
第2页 / 共9页
第3页 / 共9页
第4页 / 共9页
第5页 / 共9页
第6页 / 共9页
第7页 / 共9页
第8页 / 共9页
第9页 / 共9页
亲,该文档总共9页全部预览完了,如果喜欢就下载吧!
资源描述
客户化开发部招聘试题JAVA开发类说明:本套试题共分为五个部分,题型为选择题(单选和多选)和问答题, 满分100分,考试时间为1.5小时。第一部分 Java基础一、选择题(包含单选和多选)( 10 题共20分)1、下面哪种方式发现的成本最高?(A)写完代码后,代码人员自查代码(B)集成测试时(C)编写单元测试时发现(D)小组范围内代码评审2、下面isEmptyString函数写法正确的是?(A) public boolean isEmptyString(String str) return str.length = 0 | str = null;(B) public boolean isEmptyString(String str) return str = null | str.length = 0;(C) public boolean isEmptyString(String str) return str = | str.length = 0;(D) public boolean isEmptyString(String str) return str.equals() | str.length = 0;3、下列哪个类不是Collection的子类: (A)List (B)Set(C)Map (D)Vector4、基于下列声明:Integer s = new Integer( 9 );Integer t = new Integer( 9 );Long u = new Long( 9 );表达式结果为true的是? (A) (s=t)(B) (s.equals(u)(C) (s.equals(t)(D) (s.equals(9)(E) (s.equals(new Integer(9)5、运行该类后,哪个是控制台的输出结果?public class Test static String a =String;public static void main(String args) String b = Strin + g;System.out.println(is equal: + (a = b);(A) true (B) false (C) is equal:true (D) is equal:false6、对于以下代码片断,有行号的代码执行顺序是?class SuperTestprivate String name = Default Name; / 1public SuperTest() System.out.println(SuperTest Construct); / 2class Test extends SuperTestprivate static String const1 = CONST; / 3public Test() System.out.println(Test Construct); / 4public static void main(String args) new Test(); / 5(A)3, 5, 1, 2, 4(B)5, 3, 4, 1, 2(C)3, 5, 2, 4, 1(D)5, 3, 4, 2, 17、下列方法的返回结果是什么?public int f() int i = 0;try +i;finally +i;return +i;(A) 3(B) 2(C) 1(D) 08、如果使用了for(;);则(A).发生编译错误(B).根本不进入循环(C).这是个无限循环(D).发生运行错误9、下列哪一项是MouseMotionListener接口中的方法?(A)Public void mouseMoved(MouseEvent)(B)Public boolean mouseMoved(MouseEvent)(C)Public void mouseMoved(MouseMotionEvent)(D)Public boolean MouseMoved(MouseMotionEvent)(E)Public boolean mouseMoved(MouseMotionEvent)10、对Panel container和Frame container来说,它们的缺省布局管理器分别是:(A)BorderLayout和GridLayout(B)CardLayout和FlowLayout(C)GridLayout和BorderLayout(D)GridBagLayout和FlowLayout(E)FlowLayout 和 BorderLayout二、问答题 (3题共12分)1、 下列方法有哪些错误或隐患?(提示:至少2处)(3分)public void updateData() String sql = update t_a set fok = 1 where fid = ?; Connection conn = getConnection(); PreparedStatement ps = conn.prepareStatement(sql); ps.setString(0, 001); ps.executeUpdate(); ps.close(); conn.close();2、进程和线程的区别和关系? (4分)3、 编程题(5分):程序The Producer generates an integer between 0 and 9 (inclusive), stores it in a CubbyHole object, and prints the generated number. class Producer extends Thread private CubbyHole cubbyhole; private int number; public Producer(CubbyHole c, int number) cubbyhole = c; this.number = number; public void run() for (int i = 0; i 10; i+) cubbyhole.put(i); System.out.println(Producer # + this.number + put: + i); try sleep(int)(Math.random() * 100); catch (InterruptedException e) The Consumer, being ravenous, consumes all integers from the CubbyHole (the exact same object into which the Producer put the integers in the first place) as quickly as they become available. class Consumer extends Thread private CubbyHole cubbyhole; private int number; public Consumer(CubbyHole c, int number) cubbyhole = c; this.number = number; public void run() int value = 0; for (int i = 0; i 10; i+) value = cubbyhole.get(); System.out.println(Consumer # + this.number + got: + value); The Producer and Consumer in this example share data through a common CubbyHole object. And you will note that neither the Producer nor the Consumer make any effort whatsoever to ensure that the Consumer is getting each value produced once and only once. The synchronization between these two threads actually occurs at a lower level, within the get() and put() methods of the CubbyHole object.The Main Programclass ProducerConsumerTest public static void main(String args) CubbyHole c = new CubbyHole(); Producer p1 = new Producer(c, 1); Consumer c1 = new Consumer(c, 1); p1.start(); c1.start(); 请补充类CubbyHole 的代码。class CubbyHole private int contents; / this is the condition variable. private boolean available = false; public synchronized int get() while (available = false) try _(1)_; catch (InterruptedException e) available = _(2)_; _; return conten
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号