Unit 1 Cwipedia If Fild
Unit 1 Cwipedia If Fild
e-Exam Manage Questions for Advanced Java Programming (17625) for topic 1 Go Back to Subjects
Q To Fig Q Mar
Question Answer
No pic ure Type ks
2 Which are various AWT controls from following? 1 N R 1 Labels, Push buttons, Check boxes, Choice lists.
4 A checkbox is a control that consists of a ____________ 1 N R 1 Combination of a small box and a Label
23 AWT is used for creating a GUI in Java. AWT stands for 1 N R 1 Abstract Window Toolkit
33 By which method You can set or change the text in a Label? 1 N R 1 setText()
61 How can the Checkbox class be used to create a radio button in AWT? 1 N R 1 By associating Checkbox objects with a CheckboxGroup
62 How do you change the current layout managers for a container? 1 N R 1 Use the setLayout() method
65 How would you set the color of a graphics context called g to cyan? 1 N R 1 g.setColor(Color.cyan);
66 Identify the correct constructor of Font class? 1 N R 1 Font( String name, int fontstyle,int pointsize)
In applet, which of the following tag is used for accepting user defined
68 1 N R 1 Param
parameter?
69 In AWT Checkbox class is used to create __________ 1 N R 1 Checkbox and Radio buttons
73 In how many ways we can define the scrollbar? 1 N R 1 All of the above
86 List can be created for multiple selection by using following constructor. 1 N R 1 List(int num,boolean multiselect)
101 Select the proper constructor of FileDialog 1 N R 1 FileDialog(Frame parent, String boxName)
102 Select the proper syntax to addcomponent in an applet 1 N R 1 Component add(Component comoObj)
112 The CardLayout class defines the following constructors: 1 N R 1 CardLayout() // First Cardlayout(int hor, int ver) //second
The concept of the menu bar canbe implemented by using three java
114 1 N R 1 All of these
classes—
The default layout manager for the content pane of a swing based
117 1 N R 1 Border-Layout
applet is
120 The method setLabel can be used with what type of Object ? 1 N R 1 TextField.
121 The method ____gets the text of the button jtb is 1 N R 1 jtb.getText( )
122 the method _________ places a menu mu into a menu bar mb. 1 N R 1 mb.add(mu)
127 The string parameter to the JButton constructor 1 N R 1 tells what text will appear on the button
129 The syntax for drawRect() method is 1 N R 1 drawRect(int top, int left, int width, int height)
132 The various controls supported by swing are: 1 N R 1 all of the above
135 The _____________ class is used to create radio button in AWT 1 N R 1 CheckboxGroup
138 To create window with title bar which of the following class is used? 1 N R 1 Frame
144 To set title to the frame window___________ method is used. 1 N R 1 void setTitle(String str)
146 What are controls or components? 1 N R 1 Controls or components allow users to interact with application
148 What Are The Types of Dialogbox ? 1 N R 1 modal and Modeless Dialogbox
149 What are the variables defined in Dimension 1 N R 1 height and width
150 What Checkbox method allows you to tell if a Checkbox is checked? 1 N R 1 getState()
What does the following line of code do? TextField text = new
151 1 N R 1 Creates text object that can hold 10 columns of text.
TextField(10);
154 what is default layout manager for panels and applets 1 N R 1 FlowLayout
156 What is the difference between a TextArea and a TextField? 1 N R 1 A TextArea can handle multiple lines of text
157 What is the minimum and maximum of JProgressBar 1 N R 1 minimum -0 Maximum -100
160 What is use of second parameter in given constructor Label(String,int) 1 N R 1 sepcifies the alignment of text in label in terms of pixel
What methods are used to get and set the text label displayed by a
164 1 N R 1 getLabel( ) and setLabel( )
Button object?
168 which method is used to set the visibility of the frame? 1 N R 1 1.setVisible(true)
170 Which abstract class is the super class of all menu related classes. 1 N R 1 MenuComponent
172 Which are the Alignment Constant of Label ? 1 N R 1 All The Above
175 Which AWT control is used for multi-line text entry? 1 N R 1 TextArea
179 Which class encapsulates a blank window upon which we can draw? 1 N R 1 Canvas
180 Which class is on the top of the AWT event hierarchy? 1 N R 1 java.awt.AWTEvent
Which class is used to create a pop-up list of items from which the user
181 1 N R 1 Choice
may choose?
184 Which class provides many methods for graphics programming? 1 N R 1 java.awt.Graphics
187 Which component in swing represents data in rows and columns? 1 N R 1 JTable
189 1 Y1 R 1 Label,TextField
190 which Container use a Border Layout as their default layout? 1 N R 1 All of the above
193 Which h costructor creates a TextArea with 10 rows and 20 columns ? 1 N R 1 new TextArea(10 , 20 )
Which is correct method for adding button component into North region
195 1 N R 1 add(b1, BorderLayout.NORTH)
of border layout? Assume b1 as button object .
199 Which is the correct constructor for JProgressBar 1 N R 1 All of the above
200 Which is the correct constructor of GridLayout 1 N R 1 GridLayout(int numrows, int numcols)
202 Which is the method is used to count the number of items in the list 1 N R 1 getItemCount()
208 Which method gets the text associated with Label object jlbl? 1 N R 1 jlbl.getText()
211 Which method is used to change size and position of Components? 1 N R 1 void setBounds(int x,int y,int width,int height)
212 Which method is used to change the name of a menu item 1 N R 1 void setLabel(String newName)
216 Which method is used to set the dimensions of the window. 1 N R 1 void setSize(int newWidth, int newHeight)
217 Which method is used to set the layout of the Applet? 1 N R 1 setLayout();
218 Which method sets the size and position of a component 1 N R 1 setBounds()
222 Which of the following are not swing componant? 1 N R 1 both a & b
227 which of the following class is Derived from Container Class? 1 N R 1 Panel
228 Which of the following class act as a super class in class hierachy? 1 N R 1 Component
230 Which of the following components does not have visible borders? 1 N R 1 Panel
232 Which of the following controls does not support interaction with user? 1 N R 1 Label
Which of the following creates a List with 5 visible items and multiple
233 1 N R 1 new List(5, true)
selection enabled?
239 Which of the following is not true about Dialog Boxes? 1 N R 1 Dialog boxes contains menu bars.
240 Which of the following is not true about Swing Components? 1 N R 1 Heavy weight components
241 Which of the following is not valid alignment constant for Label? 1 N R 1 MIDDLE
242 Which of the following is not valid constructor for JCheckBox? 1 N R 1 JCheckBox(String text, boolean selected, CheckboxGroup group)
243 Which of the following is not valid style constant for Font? 1 N R 1 NORMAL
246 Which of the following is true about AWT and Swing Component? 1 N R 1 AWT Components create a process where as Swing Component create a thread
248 Which of the following layout managers need to create a Panel? 1 N R 1 CardLayout
Which of the following method is use to add a button “b” to the south
251 1 N R 1 add(b,BorderLayout.SOUTH);
of the applet using BorderLayout?
252 Which of the following method is used to change the Label caption? 1 N R 1 setText(String s)
253 Which of the following method is used to retrive icon of JButton 1 N R 1 Icon getIcon()
257 Which of the following statements about GUI components is wrong ? 1 N R 1 The AWT classes are deprecated
Which of the following statements is for placing the frames upper left
258 1 N R 1 frame.setLocation(200,100)
corner to (200,100)?
260 Which of the follwing is constructor of Jtable? 1 N R 1 JTable(Object data[][], Object colHeads[])
261 Which of the method can be used to output a string in an applet? 1 N R 1 drawString()
Which of the method Choice class returns a string containing the name
262 1 N R 1 String getSelectedItem()
of the item.
264 Which Of these Compenent can be added to frame? 1 N R 1 All of the Above
268 Which of these methods can be used to output a string in an applet? 1 N R 1 drawString()
270 Which of these methods cannot be called on TextArea? 1 N R 1 String getItem(int index)
271 Which of these methods is used to setting the winwods dimension 1 N R 1 void setSize(Dimension new_size)
273 Which of these package is used for graphical user interface ? 1 N R 1 java.awt
275 Which one is the valid constructor of JCheckBox. 1 N R 1 JCheckBox(Sting s, Icon I, Boolean State)
276 Which one method is used to set the visibility of the frame? 1 N R 1 setVisible(true)
277 Which package use for import the swing components? 1 N R 1 javax.swing.*;
which type of button is belongs to a group such that only one button in
279 1 N R 1 CheckboxGroup
the group may be selected at one time?
280 Which of these events is generated when a button is pressed? 1 N R 1 B.) ActionEvent
281 Why are swing component termed as lightweight ? 1 N R 1 they do not depend on native platform
284 Window, frame and dialog use ________ as their default layout. 1 N R 1 BorderLayout
You Can set the alignment of the string within the label by calling
286 1 N R 1 setAlignment()
_______________________
290 _________is the Superclass of TextField and the TextArea classes: 1 N R 1 TextComponent
__________ is a Swing class that allows the user to enter a single line
292 1 N R 1 JTextField
of text.
295 __________ method is used to add the menubar on frame window. 1 N R 1 setMenuBar()
316 ………………………. method is used to lock text box components. 1 N R 1 setEditable(boolean flag)
Figure:-
320 The Jtable used to display data in form of? 1 N U 2 JTable object displays rows and columns of data.
//Identify the correct output for the given code. import java.awt.*;
import java.applet.*; /*<aaplet code="LabelDemo" width=300
height=200></applet>*/ public class MyApplet extends Applet { public
323 1 Y2 A 2
void init() { Label one = new Label("One"); Button submit = new
Button("Submit"); TextField enter = new TextField(); add(one);
add(submit); add(enter); } }
//Select the correct option for the following code. import java.awt.*;
import java.applet.*; import java.awt.event.*; /*<applet
code=scrolldemo width=200 height=300> </applet>*/ public class
scrolldemo extends Applet implements AdjustmentListener { Scrollbar
s1,s2,s3; TextField r,g,b; Color c; public void init() { s1=new
Scrollbar(Scrollbar.HORIZONTAL,0,0,0,256); s2=new
Scrollbar(Scrollbar.HORIZONTAL,0,0,0,256); s3=new
Scrollbar(Scrollbar.HORIZONTAL,0,0,0,256); r=new TextField(5); g=new
325 TextField(5); b=new TextField(5); add(s1); add(r); add(s2); add(g); 1 N A 2 background with combination of r,g and b.
add(s3); add(b); s1.addAdjustmentListener(this);
s2.addAdjustmentListener(this); s3.addAdjustmentListener(this); }
public void adjustmentValueChanged(AdjustmentEvent ae) {
r.setText(Integer.toString(s1.getValue()));
g.setText(Integer.toString(s2.getValue()));
b.setText(Integer.toString(s3.getValue())); c=new
Color(s1.getValue(),s2.getValue(),s3.getValue()); setBackground(c); }
}
1.public class sample5 extends Applet 2.{ 3.public void init() 4.{
5.//CheckboxGroup cg=new CheckboxGroup(); 6.Checkbox c1,c2,c3,c4;
331 2. What is the purpose of JTable? 1 N U 2 JTable object displays rows and columns of data.
Figure:-
A JFrame supports three operations when the user closes the window.
336 1 N U 2 LOWER_ON_CLOSE
Which of the choices below is not one of the three:
337 A menu bar represents 1 N U 2 A list of menus which can be added to the top of a top-level window
A Swing component can be viewed based on what state it’s in, how it
338 looks, and what it does. This is known as the model-view- __________ 1 N U 2 Controller
model.
A toggle button looks just like a push button, but it acts differently
339 1 N U 2 it has two states: enabled and disabled
because _________________________..
348 By which method You can set or change the text in a Label? 1 N U 2 setText()
Choose the correct missing statement from the given code import
java.awt.*; import java.io.*; import java.awt.event.*; import
java.applet.*; class Myframe extends Frame { Myframe(String title) {
super(title); } public void paint(Graphics g) { g.drawString("This is
frame window",120,150); } } public class Myframeapplet extends
Applet //implements windowListener { public void init() { f1=new
352 1 N A 2 Myframe f1;
Myframe("Frame window"); f1.setSize(350,350);
//f1.setLocation(450,450); f1.setVisible(true);
//f1.addwindowListener(this); } public void start() { f1.setVisible(true);
} public void stop() { f1.setVisible(false); } public void paint(Graphics
g) { g.drawString("This ia a applet window",10,50); } } /*<applet
code="Myframeapplet" width=1000 height=1000> </applet>*/
Choose the correct Program for the following output import javax.swing.JFrame; import javax.swing.JTree; import
javax.swing.SwingUtilities; import javax.swing.tree.DefaultMutableTreeNode; public
Figure:-
class TreeExample extends JFrame { private JTree tree; public TreeExample() {
//create the root node DefaultMutableTreeNode root = new
DefaultMutableTreeNode("Root"); //create the child nodes
DefaultMutableTreeNode vegetableNode = new
DefaultMutableTreeNode("Vegetables"); DefaultMutableTreeNode
355 1 Y1 A 2
fruitNode = new DefaultMutableTreeNode("fruits"); //add the child nodes
to the root node root.add(vegetableNode); root.add(fruitNode); //create the tree by
import java.applet.*; import java.awt.*; public class RadioButton1 { public static void
main(String arg[]) { Frame fm=new Frame("RedioButton Group"); Label
la=new Label("What is your choice:"); fm.setLayout(new GridLayout(0,1));
CheckboxGroup cg1=new CheckboxGroup(); fm.add(la); Checkbox cb1=new
357 1 Y1 U 2 Checkbox("MATH",cg1,true); Checkbox cb2=new
Checkbox("PHYSICS",cg1,false); Checkbox cb3=new
Checkbox("CHEMISTRY",cg1,false); Checkbox cb4=new
Checkbox("ENGLISH",cg1,false); fm.setVisible(true); fm.add(la);
fm.add(cb1); fm.add(cb2); fm.add(cb3); fm.add(cb4); } }
import java.awt.*; import java.applet.*; public class appl extends Applet { public void
init() { TextField tf = new TextField(); TextArea t1=new TextArea(3,20); Checkbox
361 1 Y1 A 2 c=new Checkbox("a",true); Checkbox c1=new
Checkbox("b",false); add(tf); add(t1); add(c); add(c1); } } /*<applet
code="appl" width=300 height=300> </applet> */
import java.awt.*; import java.applet.*; public class test11 extends Applet { public
void init() { TextField t1=new TextField(20); Checkbox c=new
362 1 Y1 A 2
Checkbox("a", true); Checkbox c1=new Checkbox("b" , false);
add(t1); add(c); add(c1); } }
364 1 Y1 A 2 Label,TextField,Label,Button
369 1 Y1 U 2 mb.add(jmenu);
370 1 Y1 U 2 Checkbox,TextArea,Button,Label
Consider following program and find the missing statement in the code
import java.awt.event.*; import java.awt.*; import java.applet.*; /*
<applet code=exp1.class width=200 height=200> </applet> */ public
class exp1 extends Applet { public void init() { add(new
371 1 N A 2 setLayout(new BorderLayout());
Button("TOP"),BorderLayout.NORTH); add(new
Button("BOTTOM"),BorderLayout.SOUTH); add(new
Button("RIGHT"),BorderLayout.EAST); add(new
Button("LEFT"),BorderLayout.WEST); } }
Consider following program and state how meny main menu and sub
menu displayed in output: import java.awt.*; public class MenuDemo {
public static void main(String args[]) { Frame f=new Frame("My
Frame"); f.setVisible(true); MenuBar mbr= new MenuBar();
f.setMenuBar(mbr); Menu filemenu=new Menu("File"); Menu
372 editmenu=new Menu("Edit"); Menu viewmenu=new Menu("View"); 1 N A 2 3 Main,3 Sub menu
mbr.add(filemenu); mbr.add(editmenu); mbr.add(viewmenu);
MenuItem new1=new MenuItem("New"); MenuItem open1=new
MenuItem("Open"); filemenu.add(new1); filemenu.add(open1);
new1.setEnabled(false); CheckboxMenuItem wordwrap=new
CheckboxMenuItem("WordWrap"); editmenu.add(wordwrap); }
Debug the following code and find out which statement contains error.
import java.awt.*; import java.awt.event.*; public class MenuDemo
extends Frame { MenuBar mb; Menu m1,m2; MenuItem i1,i2,i3,i4,i5,i6;
MenuDemo(String s) { super(s); mb=new MenuBar(); setMenuBar();
m1=new Menu("File"); m2=new Menu("Edit"); i1=new
MenuItem("New"); i2=new MenuItem("Open"); i3=new
384 1 N A 2 statement where setMenuBar() method is invoked
MenuItem("Exit"); i4=new MenuItem("Cut"); i5=new
MenuItem("Copy"); i6=new MenuItem("Paste"); m1.add(i1);
m1.add(i2); m1.add(i3); m2.add(i4); m2.add(i5); m2.add(i6);
mb.add(m1); mb.add(m2); setSize(500,500); } public static void
main(String args[]) { MenuDemo m=new MenuDemo("MenuFrame");
m.setVisible(true); } }
Debug the following code and find which statement contains error.
import javax.swing.*; import java.awt.*; public class
JRadioButtonDemo extends JApplet { JRadioButton r1,r2,r3; Container
c; public void init() { c=getContentPane(); c.setLayout(new
FlowLayout()); r1=new JRadioButton("Red"); r2=new
385 1 N A 2 Error in statement to create button group i.e. JRadioButtonGroup
JRadioButton("Green"); r3=new JRadioButton("Blue");
JRadioButtonGroup b=new JRadioButtonGroup ();
b.add(r1);b.add(r2);b.add(r3); c.add(r1);c.add(r2);c.add(r3); } } /*
<applet code=JRadioButtonDemo.class width=500 height=500>
</applet>*/
For the below code, how is a JTable object created? String[] colHeads
403 = { "Name", "Extension", "ID#" }; Object[][] data = {{ "Gail", "4567", 1 N U 2 JTable jt=new JTable(data,colHeads);
"865" },{ "Ken", "7566", "555" }};
Give proper command to compile & run following program code? import
java.applet.*; import java.awt.*; /* <applet code="A1" height="300"
405 width="300"> </applet> */ public class A1 extends Applet { public void 1 N A 2 C:\javac A1.java C:\appletviewer A1.java
paint(Graphics gr) { gr.drawString("Welcome to JAVA ",50,100);
setBackground(Color.cyan); } }
Given the following code import java.awt.*; public class SetF extends
Frame { public static void main(String argv[]) { SetF s = new SetF();
406 1 N A 2 s.setBackground(Color.pink);
s.setSize(300,200); s.setVisible(true); } } How could you set the frame
surface color to pink
How many components are used for form validation i.e input username
407 1 N U 2 2 Label,1 Button,2 Textfield
and password
409 How to add image on button 1 N A 2 ImageIcon ii = new ImageIcon(“India.gif”); JButton Jb= new JButton(“ok”,ii);
411 1 Y1 A 2 JButton,ScrollPane
414 1 Y1 U 2 GridLayout
415 Identify proper syntax from following options of TextArea constructor 1 N U 2 TextArea(int numlines, int numChars)
If user does not set size of frame then in output size of frame is _____
421 1 N U 2 0,0
width ______ height
428 In CardLayout we are going to add components for every card to 1 N U 2 Panel
In the applet window a user wants to arrange all component one after
430 1 N U 2 setLayout(new FlowLayout());
another Which statement will work efficiently
433 Is it possible to change display character of TextField?How? 1 N U 2 Yes,by using setEchoChar() method.
434 java Applets are used to create ……………………Applications 1 N A 2 both (a) and (b)
fig(a)-TextField,fig(b)-Button,fig(c)-Label,fig(d)-List,fig(e)-CheckBoxGroup,fig(f)-
435 1 Y1 U 2
checkbox,fig(g)-Choice
Multiple layouts in the single conainer can be created with the help of
437 1 N U 2 Panel
_______________
Observe the following program and point out which statement contains
error. importjava.awt.*; importjavax.swing.*; /* <applet
code="JTableDemo" width=400 height=200> </applet> */ public class
JTableDemo extends JApplet { public void init() { Container
contentPane = getContentPane(); contentPane.setLayout(new
BorderLayout()); final String[] colHeads = { "emp_Name", "emp_id",
"emp_salary" }; final Object[][] data = { { "Ramesh", "111", "50000"
443 1 N A 2 Error in statement in which JScrollPane is created
}, { "Sagar", "222", "52000" }, { "Virag", "333", "40000" }, { "Amit",
"444", "62000" }, { "Anil", "555", "60000" }, }; JTable table = new
JTable(data,colHeads ); int v =
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED; int h =
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPanejsp = new JScrollPane(table,,h,v); contentPane.add(jsp,
BorderLayout.CENTER); } }
Observe the image shown below. S1Q42 Which AWT component will
the image as shown
Figure:-
444 1 Y1 A 2 CheckboxGroup
Picture is a ________________
Figure:-
445 1 Y1 U 2 CheckboxMenuItem
Say that a Frame contains three Panels. Could each Panel have a
448 1 N U 2 Yes---each one can use setLayout() with any layout manager
different layout manager?
450 Select correct statement to add component in south region. 1 N U 2 add(component obj,BorderLayout.SOUTH);
import java.awt.*; import java.applet.*; public class choice11 extends Applet { public
void init() { Choice os=new Choice(); os.add("wnn18"); os.add("wnn
451 1 Y1 A 2 xp"); os.add("wnn nt"); os.add("win 2000"); add(os); }
} /*<applet code="choice11" height=200 width=300>
</applet>*/
import java.awt.*; import java.applet.*; public class Sample extends Applet { public
void init() { CheckboxGroup cbg=new CheckboxGroup(); Checkbox red=new
455 1 Y1 A 2 Checkbox("Red",false,cbg); Checkbox green=new
Checkbox("Green",false,cbg); Checkbox blue=new
Checkbox("Blue",false,cbg); add(red); add(green); add(blue); }}
Select the proper output for following code import java.awt.*; import
java.applet.*; public class DemoBorderLayout extends Applet { Button
b1,b2,b3,b4,b5; public void init() { BorderLayout b=new
BorderLayout(20,30); setLayout(b); b1=new Button("Top"); b2=new
Button("Right"); b3=new Button("Bottom"); b4=new Button("Left");
473 1 Y2 A 2 S1Q42O2
b5=new Button("Center"); add(b1,BorderLayout.NORTH);
add(b2,BorderLayout.EAST); add(b3,BorderLayout.SOUTH);
add(b4,BorderLayout.WEST); add(b5,BorderLayout.CENTER); } } /*
<applet code="DemoBorderLayout.class" width=350 height=300>
</applet>*/
474 1 Y1 U 2 Buttons,FlowLaout.RIGHT
476 Show a single line of code that will convert char ch into String s 1 N A 2 String s=””+ch;
State the method that will be used so as to display the password as '?'
in the output shown in S1Q43
Figure:-
478 1 Y1 A 2 setEchoChar('?')
state the output and assume suitable data import java.awt.*; import
java.applet.*; class Demo extends Applet { CheckBox c1,c2; public void
479 1 N U 2 label of c2 will print
init(){ C1=new CheckBox(“awt”); C2=new CheckBox();
System.out.println(c2.getLabel()); } }
1. Create a JTabbedPane object 2. Call addTab() to Add a tab to the pane 3.Repeat
481 Steps for Adding TabbedPane Control 1 N U 2
Step 2 for each Tab 4. Add the Tabbed Pane to the conte
483 Swing components are light weight because: 1 N A 2 Swing components are platform independent.
485 Tabbedpane Layout can be changed using: 1 N U 2 Mentioning layout in constructor only.
The code Code will produce how many buttons: public class
JScrollPaneDemo extends JApplet { public void init() { // Get content
pane Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout()); JPanel jp = new
JPanel(); jp.setLayout(new GridLayout(20, 20)); int b = 0; for(int i = 0; i
486 < 20; i++) { for(int j = 0; j < 20; j++) { jp.add(new JButton("Button " + 1 N A 2 400 Buttons
b)); ++b; } } // Add panel to a scroll pane int v =
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED; int h =
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane jsp = new JScrollPane(jp, v, h); // Add scroll pane to the
content pane contentPane.add(jsp, BorderLayout.CENTER); } }
487 The constructor JCheckBox(true, “YES”) suggests that – 1 N U 2 Checkbox is selected and displays the string “YES” on it.
488 The default horizontal and vertical gap in FlowLayout is….. 1 N U 2 5 Pixel
490 1 Y1 U 2 BorderLayout
491 1 Y1 U 2 CardLayout
493 The layout manger that shows how words flow in a text editor?Use 1 N U 2 Flow
494 The main difference between model and models dialog box is 1 N U 2 When box is active input focus can not be directed to another window
The method _______ assigns the name Result to the Text of variable
495 1 N A 2 jlbl.setText("Result")
jlbl.
496 The method __________ separates menu items in a menu mu. 1 N A 2 mu.addSeparator()
502 To implement a single –line text area entry area, Use? 1 N A 2 TextField
503 To place any component in AWT/Swing which method will be used 1 N U 2 setBounds(int x,int y,int height,int width)
To set new font object with size 48 , name: Serif , Style PLAIN, what
will be the statement from the following
Figure:-
508 1 Y1 U 2 Label,Checkbox,checkboxGroup,FlowLayout
What code should be added so that we can get following Code? import
java.awt.*; import java.applet.*; import java.awt.event.*; /*<applet
code=SignIn.class width=400 height=400></applet>*/ public class
SignIn extends Applet implements ActionListener { TextField t1,t2;
Button b1; Label l; public void init() { t1=new TextField(20); t2=new
TextField(20); b1=new Button("Sign In"); l=new Label(""); "); add(t1);
add(t2); --------------------- add(b1); ---------------------- add(l); } public
void actionPerformed(ActionEvent ae) { if(ae.getSource()==b1) {
String msg=t1.getText(); String msg1=t2.getText();
if(msg.equals("Admin")&&msg1.equals("Admin")) { l.setText("Correct
509 Password"); } else { l.setText("Incorrect Password"); } } } } 1 Y1 A 2 Both A & B
Figure:-
What code should be added so that we can get following Code? import
java.awt.*; import java.awt.event.*; class WindowCloseDemo extends
Frame { Button exit; WindowCloseDemo() { exit=new Button("Exit");
add(exit); WindowClose w=new WindowClose();
addWindowListener(w); setTitle("Window"); setSize(400,300);
setVisible(true); } public static void main(String []cd) {
WindowCloseDemo wcd=new WindowCloseDemo(); } } class
WindowClose extends WindowAdapter { public void
windowClosing(WindowEvent we) { System.exit(1); } }
Figure:-
511 What code would you use to construct a 24-point bold Calibri font? 1 N U 2 new Font("Calibri", Font.BOLD,24);
515 1 Y1 U 2 Button,Checkbox,RadioButton
519 1 Y1 U 2 JPasswordField,JComboBox,ToolTipText,JTextArea
523 1 Y1 U 2 Label,textfield,Button
531 What is Purpose of Jtree ? 1 N U 2 A tree is a component that presents a hierarchical view of data
532 What is purpose of default constructor of Scrollbar( ) class? 1 N U 2 To create vertical Scrollbar
The object issuing the call to wait() will halt until another object sends a notify() or
537 What is the effect of issuing a wait() method on an object ? 1 N A 2 notifyAll() method
538 1 Y1 U 2 FlowLayout
What is the length of the application box made by this program? import
539 java.awt.*; import java.applet.*; public class myapplet extends Applet 1 N A 2 Compilation Error
{ Graphic g; g.drawString("A Simple Applet", 20, 20); }
546 What is the purpose of JTabbedPane? 1 N U 2 JTabbedPane manages a set of components of linking them with tabs.
547 What is the purpose of ScrollPane 1 N U 2 ScrollPane Displays component in a rectangular area
549
What is the purpose of ToggleButton? 1 N U 2 On or Off Switch
What is the result of executing the following Java class: import java
.awt.*; public class FrameTest extends Frame { public Frame Test() {
550 add (new Button("First")); add ( new Button( "Second")); add (new 1 N A 2 Only the third button is diplayed .
Button ("Third")); pack() ; setVisible(true); } public static void main (
String args [] { new Frame Test ();}}
552 What is the use of setEchoChar() method? 1 N U 2 to create password in symbol form
553 What is the use of setLayout() method 1 N U 2 To install a new layout manager
555 What is use of GridLayout Manager ? 1 N U 2 lays out components in a two-dimensional grid
What will be the order of four items added Choice c1 = new Choice();
563 c1.add("First"); c1.addItem("Second"); c1.add("Third"); 1 N U 2 First,Second,Lastadded,Third
c1.insert("Lastadded",2);
Where g is a graphics instance what will the following code draw on An arc bounded by a box of height 50, width 50, with a centre point of 45,90 starting
568 1 N A 2
the screengfillArc(45,90,50,50,90,180); at an angle of 90 degrees traversing through 180 degrees clockwise
570 1 Y1 A 2 Yes
571 which abstract class is the super class of all menu related classes? 1 N U 2 MenuComponent
Which among the below is not the method applicable for Button in
572 1 N U 2 setDisableIcon()
swing
573 Which among the following is not correct regarding dialog? 1 N U 2 Use of Dialog effects the working of Application
574 Which among the following is the feature of Jtable 1 N U 2 all of these
575 Which are the valid ways to create DataInputStream streams? 1 N A 2 new DataInputStream(new FileInputStream("in.dat");
576 Which are true about the Container class? 1 N U 2 All of the above
577 which AWT complonents are used to produce given output? 1 N U 2 Button, Label, TextField, TextArea
581 which class provides method for accessing a font's properties? 1 N U 2 FontMerices
585 1 Y1 U 2 JScrollPane,Icon
586 1 Y1 U 2 Buttons,Borderlayout
590 1 Y1 U 2 Label,TextArea,Button
591 Which Component subclass is used for drawing and painting? 1 N U 2 Canvas
596 1 Y1 A 2 Label,Choice
600 1 Y1 U 2 JRadioButton,JTextField
601 1 Y1 U 2 Label,TextArea,Button
603 1 Y1 U 2 Applet,Label,TextField,Button
604 1 Y1 U 2 Checkbox,Label
605 1 Y1 U 2 JButton,JTextField
609 1 Y1 U 2 Label,TextField,Button
610 1 Y1 U 2 Label,TextField,Button
615 Which components provide support for two-state buttons? 1 N U 2 JCheckBox, JRadioButton
616 Which constructor creates a TextArea with 10 rows and 20 columns? 1 N U 2 new TextArea(10, 20);
617 1 Y1 U 2 Jtable(2,3)
618 Which control is a combination of text field and dropdown list? 1 N U 2 combo boxes
619 Which Gridlayout class constructor creates single column grid Layout? 1 N U 2 GridLayout()
Which is the layout manger that occupies the same size on the
622 1 N A 2 Grid
window?
625 1 Y1 U 2 FlowLayout
Figure:-
626 1 Y1 U 2 GridBagLayout
627 1 Y1 U 2 BorderLayout
628 1 Y1 U 2 GridLayout
629 1 Y1 U 2 BorderLayout
630 1 Y1 U 2 GridLayout
631 1 Y1 U 2 GridLayout
635 Which method is used to display title on titlebar of Frame? 1 N U 2 setTitle(String title)
638 1 Y1 U 2 drawString("HelloWorld",30,30)
Which method of the component class is used to set the position and
639 1 N U 2 setBounds()
the size of a component?
Which method specifies that the text and icon are horizontally aligned
641 1 N U 2 jbt.setHorizontalTextPosition(JButton.RIGHT)
to the right in the button jbt.
642 1 Y1 U 2 a)drawPolygon(),fillPolygon()
All the methods in the JButton class are inherited from the javax.swing.AbstractButton
643 Which of following is true? 1 N U 2
class
647 Which of the following constructor creates a Checkbox? 1 N U 2 Checkbox(String str, boolean s, null)
Which of the following create a list with five visible items and multiple
648 1 N U 2 new List(5,true)
selection enabled?
Which of the following creates a List with 3 visible items and multiple
649 1 N U 2 new List(3,false)
mode selection disabled?
Which of the following method adds item "I" to the List with
654 1 N U 2 addItem(“I”)
deprecation warnings at the end of List?
Which of the following method use to get the text or caption of the
656 1 N U 2 jbt.getText()
button jbt?
660 Which of the following options is correct about Layout Manager 1 N U 2 Both B and C
Which of the following statement is for placing the frames upper left
661 1 N A 2 frame.setLocation(200,100)
corner to (200,100)
Which of these classes can be added to any Container class, using the
666 1 N U 2 Button
add method defined in Container class ?
667 Which of these events will be notified if scroll bar is manipulated? 1 N U 2 AdjustmentEvent
668 Which of these is not a constructor of the FileDialog? 1 N U 2 FileDialog(Frame parent,int how)
670 Which of these methods can be used to determine the type of event? 1 N U 2 getID()
671 Which of these methods can be used to know which key is pressed 1 N U 2 getModifier()
672 Which of these methods returns the class of the object? 1 N U 2 getClass()
674 Which one is the constructor of the Jtable? 1 N U 2 JTable(Object data[ ][ ], Object colHeads[ ])
Create a Jtree Object, Create a JScrollPane object, Add the tree to the scrollpane and
675 Which option is correct to adding Jtree in an Applet? 1 N U 2
Add the scroll pane to the content pane of the applet.
679 1 Y1 A 2 add(ta1)
CP.add(l2);CP.add(t2); CP.add(b1);CP.add(b2); } }
Figure:-
686 1 Y1 A 2 l2=new JLabel("Password :: ");
688 1 Y1 U 2 c)Jtree
689
691 Why we need to write static keyword to main method ? 1 N U 2 To create single copy
import java.awt.*; public class Butt extends Frame { public static void main(String
argv[]) { Butt MyBut=new Butt(); } Butt() { setLayout(new
692 1 Y1 A 2 FlowLayout(FlowLayout.CENTER)); Button HelloBut=new Button("Hello");
Button ByeBut=new Button("Bye"); add(HelloBut); add(ByeBut);
setSize(300,300); setVisible(true); } }