AJP UT1 Answer
AJP UT1 Answer
a) Button c) Panel
b) Choice d)Label
a) TextArea c) TextField
b)TextPane d) MultiLineText
5. Which class is used as the base class for all Swing components?
a) BorderLayout b) FlowLayout
c) GridLayout d) CardLayout
a) JButton b) JLabel
c) JRadioButton d) JTextArea
a) getContentPane c) getContainer
b)getWindow d) getFrameWindow
10. Which event listener interface is used for handling button click events?
a) ActionListener b) ItemListener
c) MouseListener d) KeyListener
a) ContainerListener c) ItemListener
b) ActionListener d) WindowListener
a) BorderLayout b) FlowLayout
c) GridLayout d) GridBagLayout
a) JTextField
b) JTextArea
c) JLabel
d) JList
18. Which event listener interface is used for handling keyboard events?
a) ActionListener
b) ItemListener
c) MouseListener
d) KeyListener
a) color.add(red); c) color.add(black);
b) color.add(blue); d) color.add(green);
24.
a) ActionListener, addActionListener c)ActionListener,
,actionPerformed, ActionEvent addActionListener,
actionPerformed
b)ActionListener, d) KeyListener,
addMoseListener, addKeyListener,
actionPerformed, actionPerformed,
MouseEvent KeyEvent
25. Code, fill up the correct listener name and event name.
import java.awt. *;
import java.awt. event. *;
import java. applet. *;
/* <applet code="SimpleKeyDemo" width=300
height=100> </applet> */
public class SimpleKeyDemo extends Applet implements _____________
{
String msg = ""; int X = 10, Y = 20;
public void init()
{
addKeyListener(this);
requestFocus();
}
public void keyPressed( _________ ke)
{
showStatus("Key Down");
}
public void keyReleased( _________ ke)
{
showStatus("Key Up");
}
public void keyTyped( ____________ ke)
{
msg += ke.getKeyChar();
repaint();
}
public void paint(Graphics g)
{
g.drawString(msg, X, Y);
}
}
a) KeyListener, KeyEvent c) MouseListener, MouseEvent
b)ActionListener,ActionEvent d)TextListener,TextEvent
a) mouseClicked c) mouseEntered
b) mouseExited d) mouseDragged ()
a) JButton
b) JLabel
c) JRadioButton
d) JTextArea
a. system
b. component
c. container
d. component manager
a. java.all.Component
b. all.awt.Component
c. java.awt. Component
d. awt. Component
31. The subclass of a java.awt.Container class is known as a container.
a. TRUE
b. FALSE
c. Can be true or false
d. Cannot say
34. Which method used to place some text in the text field?
35. What is the listener used to handle the events of a text field?
a. java.awt.ActionListener interface
b. java.awt.event.ActionListener
c. awt.event.ActionListener interface
d. java.awt. event. ActionListener interface
36. Which method used to change the foreground (text) color of components like
text field?
a. Yes
b. No
c. Can be yes or no
d. Cannot say
38. Which of these methods are used to register a mouse motion listener?
a) addMouse ()
b) addMoseListener ()
c) addMouseMotionListner ()
d) eventMouseMotionListener ()
a) java.io
b) java. lang
c) java.net
d) java.awt. event
41. Which of these methods can be used to determine the type of event?
a) getID ()
b) getSource ()
c) getEvent ()
d) getEventObject ()