Wednesday, 4 February 2015

interview questions java applet programming (Part4)

16. How can I arrange for different applets on a web page to communicate with each other?
Name your applets inside the Applet tag and invoke AppletContext?s getApplet() method in your applet code to obtain references to the
other applets on the page.

17. How do we read number information from my applets parameters, given that Applets getParameter() method returns a string?
Use the parseInt() method in the Integer Class, the Float(String) constructor or parseFloat() method in the Class Float, or the
Double(String) constructor or parseDoulbl() method in the class Double.

18. Can we pass parameters to an applet from HTML page to an applet? How?
We can pass parameters to an applet using <param> tag in the following way:
? <param name=?param1? value=?value1?>
? <param name=?param2? value=?value2?>
Access those parameters inside the applet is done by calling getParameter() method inside the applet. Note that getParameter() method returns String value corresponding to the parameter name.

19. How do Applets differ from Applications?
Following are the main differences:
Application: Stand Alone, doesn?t need
web-browser. Applet: Needs no explicit installation on local machine. Can be transferred through Internet on to the local machine and may run as part of web-browser. Application: Execution starts with main() method. Doesn?t work if main is not there. Applet: Execution starts with init() method. Application: May or may not be a GUI. Applet: Must run within a GUI (Using AWT). This is essential feature of applets.

20. What is the sequence for calling the methods by AWT for applets?
When an applet begins, the AWT calls the following methods, in this sequence:
? init()
? start()
? paint()
When an applet is terminated, the following sequence of method calls takes place :
? stop()
? destroy()
More Questions & Answers :-
Part1  Part2  Part3  Part4  Part5

No comments:

Post a Comment