0% found this document useful (0 votes)
36 views9 pages

AJP UT1 Answer

Uploaded by

sanikakabade07
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)
36 views9 pages

AJP UT1 Answer

Uploaded by

sanikakabade07
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/ 9

AJP Question Bank answer

1. What does GUI stand for?

a) Graphical User Interface

b) General User Interface

c) Graphics Utility Interface

d) Graphical Utility Interface

2. A____ passive AWT control that do not generate any event?

a) Button c) Panel
b) Choice d)Label

3. Which package contains the Java Swing classes?

a) java. Lang b) java.io c) java. util d) javax. swing

4. Which AWT component is used to create a text control that can


display multiple lines of text?

a) TextArea c) TextField
b)TextPane d) MultiLineText

5. Which class is used as the base class for all Swing components?

a) Component b) Container c) JPanel d) JFrame

6. TabbedPane class is present in which package?

a) java.awt c) javax. swing


b)java.util d) java.awt.event
7. Which layout manager is used by default for JFrame?

a) BorderLayout b) FlowLayout

c) GridLayout d) CardLayout

8. Which class is used to create a button in Java Swing?

a) JButton b) JLabel
c) JRadioButton d) JTextArea

9. In Swing the content pane can be obtained via method________

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

11. What is the purpose of the setVisible () method in JFrame?

a) To set the size of the frame


b) To set the title of the frame
c) To make the frame visible on the screen
d) To close the frame

12. The ___________ interface is used to handle button events:

a) ContainerListener c) ItemListener
b) ActionListener d) WindowListener

13. The Delegation Event Model is based on the concept of __


___________
a) Source c) Listener
b) Both a & b d) None of these
14. What is the purpose of the setLayout () method in Java Swing?

a) To set the background color of a component


b) To set the size of a component
c) To set the layout manager for a container
d) To set the font style for a component

15. Which layout manager is used to arrange components in a grid-like structure?

a) BorderLayout b) FlowLayout
c) GridLayout d) GridBagLayout

16. What is the purpose of the repaint () method in Java Swing?


a) To change the background color of a component
b) To add a new component to a container
c) To revalidate the layout of a container
d) To redraw a component on the screen

17. Which class is used to display text in Java Swing?

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

19. What is the purpose of the setResizable () method in JFrame?

a) To set the size of the frame


b) To set the title of the frame
c) To make the frame resizable or non-resizable
d) To close the frame
20. Which component are used in the following?

a) Checkbox,Applet, Label c) List, Applet, TextField

b) Checklist,Frame, Label d) Combobox,Applet, Label

21. Choose missing statements in following code from given options.


import java.awt. *;
import java. applet. *;
public class Ellipses extends Applet {
{
g.drawOval(10, 10, 50, 50);
g.fillOval(100, 10, 75, 50);
g.drawOval(190, 10, 90, 30);
g. fillOval (70, 90, 140, 100);}}

a ) public void init() c)public static void main(String


args[])
b) public void paint (Graphics g) d)public void paint (String s)

22. For the below code, how is a JTable object created?


String[] colHeads = { "Name", "Extension", "ID#" };
Object [] [] data = {{“Gail", "4567", "865”}, {“Ken", "7566", "555”}};

a) Table jt=new JTable(colHeads); c) Table jt=new


JTable(data,colHeads);
b) Table jt=new JTable(data); d) All of above
23. Which Node is Missing in color node Code?
DefaultMutableTreeNode style=new DefaultMutableTreeNode("Style");
DefaultMutableTreeNode color=new DefaultMutableTreeNode("color");
style. Add(color); DefaultMutableTreeNode red=new
DefaultMutableTreeNode("red");
DefaultMutableTreeNode blue=new DefaultMutableTreeNode("blue");
DefaultMutableTreeNode black=new DefaultMutableTreeNode("black");
DefaultMutableTreeNode green=new DefaultMutableTreeNode("green");
color.add(red); color.add(black); color.add(green);
JTree jt=new JTree(style);

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

26. From given list which is not method of Mouse Listener?

a) mouseClicked c) mouseEntered
b) mouseExited d) mouseDragged ()

27. Which class is used to display images in Java Swing?

a) JButton

b) JLabel

c) JRadioButton

d) JTextArea

28. AWT stands for?

a. All Window Toolkit


b. Abstract Work Toolkit
c. Abstract Window Toolkit
d. Abstract Window Text

29. The subclass of a java.awt. Component class is known as a?

a. system
b. component
c. container
d. component manager

30. What is the super class of all components of Java?

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

32. How many layout managers defined in java.awt package?


a. 2
b. 3
c. 4
d. 5

34. Which method used to place some text in the text field?

a. getText (String str)


b. setText (String str)
c. putText (String str)
d. None of the above

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. setBackground (Color clr)


b. setForeground (Color clr)
c. setColor (Color clr)
d. setEditable (boolean state)
37. getLabel () method used to retrieve the label of a button.

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 ()

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

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

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 ()

You might also like