您的位置:寻梦网首页编程乐园Java天地Core JavaJava Lecture Notes

previous.gif
 (3087 bytes)

next.gif
 (2959 bytes)


Apply Index

Apply Page # 4

Exercise 2 Event handling in TextField example

Answer each of the following questions, giving a full explanation to justify your answer.

1. What method has to be implemented in the TempConversion applet for the ActionListener interface ?

2. Which of the variables in the example are objects (reference types)?

3. Which of the variables are not objects (scalar/simple/built in types)?

4. List the statements which are messages to the text field objects?

5. What is the purpose of the method Integer.parseInt(String s) on line 26?

6. 燱hat is the purpose of the method used on line 28? Integer.toString(int i)?

7. Explain how the convert(int x) method works i.e. where it is declared, where invoked etc. giving the line numbers

8. Would the applet work if the two labels: CentigradeLabel, FarehneitLabel were not used at all?

9. What would the display look like if the size of the window was 600 x 500?

10. What would happen if the input was not integer e.g if the user enters 25.5?


Discussion of Exercise 2 

Back to content

Back to top

basicline.gif (170 bytes)