繪表依時序比較說明C、C++、Java 程式語言的主要差異和當時時代需
求。
變數、繫結、和資料型態
Void sub() {
int count;
count = 7;
while ( … ) {
int count;
count += 1;…
}
sum = count * 5;…
}
(1) 說明在C++和Java 語言中,上列敘述是否合法及其原因。
(2) 請討論其中變數count 的記憶體配置的繫結(binding)以及有效範圍
(scoping)。
物件導向程式語言
Java 使用關鍵字extends 來表達繼承觀念:
public class Animal {
public String moveMethod() {
return "Unspecified";
}
}
public class Bird extends Animal {
public String moveMethod() {
return "fly";
}
}
public class Dog extends Animal {
public String moveMethod() {
return "run";
}
}
public class Fish extends Animal {
public String moveMethod() {
return "swim";
}
}
(1) 繪出物件類別繼承圖。(7 分)
(2) 充分利用多型(polymorphism)特性寫一主程式(語意表達清楚),
宣告一陣列(array)中有3 Bird,2 Fish,1 Dog,該程式以一簡單迴
圈以亂數隨機印出這六隻動物其中之一的動作1000 次,如Fish(4)
swim …
給定文法(15 分)
<start>::= <stmt>
<stmt>::= <if-stmt> | <assign>
<if-stmt>::= if <expr> then<stmt>
| if <expr> then <stmt> else <stmt>
<assign>::= <ident> := <digit>
<expr>::= <ident> = <digit>
<digit>::= 0 | 1 | …| 9
<ident>::= a | b | …| z
剖析輸入 “if x = 0 then if y = 1 then z := 2 else w := 3”
繪出完整剖析樹之一,並說明另一可能之問題。
RSS(Really Simple Syndication)為XML 語言的應用,被使用於網站最
新頭條訊息,並提供給需求者參考。
(1) 說明何謂XML。
(2) 試以RSS 提供者角度說明程式的功能與程式重點。
(3) 試以RSS 引用者角度說明程式的功能與程式重點。
可觀看題目詳解,並提供模擬測驗!(免費會員無法觀看研究所試題解答)