02 Swing
02 Swing
Answer: C
Answer: A
Answer: A
39. Which Components need to be used to produce this output
A. JTextArea
B. JTabbedPane and TextArea
C. JTabbedPane and icon
D. JtabbedPane,JLabel and ImageIcon
Answer: D
A. B.
import java.awt.*; import java.awt.*;
import javax.swing.*; import javax.swing.*;
public class Demo extends JApplet { public class Demo extends JApplet {
JButton b1,b2; JButton b1,b2;
JCheckBox cb1,cb2; JCheckBox cb1,cb2;
public void init() { public void init() {
Container c=getContentPane(); Container c=getContentPane();
c.setLayout(new FlowLayout()); c.setLayout(new FlowLayout());
cb1=new JCheckBox("Red"); cb1=new JCheckBox("Red",true);
cb2=new JCheckBox("Blue"); cb2=new JCheckBox("Green",false);
b1=new JButton("Submit"); b1=new JButton("Submit");
b2=new JButton("Reset"); b2=new JButton("Reset");
c.add(cb1); c.add(cb2); c.add(b1); c.add(b2); c.add(b1); c.add(b2); c.add(cb1); c.add(cb2);
} } } }
C. D. None of these
import java.awt.*;
import javax.swing.*;
public class Demo extends JApplet {
JButton b1,b2;
JCheckBox cb1,cb2;
public void init() {
Container c=getContentPane();
c.setLayout(new FlowLayout());
cb1=new JCheckBox("Red", true);
cb2=new JCheckBox("Blue", false);
b1=new JButton("Submit");
b2=new JButton("Reset");
c.add(cb1); c.add(cb2); c.add(b1); c.add(b2);
} }
Answer: C
Answer: A
45. Select the correct code for display the given output
A. B.
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
public class ShowLayout extends JFrame public class ShowLayout extends JFrame
{ {
public ShowLayout (String s) public ShowLayout (String s)
{ {
Container c = f.getContentPane(); Container c = f.getContentPane();
c.setLayout (new FlowLayout()); c.setLayout (new FlowLayout());
c.add (new Button("NO"); for (int i = 0; i < 5; i++)
c.add (new Button("Batter"); {
c.add(new Label("Swing")); c.add (new Button("NO");
} }
public static void main (String args[]) c.add (new Button("Batter");
{ c.add(new Label("Swing"));
JFrame f = new }
ShowLayout("JFrameExample"); public static void main (String args[])
f.setVisible(true); {
} } JFrame f = new
ShowLayout("JFrameExample");
f.setVisible(true);
} }
C. D.
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
public class ShowLayout extends JFrame public class ShowLayout extends JFrame
{ {
public ShowLayout (String s) public ShowLayout (String s)
{ {
Container c = f.getContentPane(); Container c = f.getContentPane();
c.setLayout (new FlowLayout()); c.setLayout (new FlowLayout());
for (int i = 0; i < 5; i++) for (int i = 0; i < 4; i++)
{ {
c.add (new Button("NO"); c.add (new Button("NO");
c.add (new Button("Batter"); c.add (new Button("Batter");
} }
c.add(new Label("Swing")); c.add(new Label("Swing"));
} }
public static void main (String args[]) public static void main (String args[])
{ {
JFrame f = new JFrame f = new
ShowLayout("JFrameExample"); ShowLayout("JFrameExample");
f.setVisible(true); f.setVisible(true);
} } } }
Answer: C
48. Select the missing statement in the program to get the following output
import java.awt.*;
import javax.swing.*;
/* <applet code="JComboBoxdemo" width=300 height=200> */
public class JComboBoxdemo extends JApplet
{
public void init()
{
Container contentPane = getContentPane();
contentPane.setLayout(new FlowLayout());
JComboBox jc = new JComboBox();
jc.addItem("France");
jc.addItem("Germany");
jc.addItem("Italy");
jc.addItem("Japan");
contentPane.add(jc);
}}
A. </applet>
B. import java.awt.event.*;
C. }
D. {
Answer: A
A. f=new JFrame();
f.setLayout(new FlowLayout(FlowLayout.RIGHT));
B. f.setLayout(new FlowLayout(FlowLayout.RIGHT));
C. f=new JFrame();
D new JFrame();
setLayout(new FlowLayout(FlowLayout.RIGHT));
Answer: A