What is the sequence for calling the methods by AWT for applets?
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()
What are the Applet’s Life Cycle methods? Explain them?
Following are methods in the life cycle of an Applet:
init() method - called when an applet is first loaded. This method is called
only once in the entire cycle of an applet. This method usually intialize
the variables to be used in the applet
start() method - called each time an applet is started
paint() method - called when the applet is minimized or refreshed. This
method is used for drawing different strings, figures, and images on the
applet
window
stop() method - called when the browser moves off the applet’s page
destroy() method - called when the browser is finished with the applet
What are some alternatives to inheritance?
Delegation is an alternative to inheritance. Delegation means that you
include an instance of another class as an instance variable, and forward
messages to the instance. It is often safer than inheritance because it forces
you to think about each message you forward, because the instance is of a
known class, rather than a new class, and because it doesn’t force you to
accept all the methods of the super class: you can provide only the methods
that really make sense. On the other hand, it makes you write more code,
and it is harder to re-use (because it is not a subclass).
Do'stlaringiz bilan baham: |