2008年9月25日 星期四

H.W01

Homework 9-19-2008

1. Explain bytecode, JVM
a. bytecode
The java compiler translates your program into a language called byte-code,which is the machine language for a fictitious computer.It is easy to translate this byte-code into the machine language of any particular computer.Each type of computer will have its own interpreter that translates and executes byte-code instructions.
b. JVM(Java Virtual Machine)
Byte-code is the machine language for a fictitious computer called the Java Virtual Machine.

ByteCode 是給予 JVM 執行的一種虛擬機器碼,也就是給於 JVM 的指令‧
反過來說,JVM 就是 ByteCode 的解譯程式

2. Explain class, object
class類別 object物件
A java program works by having things called objects perform actions. The actions are known as methods and typically involve data contained in the objects. All objects of the same kind are said to be of the same class .
A class is a category of objects.

類別是一種物件導向計算機程式語言的構造,是創建物件的藍圖,描述了所創建的物件共同的屬性和方法。
在軟體系統中,物件具有唯一的標識符,物件包括屬性和方法,屬性就是需要記憶的信息,方法就是物件能夠提供的服務。在物件導向的軟體中,物件是某一個類的實例。

3. Reading Assignments:Read 1.1, 1.2, 1.3 of Textbook

4.1 Write a Java program as follows:
Let i=2;
Print i;
Print 2 * (i++);
Print i;
Ans: 2, 4, 3















4.2 Write a Java program as follows:
Let i=2;
Print i;
Print 2 * (++i);
Print i;
Ans: 2, 6, 3















4.3 Write a Java program as follows:
Let m=7, n=2;
Print (double) m/n;
Print m/ (double)n;
Ans: 3.5, 3.5


沒有留言: