Académique Documents
Professionnel Documents
Culture Documents
1) What is an Applet?
Applet is a java program which is included in a html page and executes in java
enabled client browser. Applets are used for creating dynamic and interactive web
applications.
2) Explain the life cycle of an Applet?
The following methods implement the life cycle of an Applet:
init : To initialize the applet each time it's loaded (or reloaded).
start : To start the applet's execution, such as when the applet's loaded or when the user
revisits a page that contains the applet.
stop : To stop the applet's execution, such as when the user leaves the applet's page or
quits the browser.
destroy : To perform a final cleanup in preparation for unloading.
3) What happens when an applet is loaded?
The following sequence happens when an applet is loaded:
a) An instance of the applet's controlling class (an Applet subclass) is created.
b) The applet initializes itself.
c) The applet starts running.
4) How to make my class as an applet?
Your class must directly or indirectly extend either Applet or JApplet.
5) What is AppletContext?
AppletContext is an interface which provides information about applet's environment.
6) What is the difference between an Applet and a Java Application?
The following are the major differences between an Applet and an Application:
a. Applets execute within a java enabled browser but an application is a standalone Java
program outside of a browser. Both require a JVM (Java Virtual Machine).
b. Application requires main() method to trigger execution but applets doesn't need a
main() method. Applets use the init(),start(),stop() and destroy() methods for their life
cycle.
c. Applets typically use a fairly restrictive security policy. In a standalone application,
however, the security policy is usually more relaxed.
7) What happens when a user leaves and returns to an applet's page?
When the user leaves the page, the browser stops the applet and when the user returns
to the page, the browser starts the applet and normally most browser's dont initialise the
applet again..
8) What are the restrictions imposed on an applet?
Due to Security reasons, the following restriction are imposed on applets:
No, applets loaded over the net are not allowed to start programs on the client. That
is, an applet that you visit can't start some rogue process on your PC. In UNIX
terminology, applets are not allowed to exec or fork processes. In particular, this means
that applets can't invoke some program to list the contents of your file system, and it
means that applets can't invoke System.exit() in an attempt to kill your web browser.
Applets are also not allowed to manipulate threads outside the applet's own thread group.
17) What is the difference between applets loaded over the net and applets loaded
via the file system?
There are two different ways that applets are loaded by a Java system. The way an
applet enters the system affects what it is allowed to do. If an applet is loaded over the
net, then it is loaded by the applet classloader, and is subject to the restrictions enforced
by the applet security manager. If an applet resides on the client's local disk, and in a
directory that is on the client's CLASSPATH, then it is loaded by the file system loader.
The most important differences are :
a. applets loaded via the file system are allowed to read and write files
b. applets loaded via the file system are allowed to load libraries on the client
c. applets loaded via the file system are allowed to exec processes
d. applets loaded via the file system are allowed to exit the virtual machine
e. applets loaded via the file system are not passed through the byte code verifier
18) What's the applet class loader, and what does it provide?
Applets loaded over the net are loaded by the applet class loader. For example, the
appletviewer's applet class loader is implemented by the class
sun.applet.AppletClassLoader.
The class loader enforces the Java name space hierarchy. The class loader guarantees
that a unique namespace exists for classes that come from the local file system, and that a
unique namespace exists for each network source. When a browser loads an applet over
the net, that applet's classes are placed in a private namespace associated with the applet's
origin. Thus, applets loaded from different network sources are partitioned from each
other. Also, classes loaded by the class loader are passed through the verifier.The verifier
checks that the class file conforms to the Java language specification - it doesn't assume
that the class file was produced by a "friendly" or "trusted" compiler. On the contrary, it
checks the class file for purposeful violations of the language type rules and name space
restrictions. The verifier ensures that :
a. There are no stack overflows or underflows.
b. All register accesses and stores are valid.
c. The parameters to all bytecode instructions are correct.
d. There is no illegal data conversion.
e. The verifier accomplishes that by doing a data-flow analysis of the bytecode
instruction stream, along with checking the class file format, object signatures, and
special analysis of finally clauses that are used for Java exception handling.
19) What's the applet security manager, and what does it provide?
The applet security manager is the Java mechanism for enforcing the applet