Unit 5 Oops MCQ
Unit 5 Oops MCQ
Which following method is used to set the graphics current color to the specified color in the
graphics class?
a) public abstract void setFont(Font font)
11 b) public abstract void setColor(Color c)
c) public abstract void drawString(String str, int x, int y)
d) None of the above
1. import java.awt.*;
2. import java.applet.*;
3. public class myapplet extends Applet
4. {
5. public void paint(Graphics g)
18 6. {
7. g.drawString("A Simple Applet", 20, 20);
8. }
9. }
a) A Simple Applet
b) A Simple Applet 20 20
c) Compilation Error
d) Runtime Error
What is the length of the application box made by the following Java program?
1. import java.awt.*;
2. import java.applet.*;
3. public class myapplet extends Applet
4. {
5. public void paint(Graphics g)
19 6. {
7. g.drawString("A Simple Applet", 20, 20);
8. }
9. }
a) 20
b) 50
c) 100
d) System dependent
What is the length of the application box made the following Java program?
1. import java.awt.*;
2. import java.applet.*;
3. public class myapplet extends Applet
20 4. {
5. Graphic g;
6. g.drawString("A Simple Applet", 20, 20); 7.
}
a) 20
b) Default value
c) Compilation Error
d) d) Runtime Error
Which of these packages contains all the classes and methods required for even handling
in Java?
a) java.applet
21
b) java.awt
c) java.event
d) java.awt.event
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
22 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
Which of these methods are used to register a keyboard event listener?
a) KeyListener()
22 b) addKistener()
c) addKeyListener()
d) eventKeyboardListener()
Which of these methods are used to register a mouse motion listener?
a) addMouse()
23 b) addMouseListener()
c) addMouseMotionListner()
d) eventMouseMotionListener()
What is a listener in context to event handling?
a) A listener is a variable that is notified when an event occurs
24 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
Event class is defined in which of these libraries?
a) java.io
25 b) java.lang
c) java.net
d) java.util
Which of these methods can be used to determine the type of event?
a) getID()
26 b) getSource()
c) getEvent()
d) getEventObject()
Which of these class is super class of all the events?
a) EventObject
27 b) EventClass
c) ActionEvent
d) ItemEvent
Which of these events will be notified if scroll bar is manipulated?
28 a) ActionEvent
b) ComponentEvent
c) AdjustmentEvent
d)WindowEvent
Which of these events will be generated if we close an applet’s window?
a) ActionEvent
29 b) ComponentEvent
c) AdjustmentEvent
d) WindowEvent
Which of these events is generated when a button is pressed?
30 a) ActionEvent
b) KeyEvent
c) WindowEvent
d) AdjustmentEvent
Which of these methods can be used to obtain the command name for invoking ActionEvent
object?
31 a) getCommand()
b) getActionCommand()
c) getActionEvent()
d) getActionEventCommand()
Which of these are integer constants defined in ActionEvent class?
32 a) ALT_MASK
b) CTRL_MASK
c) SHIFT_MASK
d) All of the mentioned
Which of these methods can be used to know which key is pressed?
33 a) getKey()
b) getModifier()
c) getActionKey() d)
getActionEvent()
Which of these events is generated by scroll bar? a) ActionEvent
34 b) KeyEvent
c) WindowEvent
d) AdjustmentEvent
Which of these methods can be used to determine the type of adjustment event?
35 a) getType()
b) getEventType()
c) getAdjustmentType()
d) getEventObjectType()
Which of these methods can be used to know the degree of adjustment made by the user?
36 a) getValue()
b) getAdjustmentType()
c) getAdjustmentValue()
d) getAdjustmentAmount()
Which of these constant value will change when the button at the end of scroll bar was
37 clicked to increase its value?
a) BLOCK_DECREMENT
b) BLOCK_INCREMENT
c) UNIT_DECREMENT
b) UNIT_INCREMENT
Which of these events is generated when the size of an event is changed?
38 a) ComponentEvent
b) ContainerEvent
c) FocusEvent
d) InputEvent