You are on page 1of 2

Write Correct Answer Option in Square box. a.

It enforces that only one radio button can be


selected at a time.
1. Select the correct information b.It allows multiple radio buttons to be selected
a. JTextField cannot be used as a JLabel. simultaneously.
b. JLabel cannot be used as a JTextField. c.It makes radio buttons visually distinct from each
c. Button grouped radio button cannot be used instead other.
of JComboBox. d.It prevents radio buttons from being deselected.
d. JPasswordField extends JLabel.
8. In MVC terminology, The _________
2. Which of the following displays components row- determines how the component reacts to the
by-row in the order in which they were user.
added to the JFrame? a. Model b. View c. Controller d. UI delegate
a. CardLayout
b. FlowLayout 9. Which is correct method for adding button component
c. BorderLayout into North region of border layout? Assume b1 as
d. GridLayout button object .
a. add(BorderLayout.NORTH, b1);
3. Which of the following statements are true? b. add(b1, BorderLayout.CENTER);
S1. Java AWT components are c. add(b1, BorderLayout.NORTH);
platform-dependent. d. add(BorderLayout.CENTER, b1);
S2. Java Swing componets are
platform-independent. 10. Which of the following is not a constructor of
S3. MVC pattern is not supported by AWT. FileDialog?
a.FileDialog(Frame owner)
S4. MVC pattern is supported by Swing.
b.FileDialog(Frame owner, String title)
a. S1,S2,S3,S4 b. S1,S2,S4 c.FileDialog(Frame owner, String title, int mode)
c. S1,S2,S3 d. S2,S4 d.FileDialog(Frame owner, String title, int mode,
FileFilter filter)
4. Which of the following method is used to set a
frame, say f with size 300 × 200 pixels? 11. Which statement is missing or incorrect in the given
JFrame f = new JFrame(); code below?
a. f.setsize(300, 200); import java.awt.*; import java.awt.event.*;
b. f.setSize(300, 200); import java.applet.*;
c. f.paint(300, 200); public class Pra1 extends Applet implements
d. f.setVisible(300, 200); ActionListener {
String s; Label a; Button b; TextArea t;
5. Which GridBagConstraints field specifies how public void init() {
much extra space should be allocated to a a = new Label("Enter Address:",
6component if the containers size changes? Label.LEFT); b = new Button("OK");
a. ipadx and ipady add(a);add(t);add(b); b.addActionListener(this);
b. insets }
c. weightx and weighty public void actionPerformed(ActionEvent ae) {
d. gridwidth and gridheight if (ae.getSource() == b) {repaint();}}
public void paint(Graphics gr) {
6. How do you set the default close operation for a s = t.getText(); gr.drawString("User Address
JFrame to exit the application when the frame is is: " + s, 150, 150);
closed? }}
a.setDefaultCloseOperation(EXIT_ON_CLOSE)
b.setCloseOperation(EXIT) a. The import statement for java.applet.;
b. The creation of the TextArea t instance
c.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
c. The assignment of b.addActionListener(this);
d.setCloseOperation(EXIT_ON_CLOSE)
d. The condition in if (ae.getSource() == b)

7. Which of the following is an advantage of using a 12. Which code is required to display output in table
`ButtonGroup` with `JRadioButton` components? format?
a.Container c1 = getContentPane(); c1.setLayout(new public static void main(String args[]) {
FlowLayout()); MenuDemo m = new MenuDemo();
b.Container c1 = getContentPane(); c1.setLayout(new m.setSize(200,200);
BorderLayout());
m.setTitle("Menu Demo Program");
c.Container c1 = getContentPane(); c1.setLayout(new
GridLayout()); m.setVisible(true); }
d.Container c1 = getContentPane(); c1.setLayout(new public void _______________ { // (4) Fill in the blank
CardLayout());` if (ae.getSource() == new1) {
System.out.println("You Pressed New menu Item");}
13. What error will occur while running given applet? import else if (ae.getSource() == open1)
java.awt.*; import java.awt.event.*; import java.applet.*; {System.out.println("You Pressed Open menu
/* <applet code=ButtonDemo.class width=500
Item");}}}
height=500> </applet>*/ public class ButtonDemo extends
Applet implements ActionListener { Button b1,b2,b3;
String msg; public void init() { msg=""; add(b1); add(b2); a. ActionListener, addActionListener(this)
add(b3); b1=new Button("Yes"); b2=new Button("No"); addActionListener(this), actionPerformed(ActionEvent ae)
b3=new Button("Exit"); b1.addActionListener(this);
b2.addActionListener(this); b3.addActionListener(this); } b. ActionEvent, addActionListener(this)
public void actionPerformed(ActionEvent ae) { addActionListener(this), actionPerformed(ActionListener ae)
if(ae.getSource()==b1) { msg="Yes Button is pressed"; }
if(ae.getSource()==b2) { msg="No Button is pressed"; } C) ActionListener, addActionListener(this)
if(ae.getSource()==b3) { msg="Exit Button is pressed"; } addActionListener(this), actionPerformed(ActionEvent ae)
repaint(); } public void paint(Graphics g ) {
g.drawString(msg,10,250); } } D) ActionEvent, addActionListener(ActionEvent ae)
addActionListener(ActionEvent ae), actionPerformed(this)
a. The order of add(b1); , add(b2); , add(b3); statements is
incorrect. 16. How does a JToggleButton differ from a regular
b. The init() method is missing the super.init(); call. JButton?
c. There paint(); method should be called inside each if block. a. JToggleButton cannot be clicked.
d.The Button objects are not initialized properly. b. JToggleButton cannot have icons.
c. JToggleButton does not support action events.
14. Match The Pair ? 1) Button() a) AdjustmentListener 2) d. JToggleButton can be toggled on and off.
Scrollbar() b) Non Of Above 3) Checkbox() c) ItemListener
4) Label() d) ActionListener 17. How do you add a new tab to a JTabbedPane instance
named tabbedPane?
a. 1-a, 2-b, 3-c, 4-d a. tabbedPane.addTab(String title, Component component)
b. tabbedPane.add(String title, Component component)
b. 1-d, 2-a, 3-c, 4-b
c. tabbedPane.addTab(Component component, String title)
c. 1-d, 2-c, 3-b, 4-a d. tabbedPane.add(Component component, String title)
d. 1-d, 2-a, 3-b, d-c
18. What will be the order of four items added Choice c1 =
15. Fill in the blanks to complete the code and create a new Choice(); c1.add("First"); c1.addItem("Second");
correct sequence: c1.add("Third"); c1.insert("Lastadded",2);
import java.awt.*; import java.awt.event.*; a. First, Second, Third, Lastadded
public class MenuDemo extends Frame implements b. First, Second, Lastadded, Third
_______________ { // (1) Fill in the blank c. First, Lastadded, Second, Third
MenuDemo() { MenuBar mbr = new MenuBar(); d. Second, Lastadded, First, Third
Menu filemenu = new Menu("File");
19. The constructor JCheckBox(true, “YES”) suggests that –
Menu editmenu = new Menu("Edit"); a. Checkbox is initially selected and displays the string
Menu viewmenu = new Menu("View"); "YES" on it.
mbr.add(filemenu); mbr.add(editmenu); b. Checkbox is initially deselected and displays the
MenuItem new1 = new MenuItem("New"); string "YES" on it.
MenuItem open1 = new MenuItem("Open"); c. Checkbox is initially selected and displays a default
filemenu.add(new1); label on it.
filemenu.add(open1); d.Checkbox is initially deselected and displays a default
label on it.
new1._______________; // (2) Fill in the blank
open1.______________; // (3) Fill in the blank
}

You might also like