← 返回測驗首頁

RAYIN / INTERVIEW

Java 基礎測驗

從短篇程式理解資料處理、集合操作與流程控制。

10 題單選題 · 每題 10 分 · 滿分 100 分

選擇第一個答案後開始計時,交卷後顯示分數、耗時與交卷次數。重新作答只清空選項,不會重置計時或交卷紀錄。

請先由主管建立面試場次。正在讀取本機紀錄…

1. 執行以下程式後,total 是多少?

int total = 0;
for (int i = 2; i <= 8; i += 2) {
    total += i;
}

2. 已知 name 可能為 null,要安全地判斷其文字內容是否為 Amy,哪個寫法合適?

3. 執行以下程式後,names.size() 是多少?(已匯入 java.util.ArrayList)

ArrayList<String> names = new ArrayList<>();
names.add("Amy");
names.add("Ben");
names.remove("Amy");

4. 要將員工編號對應到員工姓名,並依編號查詢,哪種介面最適合表示這種資料?

5. 要將字串 "25" 轉為整數並加上 5,哪段程式會讓 result 的值為整數 30?

6. 執行以下程式後,畫面會輸出什麼?

int score = 75;
if (score >= 80) {
    System.out.println("A");
} else if (score >= 60) {
    System.out.println("B");
} else {
    System.out.println("C");
}

7. 同一類別中定義 print(int value) 與 print(String value),這稱為什麼?

8. 執行以下程式後,items.length 的值是多少?

String text = "Java,Delphi,SQL";
String[] items = text.split(",");

9. 執行以下程式後,count 的值是多少?

int count = 0;
int balance = 100;
while (balance >= 30) {
    balance -= 30;
    count++;
}

10. 在 Java 方法中,若要立即結束目前方法的執行,應使用哪個關鍵字?

← 回到測驗首頁