Tuesday, October 19, 2010

Questions On Java Applet creation

Q Can arguments be sent to applets, as they can to applications?

You can't use arguments, but parameters serve a similar function to arguments in applet programming. You can use the tag with its NAME and VALUE attributes to send parameters to Java programs. It's described fully in Hour 15, "Sending Parameters to --Applets."

Q Is there a reason why the --CODEBASE attribute should be used in an --"" tag?

A If all Java programs are grouped into their own subdirectory, as indicated by
--CODEBASE, this structure might improve the way a Web site is organized, but there's no other reason why using --CODEBASE is better than omitting it. The choice is a matter of personal preference.

Q What happens if the height and width specified for an applet don't leave enough room for the information that is displayed in the paint() method?

The information will be drawn off-screen beyond the edges of the applet window and won't be visible at any point while the applet runs. Choosing the right dimensions for an applet is largely a matter of trial-and-error until you find the right size for both the
HEIGHT and WIDTH attributes of the tag. Fortunately, you can change the Web page's --HTML without having to recompile the Java program.
The following questions test your knowledge of applets.
1. What type of argument is used with the paint() method?

Graphics object
(b) A Boolean variable
(c) None

2. Which method is handled right before an applet finishes running?


3. Why can't all variables needed in an applet be created inside the
init() method?

The scope of the variables would be limited to the method only.
(b) Federal legislation prohibits it.
(c) They can be created there without any problems.
1. a. The Graphics object keeps track of the behavior and attributes needed to display things on-screen in the applet window.


a. Variables that are used in more than one method of a class should be created right after the class statement but before any methods begin.

No comments:

Post a Comment