0% found this document useful (0 votes)
71 views5 pages

AJP Unit 3 MCQ's

advance java programming MCQ's

Uploaded by

Gamer 420
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views5 pages

AJP Unit 3 MCQ's

advance java programming MCQ's

Uploaded by

Gamer 420
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

BHIVARABAI SAWANT

POLYTECHNIC,
Wagholi, Pune- 412207.

ADVANCED JAVA PROGRAMMING


MCQs
(Academic Year 2024-25)

Sub: Advance Java Programming Subject Code: 22517


Semester: 05 Chapter: 3

Sr. MCQ’s
No
1. Which of these packages contains all the classes and methods required for even handling in Java?
(a) java.applet (b) java.awt (c) java.awt.event (d) java.event

2. What is an event in delegation event model used by Java programming language?


(a) An event is an object that describes a state change in a source.
(b) An event is an object that describes a state change in processing.
(c) An event is an object that describes any change by the user and system.
(d) An event is a class used for defining object, to create events.

3. Which of these methods are used to register a keyboard event listener?


(a) KeyListener() (b) DefaultMutableNode (c) addKeyListener() (d) eventKeyboardListener()

4. Which of these methods are used to register a mouse motion listener?


(a) addMouse() (b) addMouseListener()
(c) addMouseMotionListner() (d) eventMouseMotionListener()

5. Event class is defined in which of these libraries?


(a) java.io (b) java.lang (c) java.net (d) javax.util
6. Which of these methods can be used to determine the type of event?
(a) getID() (b) getSource() (c) getEvent() (d) getEventObject()

7. Which of these class is super class of all the events?


(a) EventClass (b) EventObject (c) ActionEvent (d) ItemEvent

8. Which of these events will be notified if scroll bar is manipulated?

(a) ActionEvent (b) ComponentEvent (c) AdjustmentEvent (d) WindowEvent

9. Which class header would be used to create an applet that accepts a click on a button?
(a) public class MyApplet extends Japplet implements Listener
(b) public class MyApplet extends Japplet implements ActionListener
(c) public class MyAppletextends Japplet implements ActionEvent
(d) public class MyApplet extends Japplet implements Event

10. Which of these methods will respond when you click any button by mouse?

(a) mouseClicked() (b) mouseEntered() (c) mousePressed() (d) All

11. Which is the integer constants of TextEvent class?


(a) TEXT_CHANGED (b) TEXT_FORMAT_CHANGED
(c) TEXT_VALUE_CHANGED (d) TEXT_SIZE_CHANGED

12. Which methods are used to close the window?


(a) setVisible(false) (b) windowClosing() (c) stop() (d) Both a and b

13. To process scroll bar events, you need to implement ________________ interface.

(a) adjustmentlistener (b) MouseListener (c) AdjustmentListener (d) KeyListener

14. ______________ method returns a value that indicates which modifier key were pressed when the
action event is generated.

(a) getModifiers() (b) setModifiers() (c) getActionCommand() (d) None of these

15. From following list which is not Swing class?


(a) JLabel
(b) JButton
(c) JImageIcon
(d) JCheckBox

16. 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

17. ______ is an object that describes a state change in the source.

(a) event (b) source (c) none of the above (d) all of the above
18. Which of these methods can be used to obtain the coordinates of a mouse?
(a) getPoint() (b) getCoordinates() (c) getMouseXY() (d) getMouseCordinates()

19. Which of the following method is invoked when a window is changed from a normal to a minimized
state?
(a) windowIconified() (b) windowClosed() (c) windowDeactivate (d) windowOpened()

20. Which event is generating when checkable menu item is selected or deselected?
(a) KeyEvent (b) ListEvent (c) MouseEvent (d) ItemEvent

21. Which are two ways to create Java Anonymous inner class?
(a) Class, Interface (b) Applet (c) Panel,Frame (d) Event

22. The ___________method returns a reference to the component that was added to or removed from the
container.

(a) getParent() (b) getComponent() (c) getChild() (d) getReferenced()

23. Inner class can access all the members of outer class including_____data members and methods
(a) public (b) Protected (c) friend (d) private

24. In case of______we can implement only required methods of any interface.
(a) adapter classes (b) Event (c) EventObject (d) Listener

25. What is a listener in context to event handling?


(a) A listener is a variable that is notified when an event occurs.
(b) A listener is a object that is notified when an event occurs.
(c) A listener is a method that is notified when an event occurs.
(d) None of the mentioned

26.
In the Delegation Event Model, a user interface element is able to delegate, the processing of an
event………..
(a) class (b) a separate piece of code (c) interface (d) listener

27. Listeners are created by implementing one or more of the defined by the…………….
(a) interfaces (b) class (c) listener (d) handler

28. Listeners are created by implementing one or more of the defined by the…………….
(a) string (b) integer (c) Boolean (d) long

29. The example of user interface elements that implement the ItemSelectable interface
(a) checkbox and checkboxgroup (b) textfield and textarea
(c) radiobutton and button (d) Lists and choices

30. public void removeTypeListener(TypeListener el) Here Type means


(a) name of the event b) type of listener (c) name of class (d) name of object
31. The getActionCommand( ) method returns
(a) string (b) integer (c) Boolean (d) long

32. A component subclass that has executed enableEvents() to enable processing of a certain kind of
event cannot also use an adapter as a listener for the same kind of event.

(a) True (b) False

33. Which of the following is the correct way to register a listener for a button click event?

(a) button.addEventListener(new ActionListener());


(b) button.addActionListener(new ActionListener());
(c) button.registerEventListener(new ActionListener());
(d) button.setEventListener(new ActionListener());

34. Which interface must be implemented to handle mouse click events in Java?

(a) ActionListener (b) KeyListener (c) MouseListener (d) FocusListener

35. What method is used to unregister a listener from a component in Java?

(a) removeListener() (b) unregisterListener() (c) deregisterListener() (d) removeActionListener()

36. Which of the following methods is used to handle window closing events in Java?

(a) windowClosing(WindowEvent e) (b) windowClosed(WindowEvent e)


(c) windowOpened(WindowEvent e) (d) windowActivated(WindowEvent e)

37. Which of the following is not a method in the MouseListener interface?

(a) mouseClicked(MouseEvent e)
(b) mousePressed(MouseEvent e)
(c) mouseDragged(MouseEvent e)
(d) mouseExited(MouseEvent e)

38. Which of the following methods is invoked when a button is clicked in Java?

(a) actionPerformed(ActionEvent e)
(b) buttonClicked(ActionEvent e)
(c) buttonPressed(ActionEvent e)
(d) performAction(ActionEvent e)

39. What will happen if you try to add the same MouseListener object to a component twice?

JPanel panel = new JPanel();


MouseListener listener = new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
System.out.println("Mouse clicked");
}
};
panel.addMouseListener(listener);
panel.addMouseListener(listener);

(a) It will throw an exception.


(b) The listener will only be triggered once.
(c) The listener will be triggered twice.
(d) The first listener will be overwritten by the second one

40. Given the following code, what will be printed if the window is closed?

JFrame frame = new JFrame();


frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.out.println("Window is closing");
}
});
frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING));

(a) No output
(b) Window is closing
(c) Window closed
(d) Window opened

You might also like