Subscribe Us

Core Java - Interview Questions and Answers

371. What event results from the clicking of a button?

Ans : The ActionEvent event is generated as the result of the clicking of a button.

372. What is the relationship between an event-listener interface and an event-adapter class?

Ans : An event-listener interface defines the methods that must be implemented by an event
handler for a particular kind of event.
An event adapter provides a default implementation of an event-listener interface.

373. In which package are most of the AWT events that support the event-delegation model defined?

Ans : Most of the AWT–related events of the event-delegation model are defined in the
java.awt.event package. The AWTEvent class is defined in the java.awt package.

374. What is the advantage of the event-delegation model over the earlier event-inheritance model?

Ans : The event-delegation has two advantages over the event-inheritance model.
They are :
It 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 the fact that the event-delegation model does not
have to repeatedly process unhandled events, as is the case of the event-inheritance
model.

375. Which of the following are true?
a) The event-inheritance model has replaced the event-delegation model.
b) The event-inheritance model is more efficient than the event-delegation model.
c) The event-delegation model uses event listeners to define the methods of event-handling classes.
d) The event-delegation model uses the handleEvent( ) method to support event handling.

Ans : c.

376.Which of the following is the highest class in the event-delegation model?
a) java.util.EventListener
b) java.util.EventObject
c) java.awt.AWTEvent
d) java.awt.event.AWTEvent

Ans : b.

377. When two or more objects are added as listeners for the same event, which listener is first invoked to handle the event?
a) The first object that was added as listener.
b) The last object that was added as listener.
c) There is no way to determine which listener will be invoked first.
d) It is impossible to have more than one listener for a given event.

Ans : c.

378. Which of the following components generate action events?
a) Buttons
b) Labels
c) Check boxes
d) Windows

Ans : a.

379. Which of the following are true?
a) A TextField object may generate an ActionEvent.
b) A TextArea object may generate an ActionEvent.
c) A Button object may generate an ActionEvent.
d) A MenuItem object may generate an ActionEvent.

Ans : a,c and d.

380. Which of the following are true?
a) The MouseListener interface defines methods for handling mouse clicks.
b) The MouseMotionListener interface defines methods for handling mouse clicks.
c) The MouseClickListener interface defines methods for handling mouse clicks.
d) The ActionListener interface defines methods for handling the clicking of a button.

Ans : a and d.

Post a Comment

1 Comments

  1. It is very good blog and useful for students and developer , Thanks for sharing



    Core Java Online Training

    ReplyDelete