Monday, 13 February 2012

Why does JComponent have add() and remove() methods but Component does not? | Core Java

JComponent have add() and remove() methods but Component does not because JComponent is a subclass of Container, and can contain other components and jcomponents.

Can a class be it's own event handler? Explain how to implement this? | Core Java

Sure.a Class can be its own event handler. For an example could be a class that extends Jbutton and implements ActionListener. In the actionPerformed method, put the code to perform when the button is pressed.

What are the advantages of the event-delegation model over the event-inheritance model? | Core Java

Event-delegation model has two advantages over event-inheritance model.
  • Event delegation model enables event handling by objects other than the ones that generate the events. This allows a clean separation between a component's design and its use.
  •  It performs much better in applications where many events are generated. This performance improvement is due to event-delegation model does not have to be repeatedly process unhandled events as is the case of the event-inheritance.

What is an event and what are the models available for event handling? | Core Java

Changing the state of an object is called an event. An event is an event object that describes a state of change. In other words, event occurs when an action is generated, like pressing a key on keyboard, clicking mouse, etc. There different types of models for handling events are event-inheritance model and event-delegation model

Which method is used for setting security in applets? | Core Java

The Method is used for setting security in applets whihc is defined as :
  •  setSecurityManager()

What is the lifecycle of an applet? | Core Java

An Applet is basscially lifecyacle is defined as :
  •  Init( ) method : called when an applet is first loaded.
  •  Start( ) method : called each time an applet is started .
  •  Paint( ) method : called when the applet is minimized or maximized .
  •  Stop( ) method : called when the browser moves off the applet's page.
  •  Destroy( ) method : called when the browser is finished with the applet.

When we should go for codebase in applet? | Core Java

If the applet class is not in the same directory,when we used to codebase.