MCQs on Event Handling.pptx

155 views 21 slides Jan 10, 2024
Slide 1
Slide 1 of 21
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21

About This Presentation

MCQs - Event Handling in Java


Slide Content

MCQs on Event Handling

Which of these packages contains all the event handling interfaces? a) java.lang b) java.awt c ) java.awt.event d) java.event Dr Shreenath Acharya, SJEC, Mangaluru

2. Which of these interfaces handles the event when a component is added to a container? a) ComponentListener b) ContainerListener c) FocusListener d) InputListener Dr Shreenath Acharya, SJEC, Mangaluru

3. Which of these interfaces define a method actionPerformed ()? a) ComponentListener b) ContainerListener c) ActionListener d) InputListener Dr Shreenath Acharya, SJEC, Mangaluru

4. Which of these interfaces define four methods? a) ComponentListener b) ContainerListener c) ActionListener d) InputListener Dr Shreenath Acharya, SJEC, Mangaluru

5. Which of these methods will respond when you click any button by mouse? a) mouseClicked () b) mouseEntered () c) mousePressed () d) all of the mentioned Dr Shreenath Acharya, SJEC, Mangaluru

6. Which of these methods will be invoked if a character is entered? a) keyPressed () b) keyReleased () c) keyTyped () d) keyEntered () Dr Shreenath Acharya, SJEC, Mangaluru

7. Which of these methods is defined in MouseMotionAdapter class? a) mouseDragged() b) mousePressed () c) mouseReleased () d) mouseClicked () Dr Shreenath Acharya, SJEC, Mangaluru

8. Which of these is a superclass of all Adapter classes? a) Applet b) ComponentEvent c) Event d) InputEven Dr Shreenath Acharya, SJEC, Mangaluru

9. 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 Dr Shreenath Acharya, SJEC, Mangaluru

10. Which of these methods are used to register a keyboard event listener? a) KeyListener () b) addKistener () c) addKeyListener() d) eventKeyboardListener () Dr Shreenath Acharya, SJEC, Mangaluru

11. 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 Dr Shreenath Acharya, SJEC, Mangaluru

12. Which of these methods can be used to determine the type of event? a) getID () b) getSource () c) getEvent () d) getEventObject () Dr Shreenath Acharya, SJEC, Mangaluru

13. Which of these class is super class of all the events? a) EventObject b) EventClass c) ActionEvent d) ItemEvent Dr Shreenath Acharya, SJEC, Mangaluru

14. Which of these events will be notified if scroll bar is manipulated? a) ActionEvent b) ComponentEvent c) AdjustmentEvent d) WindowEvent Dr Shreenath Acharya, SJEC, Mangaluru

15. Which of these events will be generated if we close an applet’s window? a) ActionEvent b) ComponentEvent c) AdjustmentEvent d) WindowEvent Dr Shreenath Acharya, SJEC, Mangaluru

16. Which of these can be used to fully abstract a class from its implementation? a) Objects b) Packages c) Interfaces d) None of the Mentioned Dr Shreenath Acharya, SJEC, Mangaluru

17. Which of these access specifiers can be used for an interface? a) Public b) Protected c) private d) All of the mentioned Dr Shreenath Acharya, SJEC, Mangaluru

18. Which of these keywords is used by a class to use an interface defined previously? a) imports b) import c) implement d) implements Dr Shreenath Acharya, SJEC, Mangaluru

19. Which of the following is an incorrect statement about interfaces? a) Interfaces specifies what class must do but not how it does b) Interfaces are specified public if they are to be accessed by any code in the program c) All variables in interface are implicitly final and static d) All variables are static and methods are public if interface is defined pubic Dr Shreenath Acharya, SJEC, Mangaluru

20. What will be the output of the following Java program? interface calculate { void cal( int item); } class display implements calculate { int x; public void cal( int item) { x = item * item; } } class Interfaces { public static void main(String args[]) { display arr = new display(); arr.x = 0; arr.cal(2); System.out.print( arr.x ); } } a) 0 b) 2 c) 4 d) None of the mentioned Dr Shreenath Acharya, SJEC, Mangaluru
Tags