[問題] OCJP SE6 - command-line invocations
public class Prac {
public static void main(String[] args) throws Exception{
int x = 6;
Prac p = new Prac();
p.doStuff(x);
System.out.println(" main x = " + x);
}
void doStuff(int x){
System.out.println(" doStuff x = " + x++);
}
}
And the command-line invocations:
javac Prac.java
java Prac 5
--------------------------------------------------------------------
What is the result?
Ans:
B. An exception is thrown at runtime.
我自己原本是寫
C. doStuff x = 6 main x = 6
想請要一下, 是哪邊會丟出 runtime exception? 且是哪種exception?
我有試著自己跑過這個code, 但沒有看到錯誤訊息, 於是仍然困惑著
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 180.217.174.122
※ 文章網址: https://www.ptt.cc/bbs/java/M.1487597752.A.543.html
※ 編輯: uopsdod (180.217.174.122), 02/20/2017 21:36:16
推
02/20 22:35, , 1F
02/20 22:35, 1F
→
02/21 08:10, , 2F
02/21 08:10, 2F
→
02/21 23:48, , 3F
02/21 23:48, 3F
推
02/22 16:18, , 4F
02/22 16:18, 4F
推
02/23 20:14, , 5F
02/23 20:14, 5F
→
02/23 20:14, , 6F
02/23 20:14, 6F
→
02/23 20:14, , 7F
02/23 20:14, 7F
→
02/25 06:33, , 8F
02/25 06:33, 8F
→
02/25 06:33, , 9F
02/25 06:33, 9F
→
02/25 06:34, , 10F
02/25 06:34, 10F
→
02/25 06:35, , 11F
02/25 06:35, 11F
java 近期熱門文章
PTT數位生活區 即時熱門文章