熱門推薦罰單破解實戰交通警察名師 25 年經驗,親授警察臨檢、檢舉魔人、科技執法、車禍糾紛的執法邏輯看課程介紹
購物車我的課程我的書籤免費註冊
資訊處理·103·程式語言1/7

資訊處理 103程式語言考古題

7 題申論題資料來源:考選部下載 .txt
跨年同科91-115

題目為考試當年公告版本,實務標準請以現行規範為準。

試題7
103
1

定義下述文法(grammar): expression → expression + expression | expression - expression | type type → int | double ㈠ 根據上面之文法,請畫出int + int + int 兩個不同的剖析樹(parsing tree)。(10 分) ㈡ 根據上面之文法,請導出所有只包含2 個type 之expression 的結果。該 expression 一個type 為int,另一type 為double。(10 分) ㈢ 請說明何謂模稜兩可的文法(ambiguous grammar)。(5 分)

103
2

網際網路程式與應用的發展,結合了許多技術與分析方法,請用數行文字,說明下 列幾個網際網路應用技術的專有名詞: ㈠ 說明HDFS 英文全名,其架構元素與基本運作特性。(8 分) ㈡ 說明MapReduce 的特性及Map 和Reduce 的運作方式。(8 分) ㈢ 說明NO SQL 的英文全名及其特性。(9 分)

103
3

請以物件導向,多型(polymorphism)的技術,改寫下列計算薪水的程式,其中經 理(manager)薪水是40000,工程師(engineer)薪水是35000。 int getPay(String employeeType) { if (employeeType ==“manager”) { return 40000; else if (employeeType == “engineer”) return 35000; } ㈠ 設計Employee, Manager, Engineer 等三個類別及其屬性(attribute)與方法(method), 方法包括建構子(constructor)。其中 Employee 是抽象類別,有一個保護 (protected)屬性薪水(salary);Manager 和 Engineer 是Employee 的子類別。 (18 分) ㈡ 畫出UML 類別圖。(7 分) 103年特種考試地方政府公務人員考試試題

103
4

例外(exception)處理的應用: ㈠ 試說明Java 對於例外處理的抓取或宣告規則(catch or declare rule)。(7 分) ㈡ 填寫下列空格,完成以下inputScore 方法。該程式要求使用者輸入成績,若輸入為 非數字,則拋出例外(exception)警示,迴圈繼續,直到使用者輸入合理的數字成 績。若輸入的成績沒有介於0-100 間,則把例外向上拋給呼叫的方法。(18 分) public static void inputScore () (1) { String str; boolean valid; double score = 0; Scanner sc = new Scanner(System.in); do { valid = true; System.out.println("Input the score"); str = sc.next(); try { score = Double.parseDouble(str); } catch ( (2) ) { System.out.println(e); valid = false; } } while ( (3) ); if (score >100 || score <0) throw (4) ("分數未介於0-100 間"); System.out.println(score); }

(1){ String str; boolean valid; double score = 0; Scanner sc = new Scanner(System.in); do { valid = true; System.out.println("Input the score"); str = sc.next(); try { score = Double.parseDouble(str); } catch (
(2)) { System.out.println(e); valid = false; } } while (
(3)); if (score >100 || score <0) throw
(4)("分數未介於0-100 間"); System.out.println(score); }
103
5

請問下列Java 程式輸出為何?(20 分) import java.text.DecimalFormat; public class C3 { public static void main(String[] args) { DecimalFormat d = new DecimalFormat("0.00"); double grosspay = 800.416; System.out.println(d.format(grosspay)); grosspay = 1234.567; System.out.printf("%1.2f", grosspay); } }

103
6

下列為一物件導向程式: class A { private int a1; public void m1( ); { a1 = 1;} public void m2( ); { a1 = 3;} } class B extends A { private int b1; private int b2; public void m2( ); { b1 = 1; b2 = 2;} public void m3( ); { a1 = 2; } } 請說明其中的繼承(inheritance)及覆寫(overriding); 並請說明class B 的物件內含那些資料欄位(data fields)?(20 分)

103
7

㈠請說明下列main 程式執行情形。(10 分) ㈡請以此程式解釋動態繫結(dynamic binding)。(10 分) public class X {public String whatIAm() {return “I’m an X.”;}} public class Y extends X {public String whatIAm() {return “I’m a Y.”;}} public static void main(String[] args) throws IOException { X x; BufferedReader reader = new BufferedReader (new InputStreamReader(System.in)); if (reader.readLine().equals(“Go with X”)) x = new X(); else x = new Y(); System.out.println(x.whatIAm()); } // main

同年其他科目103 · 27