精華區beta NTU-Exam 關於我們 聯絡資訊
課程名稱︰ 物件導向程式設計 課程性質︰ 系訂必修 課程教師︰ 陳俊良 開課學院: 電資學院 開課系所︰ 資工系 考試日期(年月日)︰ Apr 19 2007 考試時限(分鐘): 120 min 是否需發放獎勵金: 是 (如未明確表示,則不予發放) 試題 : 1. Please compare the following pairs of terms. [10x(1+1+2)%] (a) expression vs. statement (b) formal parameter vs. actual argument (c) stack memory vs. heap memory (d) program vs. thread (e) primitive data type vs. reference data type (f) variable type vs. variable value (g) class vs. object (h) class method vs. instance method (i) method overloading vs. method overriding (j) scope vs. encapsulation 2. Almost all of today's computers follow the von Neumann architecture. One of the major concepts of the von Neumann architecture is "stored program". (a) What does "stored program" mean? [3%] (b) Use this concept to describe the operation of the von Neumann architecture briefly. [3%] (c) Use this concept to answer what the role of high level language is. [3%] 3. "this" is a very important keyword of OO language. Please say something (at least 5) about it. [5x2%] 4. (a) What does the following code do? [5%] (b) What are your judgments on it? [5%] class A { private int p; public int getP() { return p; } public void setP(int n) { p = n; } } 5. The following is a possible solution of Homework #6. Unfortunately, it doesn't word, because there are 10 errors. Please point them out. If you point out one error, you will earn 3 points, however, if your amswer introduces extra error. your penalty is also 3 points. [30%] 1: import java.io; 2: import java.util.Vector; 3: import java.util.Random; 4: package tw.edu.ntu.csie.oop.exam; 5: class Pick { 6: public static void main(String args) throws Exception { 7: BufferedReader in = new BufferedReader(new FileReader(args[0])); 8: protected String s; 9: while ((s = in.readLine()) != null) { 10: s = s.trim(); 11: if(s.length() == 0) continue; 12: s = s.replace('\t', ' ').toUpperCase(); 13: StringBuilder sb = new StringBuilder(s); 14: while (1) { 15: k = sb.indexOf(" "); 16: if (k == -1) break; 17: sb.deleteCharAt(k); 18: } 19: boolean inWord = falsel; 20: for (int i = 0; i < sb.length(); i++) { 21: char c = sb.charAt(i); 22: if (char.isLetter(c)) { 23: if (inWord) sb.setCharAt(i, (char(c - 'A' + 'a'))); 24: inWord = true; 25: } else { 26: inWord = false; 27: } 28: } 29: names.addElement(sb.toString()); 30: } 31: Ramdom r; 32: BufferedReader in = new BufferedReader( 33: new InputStreamReader(System.in)); 34: while (names.size() > 0) { 35: System.out.print("press ENTER to pick a name ..."); 36: in.readLine(); 37: System.out.println(names.remove(r.nextInt(names.size()))); 38: } 39: } 40: private Vector<String> names = new Vector<String>(); 41: } -- ╭ ╮ ┬ ╮│ ╮ ╭ ╭╮ ╭ ╭─┬ ╭──╮ ╮ ╭ ╭┬─╮ ╰────╮ ─┼─ ╮│ │ │ ││ │ │ │ │ │ │ ╭────╮ │││ ─┼╮├─┬╯ │╰╮│ │ │ ├──┤ ╰╮ │ │ │││ │ │ │ │ ││ │ │ ┬ │ │ │ ╰────╯ ╯╯╰ ╰ ╯ ╰─ ╯ ╰╯ ─┴╯╰──╯ ╯ ╰ ┴ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 210.192.193.17