You are on page 1of 3

94 學年 上學期 金門技術學院 資管系 日四技 一年級 程式設計 第一次平時考 出題者 : 陳鍾

學號 : 姓名 : 分數 :

1 變數宣告
(a). 請選出可以做為變數名稱的項目並打勾. (b). 請宣告下列變數 (10%)
(10%)
(1) ( ) 2A (1) 請宣告一個整數 i,並將其初始值設定為 5.
(2) ( ) xyz
(3) ( ) A1 (2) 請宣告一個布林值 b,並將其初始值設為
(4) ( ) BC_5 true.
(5) ( ) hello&1

2 基本運算的結果 (請填寫空格處的內容)
(a). 加減乘除 (15%) (b). 邏輯運算 (15%)
class TestOp1 class TestOp2 {
{ public static void main(String args[]) {
public static void main(String args[]) boolean a = false, b = true, c, d, e, f, g;
{ c = a;
int a=9, b=2, c, d, e; System.out.println("c= "+c);
a-- d = a&&b;
System.out.println("a= "+a); System.out.println("d= "+d);
b+=3; e = a||b;
System.out.println("b= "+b); System.out.println("e= "+e);
c = a*b; f = !a;
System.out.println("c= "+c); System.out.println("f= "+f);
d = a%b; g = (a ==b);
System.out.println("d= "+d); System.out.println("g= "+g);
} }
} }
輸出結果 輸出結果
a= c=
b= d=
c= e=
d= f=
e= g=

3 程式架構 (20%)
(a). 請於右格中寫出一個完整的 Java 程式,可以
印出你的姓名與學號如下. (10%)

姓名 : OOO
學號 : OOOOOOOOO

(b). 請寫出你用來編譯該程式的指令 (5%)

(c). 請寫出你用來執行該程式的指令 (5%)


94 學年 上學期 金門技術學院 資管系 日四技 一年級 程式設計 第一次平時考 出題者 : 陳鍾

學號 : 姓名 :

4 基本控制邏輯 if
(a). 以下是利用 if 寫出一個可以判斷成績的程式, (b) 請寫出一個可以從 35 印到 78 的 for 迴圈.
請填入空格部份 (成績 60 分以上輸出 “及格 ”, 0- (10%)
59 請輸出 “不級格 ”) (10%) class TestFor
class ScoreIf {
{ public static void main(String[] args)
public static void main(String[] args) {
{
int score=79;
if ( )
System.out.println("及格");
if ( )
System.out.println("不及格");
}
} }
}

5 除錯題 (10%)
請圈選出下列 Java 程式中錯誤的項目(共有五個),期望輸出結果
並註明正確的寫法 (右列為本程式所想要產生的
輸出結果) i=0
class 123 {
i=2
public static void main(string[] args)
i=4
{
i=6
int i;
i=8
for (i = = 0; i < 10; i++)
{
if (I % 2 = 0)
System.out.println("i="+i);
}
}
}

You might also like