Java Applet Interview Questions II
- Can applets on different pages communicate with each other?
- No, Not Directly. The applets will exchange the information at one meeting place either on the local file system or at remote system. - How do I determine the width and height of my application?
- Use the getSize() method, which the Applet class inherits from the Component class in the Java.awt package. The getSize() method returns the size of the applet as a Dimension object, from which you extract separate width, height fields. The following code snippet explains this:Dimension dim = getSize(); int appletwidth = dim.width(); int appletheight = dim.height();
- Which classes and interfaces does Applet class consist? - Applet class consists of a single class, the Applet class and three interfaces: AppletContext, AppletStub, and AudioClip.
- What is AppletStub Interface?
- The applet stub interface provides the means by which an applet and the browser communicate. Your code will not typically implement this interface. - What tags are mandatory when creating HTML to display an applet?
- name, height, width
- code, name
- codebase, height, width
- code, height, width
Correct answer is d.
- What are the Applet’s information methods?
- The following are the Applet’s information methods: getAppletInfo() method: Returns a string describing the applet, its author, copyright information, etc. getParameterInfo( ) method: Returns an array of string describing the applet’s parameters. - What are the steps involved in Applet development? - Following are the steps involved in Applet development:
- Create/Edit a Java source file. This file must contain a class which extends Applet class.
- Compile your program using javac
- Execute the appletviewer, specifying the name of your applet’s source file or html file. In case the applet information is stored in html file then Applet can be invoked using java enabled web browser.
- Which method is used to output a string to an applet? Which function is this method included in? - drawString( ) method is used to output a string to an applet. This method is included in the paint method of the Applet.























