2007年3月12日 星期一

java 作業 (二)

Java Homework Problems 2007/3/5

1. Explain bytecode, JVMAns : byte-code : The programs are first translated into an small ,easy-to-write and inexpensive language .This is a intermediate language .Program translated this intermediate language into the machine language for a particular appliance or computer .This intermediate language is call Java byte-code or byte-code.


Java
↓ compile
Byte-code
↓ interpreter
Microprocessor


JVM : A Java virtual machine or JVM is a virtual machine that runs Java byte code. This code is most often generated by Java language compilers, although the JVM has also been targeted by compilers of other languages.


2. Explain class, objectAns:

A Java program is divided into smaller parts called classes. Class is placed in a file of the same name, except that the ending is changed from java to class. Object-oriented programming has its own specialized terminology. The objects are called, appropriately enough, objects. The actions that an object 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(類別) → 1.Methods:(actions動作) 2.Property:(屬性 )

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




沒有留言: