- 8月 04 週一 201414:39
ASP.NET 使用 ajax 傳遞 Json 物件
- 7月 27 週日 201417:41
JQuery plugin 樣板 深入與淺出
一個強大、功能完善的plugin 應該具備下列幾項要點
1. 可以靠傳入的參數來改變plugin 的形式,做客製化的調整
2. 提供plugin 相關的method,來對plugin 做操作
- 7月 25 週五 201414:49
JSP與ASP 語法差異
之前都是接觸JSP,因此這篇文章主要是以JSP作為出發點來寫的
下列是依些功能上的比較
表格參數傳遞
JSP
request.getParameter("key")
- 6月 30 週日 201315:13
JME3 圖形介面 nifty 筆記

1. 使用nifty
要使用nifty的話,就在程式碼中加入下列這一段
NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager, inputManager, audioRenderer,guiViewPort);
Nifty nifty = niftyDisplay.getNifty();
nifty.fromXml("nifty.xml", "start", this);
guiViewPort.addProcessor(niftyDisplay);
- 9月 22 週六 201219:19
GLUT開發-3D遊戲設計課程
GLUT官方下載點 http://www.opengl.org/resources/libraries/glut/glutdlls37beta.zip
GLUT第四版API http://www.opengl.org/sdk/docs/man4/
- 7月 18 週三 201217:41
SCJP 6.0考古題解析 (146~150)
第146題:
Given:
1. import java.io.*;
2. public class Foo implements Serializable{
3. public int x, y;
4. public Foo(int x, int y){this.x = x; this.y = y;}
5.
6. private void writeObject(ObjectOutputStream s)
7. throws IOException{
8. s.writeInt(x); s.writeInt(y);
9. }
10.
11. private void readObject(ObjectInputStream s)
12. throws IOException, ClassNotFoundException{
13.
14. //insert code here
15.
16. }
17. }
Which code, inserted at line 14, will allow this class to correctly serialize and deserialize?
A. s.defaultReadObject();
B. this = s.defaultReadObject(),
C. y = s.readInt(); x = s.readInt();
D. x = s.readInt(); y = s.readInt();
答案:D
題目範圍:串流
解析:
因為讀出串流時,順序是x 然後y,因此寫入時應該也要一樣先x 然後y
defaultReadObject 是搭配defaultWriteObject 使用的
- 7月 09 週一 201223:42
SCJP 6.0考古題解析 (141~145)
第141題:
Given:
11. class A{
12. public void process(){System.out.print("A, ");}
13. class B extends A{
14. public void process() throws IOException{
15. super.process();
16. System.out.print("B, ");
17. throw new IOException();
18. }
19. public static void main(String[] args){
20. try{new B().process();}
21. catch(IOException e){System.out.println("Exception");}
22. }
What is the result?
A. Exception
B. A, B, Exception
C. Compilation fails because of an error in line 20.
D. Compilation fails because of an error in line 14.
E. A NullPointerException is thrown at runtime.
答案:D
題目範圍:例外處理
解析:
B類別在覆寫A類別的process()方法時,由於A.process()類別並沒有擲出IOException,因此B.process()也不可擲出IOException
如果A.process()有擲出Exception,則B.process()可以擲出IOException(因為是Exception的子類別),但裡面的super.process();必須再做例外處理
- 7月 07 週六 201212:22
SCJP 6.0考古題解析 (136~140)
第136題:
Given:
11. public static void main(String[] args){
12. try{
13. args = null;
14. args[0] = "test";
15. System.out.println(args[0]);
16. }catch(Exception ex) {
17. System.out.println("Exception");
18. }catch(NullPointerException npe){
19. System.out.println("NullPointerException");
20. }
21. }
What is the result?
A. test
B. Exception
C. Compilation fails.
D. NullPointerException
答案:C
題目範圍:例外處理
解析:
因為NullPointerException永遠不會被捕捉到
編譯階段會出現錯誤,原因是這個例外已經在先前被Exception捕捉了
- 7月 07 週六 201201:40
SCJP 6.0考古題解析 (131~135)
第131題:
Given:
static void test() throws Error {
if (true)
throw new AssertionError();
System.out.print("test ");
}
public static void main(String[] args) {
try {
test();
} catch (Exception ex) {
System.out.print("exception ");
}
System.out.print("end ");
}
What is the result?
A. end
B. Compilation fails.
C. exception end
D. exception test end
E. A Throwable is thrown by main.
F. An Exception is thrown by main.
答案:E
題目範圍:例外處理
解析:
Error和Exception都是Throwable的類別
但兩者並沒有繼承關係
在丟出Error的時候,無法被catch (Exception ex)所接到,因此最後會被main方法丟出
Error沒有強制規定必須被catch,因此並不會出現Compilation fails
- 2月 18 週六 201223:20
SCJP 6.0考古題解析 (126~130)
第126題:
Given:
31. //some code here
32. try{
33. //some code here
34. }catch(Some Exception se) {
35. //some code here
36. }finally{
37. //some code here
38. }
Under which three circumstances will the code on line 37 be executed? (Choose three.)
A. The instance gets garbage collected.
B. The code on line 33 throws an exception.
C. The code on line 35 throws an exception.
D. The code on line 31 throws an exception.
E. The code on line 33 executes successfully
答案:BCE
題目範圍:例外處理
解析:
只要進入了try/catch 裡面,不論如何都會在最後執行finally的內容
