1. Design a non-static method that can compute the addition of fractions. You must first define Fraction class then write a demo program to verify the class program.
2. Design a static method that can compute the addition of fractions. You must first define Fraction class then write a demo program to verify the class program.
3. 列舉至少三個Java程式的風格
4. 列舉至少三個Java記憶體管理的特性
5. Write a Java program to solve the Hanoi Tower Problem.
6. Write a Java program to solve the Hanoi Tower Problem.
7. Explain ADT (Abstract Data Type).
8. Explain API (Application Programming Interface).
9. Write a Java program to calculate the sin function as follows:
sin(x)=x - x 3/3! + x5/5! - x7/7! ...
10. Write a Java program to calculate the cosine function as follows:
Cos(x)=1 - x 2 /2!+ x 4/4!- x 6/6!...
11. 一個Java 物件使用多少個Byte記憶體? 為什麼?
12. 請解釋 Garbage Collector 的作用。試舉例說明。
13. 請解釋 Overloading ,舉例說明何時可能會用到 Overloading
14. 請解釋 Constructor ,舉例說明何時可能會用到 Constructor
星期四, 12月 25, 2008
星期五, 12月 19, 2008
Lab Hanoi Tower
The pseudocode for Hanoi Tower is as follows:
solve(N, Src, Aux, Dst)
if N is 0 return
solve(N-1, Src, Dst, Aux)
Move N from Src to Dst
solve(N-1, Aux, Src, Dst)
Write the Java program based on the pseudocode in the above.
solve(N, Src, Aux, Dst)
if N is 0 return
solve(N-1, Src, Dst, Aux)
Move N from Src to Dst
solve(N-1, Aux, Src, Dst)
Write the Java program based on the pseudocode in the above.
Lab Factorial
Write a Java program that computes N! where N is a positive integer.
Hint:
public static long factorial(int n)
Hint:
public static long factorial(int n)
Lab Recursive Method
Write a recursive method to compute Fibonacci series.
Hint:
1.
fib(n)=fib(n-1)+fib(n-2)
2.
public static long fib(int n)
Hint:
1.
fib(n)=fib(n-1)+fib(n-2)
2.
public static long fib(int n)
星期四, 12月 18, 2008
星期五, 12月 12, 2008
Lab Static Method
Define a Complex class with a static method for computing complex addition. Use (2+3i)+(4+5i) in your test.
Lab Java Constructor
Use Display 4.14 to call 4.13 (2nd ed.) or
Display 4.12 to call 4.11 (1st ed.).
After you finish the above, try the following
Date birthday = new Date("Jan",1,2000);
birthday.Date("Feb",1,2000);
birthday.setDate("Feb",1,2000);
birthday=new Date("Mar",1,2000);
Display 4.12 to call 4.11 (1st ed.).
After you finish the above, try the following
Date birthday = new Date("Jan",1,2000);
birthday.Date("Feb",1,2000);
birthday.setDate("Feb",1,2000);
birthday=new Date("Mar",1,2000);
訂閱:
文章 (Atom)