12. What is the difference between “error” and “exception”? (5 Points)
13. Read the following lines of code and answer the question below: (7 Points)
import java.awt.*;
import java.applet.*;
public class Test51` extends Applet
{
float[ ] x = {1.2, 3.4, 5.6, 7.8};
public void paint(Graphics g)
{
int s=0;
for( int i = 0; i < x.length; i++ )
s += (int)x[i];
g.drawString(" " + s, 30, 60);
}
}
1) What is the result after running the code?
2) Could we change the code “s += (int)x[i];” in the paint() method to “s +=x[i];”? Why?
14. If you develop a game with J2ME, how to handle voice call when the user playing game? (7 Points)
15. How to set Icon for your J2ME application instead of the default icon? (6 Points)
Part IV: Programming (30 Points)
16. How to play MIDI file and set the volume to 50? Please write the code. (10 Points)
17. How to read the data from txt file?Please write the code. (10 Points)
18. Write a simple chat program which can send message to server and receive info from server. (Only for the person who has 3 years experience.) (10 Points)