Web Hosting Web Hosting, web hosting, JSP, Servlets, Tomcat, website hosting, web site hosting
Web Hosting, web hosting, JSP, Servlets, Tomcat, website hosting, web site hosting
Web Hosting, web hosting, JSP, Servlets, Tomcat, website hosting, web site hosting

Alden Hosting provides professional, efficient, and reliable business-class Web hosting services to small- and medium-sized businesses.

WWW.

Call Us Toll-Free
(877) 256-0328

Outside USA
1 - (201) 505-0430

Web Hosting Welcome Web Hosting Web Hosting Plans Overview , Fund Raising, Fundraising, web hosting, website hosting, web site hosting Web Hosting Fund Raising, Fundraising, web hosting Web Hosting Resellers, web Hosting Web Hosting Web Design, web Hosting Web Hosting Extra Services,  web Hosting Web Hosting Traffic Booster, web hosting Web Hosting Traffic Booster, web hosting Web Hosting Technical Support,  web Hosting Web Hosting webmaster tips,  web Hosting Web Hosting 30 Day Money Back, web hosting Web Hosting Legal Notices for Web Hosting Web Hosting Glossary Computer Terms for web Hosting Web Hosting Contact Information - web hosting

Site Map

  Web Hosting Web Hosting Sign-Up   Web Hosting Fund Raising, Fundraising, web hosting, website hosting, web site hosting    Web Hosting Resellers web hosting, website hosting, web site hosting   Web Hosting EZ Site Control Panel for web hosting,website hosting, web site hosting
Answers to Questions and Exercises: Java Applets (The Java™ Tutorials > Deployment > Applets)
Trail: Deployment
Lesson: Applets
Home Page > Deployment > Applets
Answers to Questions and Exercises: Java Applets

Questions

  1. Question: Which classes can an applet extend?

    Answer: An applet can extend the java.applet.Applet class or the java.swing.JApplet class.

    The java.applet.Applet class extends the java.awt.Panel class and enables you to use the GUI tools in the AWT package.

    The java.swing.JApplet class is a subclass of java.applet.Applet that also enables you to use the Swing GUI tools.

  2. Question: How do you cause the applet GUI in the browser to be refreshed when data in it may have changed?

    Answer: You invoke the repaint() method. This method causes the paint method, which is required in any applet, to be invoked again, updating the display.

  3. Question: For what do you use the start() method?

    Answer: You use the start() method when the applet must perform a task after it is initialized, before receiving user input. The start() method either performs the applet's work or (more likely) starts up one or more threads to perform the work.

  4. Question: True or false: An applet can make network connections to any host on the Internet.

    Answer: False: An applet can only connect to the host that it came from.

  5. Question: How do you get the value of a parameter specified in the APPLET tag from within the applet's code?

    Answer: You use the getParameter("Parameter name") method, which returns the String value of the parameter.

  6. Question: True of false: An applet can run multiple threads.

    Answer: True. The paint and update methods are always called from the AWT drawing and event handling thread. You can have your applet create additional threads, which is recommended for performing time-consuming tasks.

  7. Question: Match the following tag names with the descriptions in the following lists:
    1. EMBED tag
    2. APPLET tag
    3. OBJECT tag

    1. Use to deploy applets to a multi-browser environment.
    2. Use to deploy applets that are to be used only with the Mozilla family of browsers
    3. Use to deploy applets that are to be used only with Internet Explorer

    Answer:

    1. EMBED tag: b
    2. APPLET tag: a
    3. OBJECT tag: c

Exercises

  1. Exercise: For an applet using the Exercise class, write the Applet tag that sets the ButtonName parameter to Save.

    Answer:

    <APPLET CODE=AppletButton.class> 
      <PARAM NAME=ButtonName VALUE=Save>
    </APPLET> 
    
  2. Exercise: Write the method to display an applet in the browser, so that the contents are contained in a rectangle around the phrase "Exercise Applet". Have the applet be one pixel less than the size specified ont he web page, and the phrase starting at the coordinates 5, 15.

    Answer:

    public void paint(Graphics g) {
    	//Draw a Rectangle around the applet's display area.
            g.drawRect(0, 0, 
    		   getWidth() - 1,
    		   getHeight() - 1);
    
    	//Draw the current string inside the rectangle.
            g.drawString("Exercise Applet", 5, 15);
        }
    
Previous page: Questions and Exercises: Java Applets
Web Hosting, web hosting, JSP, Servlets, Tomcat, website hosting, web site hosting
Add to My Yahoo!

XML icon

Add to Google

 

 

 

 

 

 

 

 

 

 

 

http://alden-servlet-Hosting.com
JSP at alden-servlet-Hosting.com
Servlets at alden-servlet-Hosting.com
Servlet at alden-servlet-Hosting.com
Tomcat at alden-servlet-Hosting.com
MySQL at alden-servlet-Hosting.com
Java at alden-servlet-Hosting.com
sFTP at alden-servlet-Hosting.com
http://alden-tomcat-Hosting.com
JSP at alden-tomcat-Hosting.com
Servlets at alden-tomcat-Hosting.com
Servlet at alden-tomcat-Hosting.com
Tomcat at alden-tomcat-Hosting.com
MySQL at alden-tomcat-Hosting.com
Java at alden-tomcat-Hosting.com
sFTP at alden-tomcat-Hosting.com
http://alden-sftp-Hosting.com
JSP at alden-sftp-Hosting.com
Servlets at alden-sftp-Hosting.com
Servlet at alden-sftp-Hosting.com
Tomcat at alden-sftp-Hosting.com
MySQL at alden-sftp-Hosting.com
Java at alden-sftp-Hosting.com
sFTP at alden-sftp-Hosting.com
http://alden-jsp-Hosting.com
JSP at alden-jsp-Hosting.com
Servlets at alden-jsp-Hosting.com
Servlet at alden-jsp-Hosting.com
Tomcat at alden-jsp-Hosting.com
MySQL at alden-jsp-Hosting.com
Java at alden-jsp-Hosting.com
sFTP at alden-jsp-Hosting.com
http://alden-java-Hosting.com
JSp at alden-java-Hosting.com
Servlets at alden-java-Hosting.com
Servlet at alden-java-Hosting.com
Tomcat at alden-java-Hosting.com
MySQL at alden-java-Hosting.com
Java at alden-java-Hosting.com
sFTP at alden-java-Hosting.com
JSP Servlets Tomcat mysql Java JSP Servlets Tomcat mysql Java JSP Servlets Tomcat mysql Java JSP Servlets Tomcat mysql Java JSP at JSP.aldenWEBhosting.com Servlets at servlets.aldenWEBhosting.com Tomcat at Tomcat.aldenWEBhosting.com mysql at mysql.aldenWEBhosting.com Java at Java.aldenWEBhosting.com Web Hosts Portal Web Links Web Links Web Hosting JSP Solutions Web Links JSP Solutions Web Hosting Servlets Solutions Web Links Servlets Solutions Web Hosting Web Links Web Links . .
.
.
. .
. . . . jsp hosting servlets hosting web hosting web sites designed cheap web hosting web site hosting myspace web hosting