Applets Questions

46)What is an applet?
Ans: Applet is a dynamic and interactive program that runs inside a web page displayed by a java capable browser.
47)What is the difference between applications and applets?
Ans: a)Application must be run on local machine whereas applet needs no explicit installation on local machine.
b)Application must be run explicitly within a java-compatible virtual machine whereas applet loads and runs itself automatically in a java-enabled browser.
d)Application starts execution with its main method whereas applet starts execution with its init method.
e)Application can run with or without graphical user interface whereas applet must run within a graphical user interface.
48)How does applet recognize the height and width?
Ans:Using getParameters() method.

49)When do you use codebase in applet?
Ans:When the applet class file is not in the same directory, codebase is used.
50)What is the lifecycle of an applet?
Ans:init( ) method - Can be called when an applet is first loaded
start( ) method - Can be called each time an applet is started
paint( ) method - Can be called when the applet is minimized or maximized
stop( ) method - Can be used when the browser moves off the applet’s page
destroy( ) method - Can be called when the browser is finished with the applet
51)How do you set security in applets?
Ans: using setSecurityManager() method

7. What are types of applets?.
Trusted Applets: Applets with predefined security
Untrusted Applets: Applets without any security

24. What is java code embedded in a web page known as

25.Which of the following attributes are compulsory with an tag?. code,height & width.

26. What does ‘CODEBASE’ in an applet tag specify?.
Files absolute path.

29.Hostile Applets:Its an applet which when downloaded attempts to exploit your system’s resources in an inappropriate manner.It performs or causes you to perform an action which you would not otherwise care to perform

45.The package java.applet.* has only one class.
55. java.applet is one of the smallest package in Java API - True
86. What are the restrictions imposed by a Security Manager on Applets?.

i) cannot read or write files on the host that’s executing it.
ii) cannot load libraries or define native methods.
iii) cannot make network connections except to the host that it came from
iv) cannot start any program on the host that’s executing it.
v) cannot read certain system properties.
vi) windows that an applet brings up look different than windows that an application brings up.

87. Can we access a database using applets?. Yes.

30. What is the immediate superclass of the Applet class?

No comments: