Answer the following in a 1/4 sheet of paper.
1. The ________ method is invoked once when an applet begins execution.
2. The ________ method is used to produce random numbers.
3. The ________ method is invoked each time the user of a browser revisits the HTML page on which an applet resides.
4. A method that calls itself either directly or indirectly is a ________ method.
5. A recursive method typically has two components: one that provides a means for the recursion to terminate by testing for a ________ case and one that expresses the problem as a recursive call for a slightly simpler problem than the original call.
6. In Java, it is possible to have various methods with the same name that each operate on different types and/or numbers of arguments. This is called method ________ .
7. The ________ qualifier is used to declare read-only variables.
8. A method is invoked with a ________ .
9. A variable known only within the method in which it is defined is called a ________ .
10. The ________ statement in a called method can be used to pass the value of an expression back to the calling method.
11. The keyword ________ is used in a method header to indicate that a method does not return a value.
12. The ________ of an identifier is the portion of the program in which the identifier can be used.
13. The three ways to return control from a called method to a caller are ________ , ________ and ________ .
14. The ________ method is invoked to draw on an applet.
15. The ________ method invokes the applet’s update method, which in turn invokes the applet’s paint method.
16. The ________ method is invoked for an applet each time the user of a browser leaves an HTML page on which the applet resides.
17. Program modules in Java are called ________ and ________.
18. Variables declared in a block or in a method’s parameter list are of ________ duration.
II. Programming
Write a complete Java to prompt the user for the double radius of a sphere and call method sphereVolume to calculate and display the volume of that sphere using the assignment
volume = ( 4.0 / 3.0 ) * Math.PI * Math.pow( radius, 3 )
The user should input the radius through a JOptionPane.showInputDialog. A string can be converted to a double value as follows
// Create a Double object using the text field value.
Double val = Double.parseDouble();
0 Comments