- Aug 04 Mon 2014 14:39
-
ASP.NET 使用 ajax 傳遞 Json 物件
- Jul 27 Sun 2014 17:41
-
JQuery plugin 樣板 深入與淺出
一個強大、功能完善的plugin 應該具備下列幾項要點
1. 可以靠傳入的參數來改變plugin 的形式,做客製化的調整
2. 提供plugin 相關的method,來對plugin 做操作
- Jul 25 Fri 2014 14:49
-
JSP與ASP 語法差異
之前都是接觸JSP,因此這篇文章主要是以JSP作為出發點來寫的
下列是依些功能上的比較
表格參數傳遞
JSP
request.getParameter("key")
- Jun 30 Sun 2013 15: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);
- Sep 22 Sat 2012 19:19
-
GLUT開發-3D遊戲設計課程
GLUT官方下載點 https://www.opengl.org/resources/libraries/glut/glutdlls37beta.zip
GLUT第四版API https://www.opengl.org/sdk/docs/man4/
- Jul 18 Wed 2012 17: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 使用的
- Jul 09 Mon 2012 23: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();必須再做例外處理
- Jul 07 Sat 2012 12: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捕捉了
- Jul 07 Sat 2012 01: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
- Feb 18 Sat 2012 23: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的內容
- Feb 18 Sat 2012 15:00
-
SCJP 6.0考古題解析 (121~125)
第121題:
Given:
11. public class Test{
12. public enum Dogs {collie, harrier, shepherd},
13. public static void main(String[] args){
14. Dogs myDog = Dogs.shepherd;
15. switch(myDog){
16. case collie:
17. System.out.print("collie ");
18. case default:
19. System.out.print("retriever "),
20. case harrier:
21. System.out.print("harrier ");
22. }
23. }
24. }
What is the result?
A. harrier
B. shepherd
C. retriever
D. Compilation fails
E. retriever harrier
F. An exception is thrown at runtime,
答案:D
題目範圍:基本觀念,switch
解析:
這題藏了三個錯誤,分別是:
Enum那行最後的逗號應該被刪掉
System.out.print("retriever "), 的逗號
還有case default: 應該改為default:
- Feb 05 Sun 2012 23:44
-
SCJP 6.0考古題解析 (116~120)
第116題:
Given:
11. public class Commander{
12. public static void main(String[] args){
13. String myProp = /* insert code here */
14. System.out.println(myProp);
15. }
16. }
and the command line:
java -Dprop.custom=gobstopper Commander
Which two, placed on line 13, will produce the output gobstopper? (Choose two.)
A. System.load("prop.custom");
B. System.getenv("prop.custom");
C. System.property("prop.custom);
D. System.getProperty("prop.custom");
E. System.getProperties().getProperty("prop.custom");
答案:DE
題目範圍:System下的方法
解析:
System.load方法可以傳入一個檔案位址,讓程式將指定檔案的內容加入函式庫中
System.getenv方法會回傳對應輸入的環境變數,例如你可以輸入"JAVA_HOME"
System.property,沒有這個方法
System.getProperty會回傳在執行檔案時所定義的屬性
System.getProperties會回傳一個hashtable裡面包含很多系統資訊,詳細請上網搜尋