Monday, March 26, 2007

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

1 Comments:

Blogger Yao Jen said...

grading
1. 12
2. 18
3. 5
4. 0

total=35

10:37 PM

 

Post a Comment

<< Home