第一章
簡述JAVA發展歷史。
BCPL(1967)→B(Bell Laboratories, UNIX, 1970)→C(1972)→C++(1980s)→JAVA
Java Class Libraries
一部份的java programs consist叫做classes(類別),類別中含執行特定功能的methods(方法),方法有時在執行結束時會傳回特定結果。
大部份java程式設計師都會利用java class libraries中的classes來撰寫程式,而java class libraries又被稱為Java APIs (Application Programming Interfaces)。
Java程式設計五步驟(Fig. 1.1)
edit (.java), compile (.class), load (load .class, puts in primary memory), verify (valid and do not violate security), execute (the JVM reads Primary Memory)
復習(課本上原有解答)
直接看課本:p.34~p.35
練習(自己寫的答案,並非正確解答)
1.4 Categorize each of the following items as either hardware or software:
hardware: CPU, input unit.
software: Java compiler, JVM (Java Virtual Machine), editor.
1.5 What is the difference between fatal errors and nonfatal errors? Why might you prefer to experience a fatal error rather than a nonfatal error?
fatal errors: 致命性錯誤,會導致程序立即終止。
nonfatal errors: 非致命性錯誤,會導致結果與預期不符,程序不會立即終止。
原因:致命性錯誤常在較明顯的地方,容易修改,而非致命性錯誤雖然只有結果不符,但產生錯誤的地方很難找出來。
1.6 Fill in the blanks in each of the following statements (based on Section 1.13):
a) Java programs normally go through five phases-edit, compile, load, verify and execute.
b) A(n) integrated development environment (IDE) provides many tools that support the software development process, such as editors for writing and editing programs, debuggers for locating logic errors in programs, and many other features.
c) The command java invokes the Java Virtual Machine(JVM),which executes Java programs.
d) A(n) virtual machine (VM) is a software application that simulates a computer, but hides the underlying operating system and hardware from the programs that interact with the VM.
e) A(n) portable program can run on multiple platforms.
f) The class loader takes the .class files containing the program's bytecodes and transfers them to primary memory.
g) The bytecode verifier examines bytecodes to ensure that they are valid.
1.7 Explain the two compilation phases of Java programs.
早期的java版本中,JVM是簡單的java編譯程式,但因為每執行一次程式就需要重新編譯,導致執行進度過慢。而現在的JVM則是用JIT(Just-In-Time)來編譯。JIT是將程式碼中較頻繁執行的bytecode弄成Hot Spot,再將HotSpot轉換原機器語言。如此一來,下次想再執行程式時,編譯部份就會以相應的機器語言去執行,使編譯的時間縮短。
2013/7/3 23:48 第一次編輯
2013/7/4 16:14 完成
沒有留言:
張貼留言