浙江工商大学java期末试卷及答案

上传人:aa****6 文档编号:39207519 上传时间:2018-05-13 格式:DOC 页数:10 大小:38KB
返回 下载 相关 举报
浙江工商大学java期末试卷及答案_第1页
第1页 / 共10页
浙江工商大学java期末试卷及答案_第2页
第2页 / 共10页
浙江工商大学java期末试卷及答案_第3页
第3页 / 共10页
浙江工商大学java期末试卷及答案_第4页
第4页 / 共10页
浙江工商大学java期末试卷及答案_第5页
第5页 / 共10页
点击查看更多>>
资源描述

《浙江工商大学java期末试卷及答案》由会员分享,可在线阅读,更多相关《浙江工商大学java期末试卷及答案(10页珍藏版)》请在金锄头文库上搜索。

1、浙江工商大学Java 语言程序设计基础(英)课程考试试卷,适用专业:电子、通信第 1 页 共 10 页浙江工商大学浙江工商大学 2008 /2009 学年第学年第 二二 学期考试试卷学期考试试卷(B 卷卷)课程名称:课程名称:Java 语言程序设计基础语言程序设计基础(英英) 考试方式:考试方式:开卷开卷 完成时限:完成时限:120 分钟分钟班级名称:班级名称: 学号:学号: 姓名:姓名: Part 1. Single selectionQ.1 Which of the following are NOT valid Java comments? (3 mark) A. / This is a

2、 comment. B. /* This is a comment. */ C. /* This is a comment. */ D. * This is a comment. *Answer:Q.2 Which of the following methods cause the String object referenced by s to be changed? (3 mark) A. s.concat() B. s.toUpperCase() C. s.replace() D. None of the above.Answer:Q.3 Which of the following

3、is not a wrapper class? (3 mark) A. String B. Integer C. Boolean D. CharacterAnswer:Q.4 Given non-static classes Outer and Inner where Inner is declared as an inner class of Outer, how is an instance of outer accessed from within the scope of Inner? (3 mark) A. this B. this.Outer C. Outer.this D. th

4、is.thisAnswer:Q.5 In order for the MyProgram program to be compiled and run, which of the following must be true? (3 mark) A. the MyProgram class must be defined in MyProgram.java浙江工商大学Java 语言程序设计基础(英)课程考试试卷,适用专业:电子、通信第 2 页 共 10 页B. MyProgram must be declared public. C. My program must have a correc

5、tly formed main() method. D. MyProgram must import java.lang.Answer:Q.6 Which of the following are true? (3 mark) A. The Thread class does not inherits the wait() and notify() methods. B. the Object class declares the wait() and notify() methods. C. Only the Synchronized class supports the wait() an

6、d notify() methods. D. The wait() and notify() methods have been deprecated in JDK1.2.Answer:Q.7 Which declares an abstract method in an abstract Java class? (3 mark) A. public abstract method(); B. public abstract void method(); C. public void abstract Method(); E. public abstract void method() Ans

7、wer:Q.8 Which of the following modifiers may NOT be used with a top-level class? (3 mark) A. public B. private C. abstract D. finalAnswer:Q.9 What is the output of the following program when it is invoked using the command line “java Test this is a test”? (3 mark)class Test public static void main(S

8、tring args) System.out.println(args1); A. this B. is C. a D. testAnswer:Q.10 Which is NOT the example of polymorphism? (3 mark) A. Inner classes B. Upcasting浙江工商大学Java 语言程序设计基础(英)课程考试试卷,适用专业:电子、通信第 3 页 共 10 页C. Method overloading D. Method overridingAnswer:Part 2. Read the program and write down the

9、 resultQ.11 Please write down the output: (5 mark) public class Question String s = “Outer”;public static void main (String args) S2 s2 = new S2(); s2.display(); class S1 String s = “S1”;void display() System.out.println(s); class S2 extends S1 String s = “S2”; Answer:Q.12 Please write down the outp

10、ut: (5 mark) public class Outer String s = “Outer”;public static void main (String args) new Outer().new Inner(); Outer () System.out.print(s); class Inner String s = “Inner”;浙江工商大学Java 语言程序设计基础(英)课程考试试卷,适用专业:电子、通信第 4 页 共 10 页Inner() System.out.print(s); Answer:Q.13 Please write down the output: (5

11、mark) import java.util.*; public class Question public static void main (String args) TreeMap map = new TreeMap();map.put(“one”, “1”);map.put(“two”, “2”);map.put(“three”, “3”);displayMap(map); static void displayMap(TreeMap map) Collection c = map.entrySet(); Iterator i = c.iterator(); while(i.hasNe

12、xt() Object o = i.next(); System.out.print(o.toString(); Answer:Q.14 Please write down the output of the program (5 mark) public class Question public static void main (String args) int i = 1; int j = 2; outer: while (i stack = new Stack(); stack.push(s1); stack.push(s2); try String s3 = (String) st

13、ack.pop() +(String)stack.pop(); System.out.println(s3); catch(EmptyStackException e)System.out.println(“Caught Exception”); Answer:Part 3. ProgrammingQ.19 Pleas fill in the blank so that the command line arguments are printed to the output stream. For example, if we run this program use “Java Test t

14、his is a test”, the output of the program will be “this is a test”. Assume that the class is in the package called pract. (6 mark) _ _ public class Test浙江工商大学Java 语言程序设计基础(英)课程考试试卷,适用专业:电子、通信第 8 页 共 10 页public static void main(String args)for(_:args)out.print(_); Q.20 Please fill in the blank so tha

15、t the following code compiles and runs, printing “catch1finnally1finally2” (9 mark) public class Test void f() throw new_; public static void main(String args)_ Exception Test t = new Test(); tryt.f(); catch(_ e)trythrow_;catch(Exception ex)System.out.print(“catch1”);_ ex; finallySystem.out.print(“finally1”); finallySystem.out.print(“finally2”);System.exit(0); Q.21 Physics programming often involves complex numbers. Please design a complex class to implement complex number addition and subtraction operatio

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 大杂烩/其它

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号