Monday, March 26, 2007

Java Class Work 2007/3/26

Display3.1


Java Test I 2007/3/26

1. Revise your program for Simple Java Expressionaccording to Java program styles. Check the following(1) the naming of constants, if any,(2) Java spelling conventions, and(3) indenting.
2. Insert proper comments in your program for Simple Java Expression. Note that there are 2 ways to insert comments: line comments and block comments.

ANS:

3. The identifier BufferedReader is normally abbreviated as BR in programming language C. However, Java programmers normally do not use abbreviations in identifiers. Can you give some good reasons for using long names in Java?

ANS:

主要是由於Java與 C語言的讀取方式不一樣,Java使用 BufferedReader(Reader in),預設一次從Reader in 先讀8192個字元在記憶體,但可以自定一次讀入的字元BufferedReader(Reader in, int size),而與C的讀取方式不同。



4.The Java Virtual Machine handles string objects in a way different from the one it handles variables of primitive types such as int, long, float, and double. What is the difference?

ANS:

int(整數):integer ; 4-bytes

long(長整數):interger ; 8-bytes

float(小數):floating-point number ; 4-bytes

double(實數-兩倍準確):floating-point number ; 8-bytes

Sunday, March 25, 2007

Java Homework Problems 2007/3/19

ch2-project 1


ch2-project 3



ch2-project 8





Monday, March 19, 2007

Java Class Work 2007/3/19 -2


Java Class Work 2007/3/19


Sunday, March 18, 2007

Java Homework Problems 2007/3/12

Display1.7

Project 5 on ch1




Monday, March 12, 2007

Java Class Work 2007/3/12


Saturday, March 10, 2007

Java Homework Problems 2007/3/5

1. Explain bytecode, JVM

Ans : 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, object

Ans: 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

Monday, March 05, 2007

Java Class Work 2007/3/5