103年 地方特考 三等 資訊處理 程式語言 試卷

pdf
155.5 KB
2 頁
MIS
侵權投訴
加載中. ..
PDF
103年特種考試地方政府公務人員考試試
代號:
34460
全一張
(正面)
別:
三等考試
科:
資訊處理
目:
程式語言
考試時間:
2小時
※注意:
禁止使用電子計算器。
(請接背面)
一、定義下述文法(grammar):
expression expression + expression | expression - expression | type
type int | double
畫出 int + int + int parsing tree10
根據上面之文法,請導出所有只包含 2type expression 的結果
expression 一個 type int,另一 type double。(10
請說明何謂模稜兩可的文法(ambiguous grammar)。(5分)
二、網際網路程式與應用的發展,結合了許多技術與分析方法,請用數行文字,說明下
列幾個網際網路應用技術的專有名詞:
說明 HDFS 英文全名,其架構元素與基本運作特性。(8分)
說明 MapReduce 的特性及 Map Reduce 的運作方式。(8分)
說明 NO SQL 的英文全名及其特性。(9分)
三、請以物件導向,多型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年特種考試地方政府公務人員考試試
代號:
34460
全一張
(背面)
別:
三等考試
科:
資訊處理
目:
程式語言
四、例外(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);
}
收藏 ⬇️ 下載