2008年3月6日 星期四

Homework 3-3-2008



1. Explain bytecode, JVM
bytecode:是一種中間語言,可以稱為Java byte-code 或是簡稱為 byte-code,當初之所以要發展的原因是為了讓這語言能在不同的機械中運作,而它具有許多的特性:很小, 很容易上手, 而且並不貴等因素,而他負責編譯機械語言,讓使用者變於撰寫

JVM:JVM是一個虛構出來的電腦,並且屏蔽了原有的處理系統的指令,讓JAVA可以有自己的CPU等相關指令,使JAVA可以在任何平台都可以修改
2. Explain class, object

class: A Java program is divided into smaller parts called classes, and normally each class definition is in a separate file and is compiled separately.




object: To make sure it is clear which program we mean, we call the input program, which in our case will be a Java program, the source program, or source code, and call the translated low-level-language program that the compiler produces the object program, or object code.




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;











public class I


{

public static void main(String[] args)



{
int i;/*虛告一個i的函數*/
i = 2;
System.out.println(i);/*輸出i值*/
System.out.println(2*(i++));/*輸出2乘與i++後的值*/
System.out.println(i);

}


}



4.2 Write a Java program as follows:



Let i=2;



Print i;



Print 2 * (++i);



Print i;




package homework;



public class I


{


public static void main(String[] args)


{


int i;/*虛告一個i的函數*/


i = 2;


System.out.println(i);/*輸出i值*/


System.out.println(2*(++i));/*輸出2乘與++i後的值*/


System.out.println(i);


}


}


4.3 Write a Java program as follows:


Let m=7, n=2;


Print (double) m/n;


Print m/ (double)n;


public class I


{


public static void main(String[] args)


{


int m,n;/*虛告m和n的函數*/


m = 7; n = 2;


System.out.println((double)m/n);


System.out.println(m/(double)n);


}


}

沒有留言: