1. 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.
2. 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.
3. 列舉至少三個Java記憶體管理的特性
4. 列舉至少三個Java程式的風格
5. Let i, j be two integers. Write a Java program to exchange their values. Please make sure you have good styles of making comments, naming variables, and indenting.
6. Write a complete Java program that uses a for loop to compute the sum of the odd numbers between 1 and 25.
7. 列舉至少三個 API (Application Programming Interface).
8. 列舉 ADT (Abstract Data Type) 的特性.
9. Write a Java program to calculate the cosine function as follows:
Cos(x)=1 - x 2 /2!+ x 4/4!- x 6/6!...
10. Write a Java program to calculate the sin function as follows:
sin(x)=x - x 3/3! + x5/5! - x7/7! ...
11. 請解釋 public static final PI = 3.141592654 中, public, static, final 的意義。
12. 為什麼 static method 不能呼叫 nonstatic method?詳細說明之。
13. 舉三個例子 Object
14. 舉三個例子 Method
星期日, 6月 07, 2009
星期一, 5月 18, 2009
Quiz 5-18-2009
1. Design a non-static method that can compute the addition of complexes. You must first define Complex class then write a demo program to verify the class program.
2. Design a static method that can compute the multiplication of fractions. You must first define Fraction class then write a demo program to verify the class program.
3. 列舉至少三個Java程式風格
4. 列舉至少三個Java記憶體管理特性
5. 6. Design a method that can compute the vector inner product. You must define Vector class in the first place. Write a demo program to verify your program works.
7. Give three examples of ADT (Abstract Data Type).
8. Give three examples of API (Application Programming Interface).
9. 10. Define a class called Counter whose objects count things. An object of this class records a count that is a nonnegative integer. Include methods to set the counter to 0, to increase the count by 1, and to decrease the count by 1. Include an accessor method that returns the current count value and a method that outputs the count to the screen.
11. 為什麼static method 不能呼叫 nonstatic method?詳細說明之。
12. 請解釋 public static final PI = 3.141592654 中, public, static, final 的意義。
13. 舉三個例子說明 Overloading
14. 舉三個例子說明 Constructor
2. Design a static method that can compute the multiplication of fractions. You must first define Fraction class then write a demo program to verify the class program.
3. 列舉至少三個Java程式風格
4. 列舉至少三個Java記憶體管理特性
5. 6. Design a method that can compute the vector inner product. You must define Vector class in the first place. Write a demo program to verify your program works.
7. Give three examples of ADT (Abstract Data Type).
8. Give three examples of API (Application Programming Interface).
9. 10. Define a class called Counter whose objects count things. An object of this class records a count that is a nonnegative integer. Include methods to set the counter to 0, to increase the count by 1, and to decrease the count by 1. Include an accessor method that returns the current count value and a method that outputs the count to the screen.
11. 為什麼static method 不能呼叫 nonstatic method?詳細說明之。
12. 請解釋 public static final PI = 3.141592654 中, public, static, final 的意義。
13. 舉三個例子說明 Overloading
14. 舉三個例子說明 Constructor
星期四, 12月 25, 2008
Quiz 12-26-2008
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
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
星期五, 10月 31, 2008
Quiz 10-31-2008
1. Write a Java program to calculate the trianular function as follows:
Cos(x)=1 - 2!/x 2 + 4!/x 4- 6!/x 6...
2. Write a Java program to calculate the sin function as follows:
sin(x)=x - 3!/x 3 + 5!/x5 - 7!/x7 ...
3. Write a Java program that can determine the minimum of any 4 numbers.
4. Write a Java program that can determine the maximum of any 4 numbers.
5. Let i, j be two integers. Write a Java program to exchange their values. Please make sure you have good styles of making comments, naming variables, and indenting.
6. Write a complete Java program that uses a for loop to compute the sum of the odd numbers between 1 and 25.
7. Explain syntax errors and sematic errors.
8. Explain programming styles and naming conventions in Java.
9. What is Java Virtual Machine and Java Bytecode?
10. Explain Java's feature "Write once, run anywhere."
Cos(x)=1 - 2!/x 2 + 4!/x 4- 6!/x 6...
2. Write a Java program to calculate the sin function as follows:
sin(x)=x - 3!/x 3 + 5!/x5 - 7!/x7 ...
3. Write a Java program that can determine the minimum of any 4 numbers.
4. Write a Java program that can determine the maximum of any 4 numbers.
5. Let i, j be two integers. Write a Java program to exchange their values. Please make sure you have good styles of making comments, naming variables, and indenting.
6. Write a complete Java program that uses a for loop to compute the sum of the odd numbers between 1 and 25.
7. Explain syntax errors and sematic errors.
8. Explain programming styles and naming conventions in Java.
9. What is Java Virtual Machine and Java Bytecode?
10. Explain Java's feature "Write once, run anywhere."
星期一, 6月 16, 2008
Quiz 4
1. Write a Java program to calculate the trianular function as follows:
Cos(x)=1 - 2!/x 2 + 4!/x4 - 6!/x6 ...
2. Write a Java program to calculate the sin function as follows:
sin(x)=x - 3!/x 3 + 5!/x5 - 7!/x7 ...
3. Design a non-static method that can compute the product of complex numbers. You must first define Complex class then write a demo program to verify the class program.
4. Design a static method that can compute the product of complex numbers. You must first define Complex class then write a demo program to verify the class program.
5. Let i, j be two integers. Write a Java program to exchange their values. Please make sure you have good styles of making comments, naming variables, and indenting.
6. Write a complete Java program that uses a for loop to compute the sum of the even numbers between 1 and 25.
7. Explain API and ADT.
8. Explain programming styles and naming conventions
Cos(x)=1 - 2!/x 2 + 4!/x4 - 6!/x6 ...
2. Write a Java program to calculate the sin function as follows:
sin(x)=x - 3!/x 3 + 5!/x5 - 7!/x7 ...
3. Design a non-static method that can compute the product of complex numbers. You must first define Complex class then write a demo program to verify the class program.
4. Design a static method that can compute the product of complex numbers. You must first define Complex class then write a demo program to verify the class program.
5. Let i, j be two integers. Write a Java program to exchange their values. Please make sure you have good styles of making comments, naming variables, and indenting.
6. Write a complete Java program that uses a for loop to compute the sum of the even numbers between 1 and 25.
7. Explain API and ADT.
8. Explain programming styles and naming conventions
星期一, 6月 02, 2008
Quiz 6-2
1. Define a class called Counter whose objects count things. An object of this class records a count that is a nonnegative integer. Include methods to set the counter to 0, to increase the count by 1, and to decrease the count by 1.
2. Define a Complex class with complex addition.
3. What is Abstract Data Type (ADT)?
4. What is "Overloading"? Why is it useful?
5. Write a program to implement a method that can do additions of 2 fractions. You will implement a class called Fraction consisting of a numerator and a denominator.
6. Design a method that can compute the vector inner product. You must define Vector class in the first place. Write a demo program to verify your program works.
2. Define a Complex class with complex addition.
3. What is Abstract Data Type (ADT)?
4. What is "Overloading"? Why is it useful?
5. Write a program to implement a method that can do additions of 2 fractions. You will implement a class called Fraction consisting of a numerator and a denominator.
6. Design a method that can compute the vector inner product. You must define Vector class in the first place. Write a demo program to verify your program works.
星期一, 4月 14, 2008
Partial Answer to Quiz 2
Partial solutions: The following solutions are not complete Java programs. They are kept brief to illustrate the main ideas of the complete programs.
Problem 1:
1. Write a Java program to calculate the trianular function as follows:
Cos(x)=1 - 2!/x 2 + 4!/x4 - 6!/x6 ...
double power=1, fact=1, sum=0;
int k=-1;
for(int i=1; i<10; i++)
{
power=power*x;
fact=fact*i;
if(i%2==1)
{ k=k*(-1);
sum+=k*power/fact;
}
}
Write a complete Java program that uses a for loop to compute the sum of the even numbers and the sum of the odd numbers between 1 and 50.
int evenSum=oddSum=0;
for(i=1; i<=50; i++)
{
if(i%2==0)
evenSum=evenSum+i;
else
oddSum+=i;
}
Problem 1:
1. Write a Java program to calculate the trianular function as follows:
Cos(x)=1 - 2!/x 2 + 4!/x4 - 6!/x6 ...
double power=1, fact=1, sum=0;
int k=-1;
for(int i=1; i<10; i++)
{
power=power*x;
fact=fact*i;
if(i%2==1)
{ k=k*(-1);
sum+=k*power/fact;
}
}
Write a complete Java program that uses a for loop to compute the sum of the even numbers and the sum of the odd numbers between 1 and 50.
int evenSum=oddSum=0;
for(i=1; i<=50; i++)
{
if(i%2==0)
evenSum=evenSum+i;
else
oddSum+=i;
}
Quiz 4-14-2008
There are 3 problem each with its own marks. Total above 75 marks is considered as PASS.
1. (50) Write a Java program to calculate the trianular function as follows:
Cos(x)=1 - 2!/x 2 + 4!/x4 - 6!/x6 ...
2. (30)
Write a complete Java program that uses a for loop to compute the sum of the even numbers and the sum of the odd numbers between 1 and 50.
3. (20) Rewrite the following for loop using a while expression.
int Sum=0;
for(i=0; i<=10; i++)
Sum=Sum+i;
星期一, 3月 24, 2008
Quiz 3-24-2008
1. Let i, j be two integers. Write a Java program to exchange their values. Please make sure you have good styles of making comments, naming variables, and indenting.
2. The identifier StreamReader is normally abbreviated as SR in programming language C. However, Java programmers normally do not use abbreviations for identifiers. What are the advantages and disadvantages of not using abbreviations?
3. a. What is "self-documenting"?
b. What is the purpose of "Unicode"? Does Java use it?
4. Give an example of "logic error"
2. The identifier StreamReader is normally abbreviated as SR in programming language C. However, Java programmers normally do not use abbreviations for identifiers. What are the advantages and disadvantages of not using abbreviations?
3. a. What is "self-documenting"?
b. What is the purpose of "Unicode"? Does Java use it?
4. Give an example of "logic error"
星期六, 12月 08, 2007
Quiz on Chap. 4
1. Explain API and ADT.
2. How are the object variables managed by Java compilers? Are they managed in the same way as variables of primitive types?
3. In the following statement,
Date myDate= new Date();
What is the use of "new"?
4. Design a method that can compute the vector inner product. You must define Vector class in the first place. Write a demo program to verify your program works.
5. Define a class called Counter whose objects count things. An object of this class records a count that is a nonnegative integer. Include methods to set the counter to 0, to increase the count by 1, and to decrease the count by 1. Include an accessor method that returns the current count value and a method that outputs the count to the screen. Write a program to test
2. How are the object variables managed by Java compilers? Are they managed in the same way as variables of primitive types?
3. In the following statement,
Date myDate= new Date();
What is the use of "new"?
4. Design a method that can compute the vector inner product. You must define Vector class in the first place. Write a demo program to verify your program works.
5. Define a class called Counter whose objects count things. An object of this class records a count that is a nonnegative integer. Include methods to set the counter to 0, to increase the count by 1, and to decrease the count by 1. Include an accessor method that returns the current count value and a method that outputs the count to the screen. Write a program to test
星期五, 11月 09, 2007
Partial Solutions to Quiz II
Partial solutions: The following solutions are not complete Java programs. They are kept brief to illustrate the main ideas of the complete programs.
Problem 1:
double power=1, fact=1, sum=0;
int k=-1;
for(int i=1; i<10; i++)
{
power=power*x;
fact=fact*i;
if(i%2==1)
{ k=k*(-1);
sum+=k*power/fact;
}
}
Problem 2:
int evenSum=oddSum=0;
for(i=1; i<=25; i++)
{
if(i%2==0)
evenSum=evenSum+i;
else
oddSum+=i;
}
Problem 1:
double power=1, fact=1, sum=0;
int k=-1;
for(int i=1; i<10; i++)
{
power=power*x;
fact=fact*i;
if(i%2==1)
{ k=k*(-1);
sum+=k*power/fact;
}
}
Problem 2:
int evenSum=oddSum=0;
for(i=1; i<=25; i++)
{
if(i%2==0)
evenSum=evenSum+i;
else
oddSum+=i;
}
Quiz 11/9/2007
There are 3 problem each with its own marks. Total above 75 marks is considered as PASS.
1. (50) Write a Java program to calculate the sin function as follows:
sin(x)=x - 3!/x 3 + 5!/x5 - 7!/x7 ...
2. (30)
M 82
M 65
F 88
M 63
F 75
F 90
F 90
M 70
You should be able to allow users to type in a whole line such as F 80 followed by next line M 70.
1. (50) Write a Java program to calculate the sin function as follows:
sin(x)=x - 3!/x 3 + 5!/x5 - 7!/x7 ...
2. (30)
Write a complete Java program that uses a for loop to compute the sum of the even numbers and the sum of the odd numbers between 1 and 25.
3. (70) Write a program to calculate average science scores by gender based on the following data, where F stands for female and M for male.M 82
M 65
F 88
M 63
F 75
F 90
F 90
M 70
You should be able to allow users to type in a whole line such as F 80 followed by next line M 70.
星期五, 10月 12, 2007
Quiz 10-12-2007
1. Let i, j be two integers. Write a program to exchange their values. How can you show your program is correct.
2. The identifier BufferedReader is normally abbreviated as BR in programming language C. However, Java programmers normally do not use abbreviations for identifiers. What are the advantages and disadvantages of not using abbreviations?
2. The identifier BufferedReader is normally abbreviated as BR in programming language C. However, Java programmers normally do not use abbreviations for identifiers. What are the advantages and disadvantages of not using abbreviations?
星期一, 6月 04, 2007
Quiz 6-4-2007 II
Design a non-static method that can compute the product of complex numbers. You must first define Complex class then write a demo program to verify the class program.
Quiz 6-4-2007
Design a static method that can compute the vector inner product. You must first define Vector class in the first place. Write a demo program to verify your program works.
星期一, 3月 26, 2007
Quiz 3-26-2007
1. Revise your program for Simple Java Expression
according 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.
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?
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?
according 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.
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?
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?
星期一, 10月 31, 2005
10-31 Quiz Fibonacci
Name 3 objects that demonstrate Fibonacci numbers and
illustrate the objects with figures.
illustrate the objects with figures.
訂閱:
文章 (Atom)
