2008年9月26日 星期五

homework1

1. Explain bytecode, JVM
The Java compiler translates your Java 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 instruction.

Byte-code is the machine language for a fictitious computer called the Java Virtual Machine(JVM)


2. Explain class, object

Object-oriented programming has its own specialized terminology. The objects are called, appropriately enough, objects. The actions that an objects can take are called methods.Objects of the same kind are said to have the same type or, more often, are said to be in the same class.
class is a type and object is the some method in class.

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
















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

沒有留言: