0% found this document useful (0 votes)
5 views

AJAVA_MCQ

Uploaded by

sujitwavhal2004
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

AJAVA_MCQ

Uploaded by

sujitwavhal2004
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 386

Maharashtra State Board of Technical Education

(A utonomous) (ISO 9001:2008) (ISO/IEC 27001:2005)

Welcome M1001 [117.239.186.68]

My Home Log Out

5171

e-Exam Manage Questions for Advanced Java Programming (17625) for topic 1 Go Back to Subjects

Question Edited Successfully

Q No Question To picFig ureQ Type Mar ksAnswer

1 JPanel and Applet use ___________________ as their default layout 1 N R 1 Flow Layout

2 W hich are various AW T controls from follow ing? 1 N R 1 Labels, Push buttons, Check boxes, Choice lists.

3 W hich of the follow ing component class cannot be add on applet 1 N R 1 Menu

4 A checkbox is a control that consists of a ____________ 1 N R 1 Combination of a small box and a Label

5 A Frame's _______________ designates the area of the frame excluding the title,menu 1 N R 1 ContentPane

6 A GUI stands for _____________. 1 N R 1 stands for Graphical User Interface

7 A JCheckBoxMenuItem is a subclass of ________. 1 N R 1 All of these

8 A label is a simple control w hich is used to display 1 N R 1 Text(non-editable)


_________________on the w indow

9 A ScrollPane is _______________ 1 N R 1 Container

10 A superclass of Textfield and TextArea classes that is used to create single-line , multili 1 N R 1 Textcomponent

11 A _______ is a component that appears as a group of folders in a file cabinet. 1 N R 1 JTabbedPane

12 A __________ automatically arranges the components added to a container. 1 N R 1 Layout Manager

13 A ____________ is a passive AW T control w hich do not generate any event. 1 N R 1 Label

14 A ____________________component is a display area for a short string of text, image 1 N R 1 Jlabel

15 All Component on Container can be removed by calling follow ing method 1 N R 1 removeAll()

16 All sw ing component classes are placed in 1 N R 1 javax.sw ing

17 An Applet is ______________ of Panel 1 N R 1 subclass

18 Applet Container is used to prepare ________________output w indow . 1 N R 1 Both a and b

19 AppletView er tool is available in w hich of the folder of JDK 1 N R 1 bin

Arranges the components as a deck of cards such that only one

20 component is visible at a time 1 N R 1 CardLayout

21 At the top of the AW T hierarchy is the__________________ class. 1 N R 1 Component

22 AW T classes are contained in the __________ package 1 N R 1 java.aw t

23 AW T is used for creating a GUI in Java. AW T stands for 1 N R 1 Abstract W indow Toolkit

24 AW TEvent Class is define in follow ing package 1 N R 1 java.aw t

25 A________is Componenet that represents a hierarchical view of data 1 N R 1 Jtree

26 A____________ is component that presents a rectangular area in w hich a component 1 N R 1 Scroll Pane

27 Border Layout is divided into_________regions 1 N R 1 five


28 BorderLayout class has __________regions to add components to it 1 N R 1 Five

29 By default flow layout uses __________justification. 1 N R 1 Center

30 By default page-up and page-dow n increment of scrollbar is_____________. 1 N R 1 10

31 By default the Frame has a ________________________________ 1 N R 1 Titlebar,borders,resizing corners

32 By default w hich layout manager is set on applet 1 N R 1 Flow Layout

33 By w hich method You can set or change the text in a Label? 1 N R 1 setText()

34 Canvas is a ________________ 1 N R 1 W indow

35 Checkable menu items are created using object of …………………….class. 1 N R 1 CheckboxMenuItem

36 Choose the incorrect statement 1 N R 1 BorderLayout b = new BorderLayout(3,4);

37 Combobox is a combination of ________________________ 1 N R 1 TextField and Dropdow n List

38 Components are added to w hich pane of sw ing JApplet . 1 N R 1 ContentPane

39 constructors of Jseparator are 1 N R 1 both i and ii

40 Container is the sub class of? 1 N R 1 Component

41 Control not support by aw t are 1 N R 1 TabbedPane,Table

42 Current text of label can be obtained using ___________________. 1 N R 1 getText ()

43 Deafult layout manager for Frame is ___________________. 1 N R 1 BorderLayout

44 Default layout manager for panel is 1 N R 1 Flow Layout

45 Default layout manager for W indow is 1 N R 1 Borderlayout

46 Default Layout of Frame 1 N R 1 BorderLayout

47 Default orientation of progress bar is: 1 N R 1 Horizontal

48 Double-buffering built in, tool tips, dockable tool bars, keyboard accelerators, custom cu1 N R 1 Sw ing

49 Each menu is associated w ith a ___________list of menu items 1 N R 1 Drop-dow n

50 Every layout manager is an instance of __________. 1 N R 1 the LayoutManager interface

51 Executable applet is nothing but _________ file of applet 1 N R 1 .class

52 FileDialog is w hich kind of dialog box? 1 N R 1 Modaltype

53 Flow Layout arranges components from 1 N R 1 Left to Right

54 Flow Layout does not support this value of alignment… 1 N R 1 Flow Layout.BASELINE

55 Font class is available in ___________ 1 N R 1 java.aw t package

56 For adding controls to a w indow , w e use follow ing method 1 N R 1 add()

57 for using Sw ing control one must import______________________________pacakge 1 N R 1 import javax.sw ing.*

58 Frame is a standard w indow ,w hich is ____________________of 1 N R 1 sub class


W indow class from AW T hierarchy

59 getContentPane() method of w hich class 1 N R 1 JApplet

60 getSelectedCheckbox() mehod of w hich class 1 N R 1 CheckboxGroup

61 How can the Checkbox class be used to create a radio button in AW T? 1 N R 1 By associating Checkbox objects w ith a CheckboxGroup

62 How do you change the current layout managers for a container? 1 N R 1 Use the setLayout() method

63 How many checkboxes w e can check at a time: 1 N R 1 multiple

64 How To Apply Image To Button ? 1 N R 1 Using ImageIcon

65 How w ould 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)

67 Identify w rong constructor of Checkbox 1 N R 1 None of Above


68 In applet, w hich of the follow ing tag is used for accepting user defined parameter? 1 N R 1 Param

69 In AW T Checkbox class is used to create __________ 1 N R 1 Checkbox and Radio buttons

70 In AW T Radio buttons are created using_____________________ 1 N R 1 CheckBoxGroup

71 In Flow Layout manager the default space betw een each component is 1 N R 1 5 Pixel

72 In Graphics class W hich method is used to set the graphics current color to the specifie 1 N R 1 public abstract void setColor(Color c)

73 In how many w ays w e can define the scrollbar? 1 N R 1 All of the above

74 In Sw ing Buttons are the subclasses of w hich class? 1 N R 1 AbstractButton

75 In Sw ing the content pane can be obtained via method________ 1 N R 1 getContentPane()

76 In Sw ing ____________is a component that displays row s and columns of data. 1 N R 1 table

77 In Sw ing, tables are implemented by the ______________ class 1 N R 1 JTable

78 Indentify w hich is a valid constructor of MenuItem class? 1 N R 1 MenuItem(String Itemname)

79 Items are added in JComboBox using method……? 1 N R 1 addItem()

80 JApplet class is Derived form 1 N R 1 Applet

81 Java supports input/output of data through the classes included in the 1 N R 1 Java.io
_______ package:

82 JCheckBox is _______________________Component 1 N R 1 lightw eight

83 JRadioButton is a subclass of ________. 1 N R 1 AbstractButton

84 JTabbedPane class is present in w hich package? 1 N R 1 javax.sw ing

85 Jtree class comes under w hich package 1 N R 1 javax.sw ing

86 List can be created for multiple selection by using follow ing constructor. 1 N R 1 List(int num,boolean multiselect)

87 Model is the _________ of the MVC architecture. 1 N R 1 bottom most level

88 mouse click w ill alw ays generate ________________ event? 1 N R 1 MouseEvent

89 MutableTreeNode is extends__________________interface 1 N R 1 TreeNode

90 MVC Architecture is 1 N R 1 Model-View -Controller

91 Name the class used to represent a GUI application w indow , w hich is optionally resiza 1 N R 1 Frame

92 On w hich side applet alw ays executed? 1 N R 1 Client side

93 Package of draw String() method is 1 N R 1 java.aw t

94 Panel is defined as 1 N R 1 All of above

95 Panel is used for __________ components 1 N R 1 Grouping

96 Plugable Look & Feel is the feature of 1 N R 1 Sw ing

97 Positions the componenets into five regions:east,w est,north,south,center 1 N R 1 BorderLayout

98 Program w hich executes applet is know n as________ 1 N R 1 Appletview er

99 public class MenuBar extends ____________________ 1 N R 1 MenuComponent

100 Scrollbar( ) creates a ______________ scroll bar by default. 1 N R 1 Vertical

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)

103 setBorder() method is used to set a border for ________? 1 N R 1 Jcomponent

104 setMenuBar() method of w hich class 1 N R 1 Frame

105 State true of false i) AW T is an extended version of sw ing ii) Paint( ) of 1 N R 1 i-false, ii-false
Applet class cannot be overridden

106 Sw ing components are 1 N R 1 lightw eight and platform independent


107 sw ing is the set of ____________ that provides more pow erful & 1 N R 1 Classes
flexible components as compare to AW T.

108 Text field usually called as 1 N R 1 edit control

109 TextField class is used for__________ 1 N R 1 Single-Line text-entry area

110 The Applet class is in ………..package 1 N R 1 java.applet

111 The AW T container is an instance of the ___________ class w hich holds various comp1 N R 1 Container

112 The CardLayout class defines the follow ing constructors: 1 N R 1 CardLayout() // First Cardlayout(int hor, int ver) //second

113 The CardLayout class manages the components in such a manner that 1 N R 1 Only one

____________component is visible at a time


114 The concept of the menu bar canbe implemented by using three java classes— 1 N R 1 All of these

115 The coordinate of the upper-left corner of a frame is ________. 1 N R 1 (0, 0)

116 The correct hierchy for panel is 1 N R 1 Component-Container-Panel

117 The default layout manager for the content pane of a sw ing based applet is 1 N R 1 Border-Layout

118 The follow ing specifies the advantages of It is lightw eight. It supports pluggable look a1 N R 1 Sw ing

119 The method draw Rect() is used to display an 1 N R 1 outlined rectangle


___________________________

120 The method setLabel can be used w ith w hat 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)

123 The method ______________ sets the foreground color to yellow in 1 N R 1 f.setForeground (Color.YELLOW )
Jframe

124 The method _______________creates a IconImage for file c:\image\us.gif 1 N R 1 new ImageIcon("c:\image\us.gif&q

125 The method ____________________gets the text (or caption) of the label jlbl 1 N R 1 jlbl.getText()

126 The setBackground() method is part of the follow ing class in java.aw t package: 1 N R 1 Component

127 The string parameter to the JButton constructor 1 N R 1 tells w hat text w ill appear on the button

128 The Sw ing component classes that are used in encapsulate a mutually exclusive set of 1 N R 1 ButtonGroup

129 The syntax for draw Rect() method is 1 N R 1 draw Rect(int top, int left, int w idth, int height)

130 The TextArea controls create a ________ respectively. 1 N R 1 Multi-line text

131 the various Control Supported by AW T are 1 N R 1 All of these

132 The various controls supported by sw ing are: 1 N R 1 all of the above

133 The __________ arranges components in row s and columns and makes all component 1 N R 1 GridLayout manager

134 The ___________ interface is used to handle button events: 1 N R 1 ActionListener

135 The _____________ class is used to create radio button in AW T 1 N R 1 CheckboxGroup

136 The ___________________ Can be used to enter or display a string 1 N R 1 textfield

137 These four methods commonly used in? 1)public void add(Component c) 2)public void s 1 N R 1 Component class

138 To create w indow w ith title bar w hich of the follow ing class is used? 1 N R 1 Frame

139 To create file dialog box ______________ class is used 1 N R 1 FileDialog

140 To display text on the applet ______ method is used. 1 N R 1 draw String()
141 To draw a line in applet, w e use follow ing method 1 N R 1 draw Line()

142 To fetch caption of button___________ method is used. 1 N R 1 getLabel( )

143 To retrieve the current state of a check box,call 1 N R 1 getState()


___________________

144 To set title to the frame w indow ___________ method is used. 1 N R 1 void setTitle(String str)

145 W e can add menus to _________________________ 1 N R 1 Frames

146 W hat are controls or components? 1 N R 1 Controls or components allow users to interact w ith applica

147 W hat are the TextCompoent ? 1 N R 1 TextField , TextArea

148 W hat Are The Types of Dialogbox ? 1 N R 1 modal and Modeless Dialogbox

149 W hat are the variables defined in Dimension 1 N R 1 height and w idth

150 W hat Checkbox method allow s you to tell if a Checkbox is checked? 1 N R 1 getState()

151 W hat does the follow ing line of code do? TextField text = new 1 N R 1 Creates text object that can hold 10 colu
TextField(10);

152 W hat is API 1 N R 1 Application Programming Interface

153 W hat is default alignment of components using Flow Layout 1 N R 1 Flow Layout.CENTER

154 w hat is default layout manager for panels and applets 1 N R 1 Flow Layout

155 W hat is the default layout for a dialog? 1 N R 1 BorderLayout

156 W hat is the difference betw een a TextArea and a TextField? 1 N R 1 A TextArea can handle multiple lines of text

157 W hat is the minimum and maximum of JProgressBar 1 N R 1 minimum -0 Maximum -100

158 W hat is the use of follow ing method in JDialog? Container getContentPane() 1 N R 1 This method returns,a Content Pane for t

159 W hat is use of 3rd parameter in given constructor 1 N R 1 Thumbsize


Scrollbar(int,int,int,int,int)

160 W hat 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

161 w hat layout manager should you use so that every component occupies the same size i 1 N R 1 GridLayout

162 W hat letter precedes Sw ing component names that have a corresponding AW T compo1 N R 1 J

163 W hat method is used to prevent a user from changing the size of a 1 N R 1 setResizable( false )
Frame() object?

164 W hat methods are used to get and set the text label displayed by a 1 N R 1 getLabel( ) and setLabel( )
Button object?

165 W hen DialogBox is closed w hich method gets called 1 N R 1 dispose()

166 W hen layout manager is disabled , w hich method is used to determine the shape and p1 N R 1 setBounds

167 W hen w e invoke repaint() for a java.aw t.Component object, the AW T 1 N R 1 update()
invokes the method:

168 w hich method is used to set the visibility of the frame? 1 N R 1 1.setVisible(true)

169 w hich package w e need to import w hile w ritng sw ing JRadioButton class 1 N R 1 import javax.sw ing.*;

170 W hich abstract class is the super class of all menu related classes. 1 N R 1 MenuComponent

171 W hich Among the below is not an AW T class 1 N R 1 RadioButton

172 W hich are the Alignment Constant of Label ? 1 N R 1 All The Above

173 W hich are the subclasses of the container class? 1 N R 1 W indow s,Panel,ScrollPane.

174 W hich AW T component is not editable? 1 N R 1 Label

175 W hich AW T control is used for multi-line text entry? 1 N R 1 TextArea

176 W hich class can be used to represent a checkbox w ith a textual label that can appear i 1 N R 1 CheckboxMenuItem
177 W hich class creates a node in Jtree? 1 N R 1 DefaultMutableTreeNode

178 W hich class defines the setSize( ) method ? 1 N R 1 Frame

179 W hich class encapsulates a blank w indow upon w hich w e can draw ? 1 N R 1 Canvas

180 W hich class is on the top of the AW T event hierarchy? 1 N R 1 java.aw t.AW TEvent

181 W hich class is used to create a pop-up list of items from w hich the user may choose? 1 N R 1 Choice

182 W hich Class is used to get dimension of an Applet? 1 N R 1 Dimension

183 W hich class is used to represent a single line textbox w ith passw ord character facility?1 N R 1 TextField

184 W hich class provides many methods for graphics programming? 1 N R 1 java.aw t.Graphics

185 W hich componant canot be added to a container? 1 N R 1 JFrame

186 W hich component displays information in hierarchical manner w ith parent-child relatio1 N R 1 JTree

187 W hich component in sw ing represents data in row s and columns? 1 N R 1 JTable

188 W hich Component of AW T provides a compact, multichoice , scrolling selection? 1 N R 1 List

189 W hich components are needed to get follow ing show n output 1 Y1 R 1 Label,TextField
Figure:-

190 w hich Container use a Border Layout as their default layout? 1 N R 1 All of the above

191 W hich containers may have a MenuBar? 1 N R 1 Frame


192 W hich control is not contain in AW T Package ? 1 N R 1 Scrollpane

193 W hich h costructor creates a TextArea w ith 10 row s and 20 columns ? 1 N R 1 new TextArea(10 , 20 )

194 W hich is Controll in sw ing a combination of a text field and a dropdow n list 1 N R 1 JComboBox

195 W hich is correct method for adding button component into North region of border layou 1 N R 1 add(b1, BorderLayout.NORTH)

196 w hich is default layout Manager for Japplet? 1 N R 1 BorderLayout

197 W hich is immediate super class for TextField? 1 N R 1 TextComponent

198 W hich is the a constructor of JTabbed Pane 1 N R 1 Both option A and B

199 W hich is the correct constructor for JProgressBar 1 N R 1 All of the above

200 W hich is the correct constructor of GridLayout 1 N R 1 GridLayout(int numrow s, int numcols)

201 W hich is the immediate super class of Applet? 1 N R 1 Panel

202 W hich is the method is used to count the number of items in the list 1 N R 1 getItemCount()

203 W hich is true about sw ing? 1 N R 1 All the above

204 W hich is various methods of TextField control from follow ing? 1 N R 1 getText(),setText(),setEchoChar()

205 W hich layout arranges the components as a deck of cards such that only one compone 1 N R 1 CardLayout

206 W hich layout should you use to organize the components of a container in a tabular for1 N R 1 GridLayout

207 W hich method exectues only once 1 N R 1 init() method


208 W hich method gets the text associated w ith Label object jlbl? 1 N R 1 jlbl.getText()

209 W hich method Is used to add items to JComboBox 1 N R 1 addItem()

210 W hich method is used to add tabs to a JTabbedPane? 1 N R 1 addTab()

211 W hich method is used to change size and position of Components? 1 N R 1 void setBounds(int x,int y,int w idth,int height)

212 W hich method is used to change the name of a menu item 1 N R 1 void setLabel(String new Name)

213 W hich method is used to close a sw ing frame? 1 N R 1 setDefaultCloseOperation()

214 W hich method is used to display Label on checkbox? 1 N R 1 String getLabel()

215 W hich method is used to set label for Button B ? 1 N R 1 B.setLabel(String s)

216 W hich method is used to set the dimensions of the w indow . 1 N R 1 void setSize(int new W idth, int new Height)

217 W hich method is used to set the layout of the Applet? 1 N R 1 setLayout();

218 W hich method sets the size and position of a component 1 N R 1 setBounds()

219 W hich method w ill cause a Frame to be displayed? 1 N R 1 setVisible( true)

220 W hich object can be constructed to show and select any number of choices in the visib 1 N R 1 List

221 W hich of the follow ing applet tags is legal to embed an applet class named Test into a 1 N R 1 < applet code = Test.class w idth = 20

222 W hich of the follow ing are not sw ing componant? 1 N R 1 both a & b
223 W hich of the follow ing are passed as an argument to the paint( ) 1 N R 1 A Graphics object
method?

224 W hich of the follow ing are subclasses of Container Class? 1 N R 1 ScrollPane,Vector,String

225 W hich of the follow ing are subclasses of java.aw t.Component? 1 N R 1 Container

226 W hich of the follow ing are true? 1 N R 1 Panel extends Container.

227 w hich of the follow ing class is Derived from Container Class? 1 N R 1 Panel

228 W hich of the follow ing class act as a super class in class hierachy? 1 N R 1 Component

229 W hich of the follow ing components allow multiple selections? 1 N R 1 List

230 W hich of the follow ing components does not have visible borders? 1 N R 1 Panel

231 W hich of the follow ing contain a Menubar? 1 N R 1 A Frame

232 W hich of the follow ing controls does not support interaction w ith user? 1 N R 1 Label

233 W hich of the follow ing creates a List w ith 5 visible items and multiple selection enable1 N R 1 new List(5, true)

234 w hich of the follow ing is not a AW T control. 1 N R 1 ButtonGroup

235 W hich of the follow ing is not a constructor of JTree 1 N R 1 JTree(int x)

236 W hich of the follow ing is not a sw ing class? 1 N R 1 Canvas

237 W hich of the follow ing is not active control 1 N R 1 labels

238 W hich of the follow ing is not an AW T component 1 N R 1 Applet

239 W hich of the follow ing is not true about Dialog Boxes? 1 N R 1 Dialog boxes contains menu bars.

240 W hich of the follow ing is not true about Sw ing Components? 1 N R 1 Heavy w eight components

241 W hich of the follow ing is not valid alignment constant for Label? 1 N R 1 MIDDLE

242 W hich of the follow ing is not valid constructor for JCheckBox? 1 N R 1 JCheckBox(String text, boolean selected, CheckboxGroup gr

243 W hich of the follow ing is not valid style constant for Font? 1 N R 1 NORMAL

244 W hich of the follow ing is passive AW T control? 1 N R 1 Label

245 W hich of the follow ing is the immidiate superclass of the 1 N R 1 Object
MenuComponent class?

246 W hich of the follow ing is true about AW T and Sw ing Component? 1 N R 1 AW T Components create a process w here as Sw ing Compo
247 W hich of the follow ing is used to interpret and execute Java Applet 1 N R 1 Appletview er
Classes hosted by HTML ?

248 W hich of the follow ing layout managers need to create a Panel? 1 N R 1 CardLayout

249 W hich of the follow ing may a menu contain? 1 N R 1 menu

250 W hich of the follow ing may contain a menu bar? 1 N R 1 frame

251 W hich of the follow ing method is use to add a button “b” to the south of the applet usi 1 N R 1 add(b,BorderLayout.SOUTH);

252 W hich of the follow ing method is used to change the Label caption? 1 N R 1 setText(String s)

253 W hich of the follow ing method is used to retrive icon of JButton 1 N R 1 Icon getIcon()
254 W hich of the follow ing methods are invoked by the AW T to support paint and repaint o1 N R 1 repaint( )

255 W hich of the follow ing methods can be used to change the size of a java.aw t.Compone1 N R 1 setSize()

256 W hich of the follow ing methods can be used to remove java.aw t component object fro1 N R 1 remove()

257 W hich of the follow ing statements about GUI components is w rong ? 1 N R 1 The AW T classes are deprecated

258 W hich of the follow ing statements is for placing the frames upper left corner to (200,11 N R 1 frame.setLocation(200,100)

259 W hich of the follow ing sw ing components donot have an Icon parameter in its constru1 N R 1 JTextField

260 W hich of the follw ing is constructor of Jtable? 1 N R 1 JTable(Object data[][], Object colHeads[])

261 W hich of the method can be used to output a string in an applet? 1 N R 1 draw String()

262 W hich of the method Choice class returns a string containing the name of the item. 1 N R 1 String getSelectedItem()

263 W hich of the subclasses of java.aw t.component? 1 N R 1 Container classes

264 W hich Of these Compenent can be added to frame? 1 N R 1 All of the Above

265 W hich of these follow ing is not a component of sw ing 1 N R 1 List

266 W hich of these method cannot be called on JLabel object? 1 N R 1 setBorderLayout()

267 W hich of these methods can be used to obtain the reference to the container that gener1 N R 1 getContainer()

268 W hich of these methods can be used to output a string in an applet? 1 N R 1 draw String()

269 W hich of these methods cannot be called on JLabel object? 1 N R 1 setBorderLayout()

270 W hich of these methods cannot be called on TextArea? 1 N R 1 String getItem(int index)

271 W hich of these methods is used to setting the w inw ods dimension 1 N R 1 void setSize(Dimension new _size)

272 w hich of these methods use in cardlayout 1 N R 1 add(String s, Component c)

273 W hich of these package is used for graphical user interface ? 1 N R 1 java.aw t

274 W hich of these packages contains all the classes and methods required for event handli1 N R 1 java.aw t.event

275 W hich one is the valid constructor of JCheckBox. 1 N R 1 JCheckBox(Sting s, Icon I, Boolean State)

276 W hich one method is used to set the visibility of the frame? 1 N R 1 setVisible(true)

277 W hich package use for import the sw ing components? 1 N R 1 javax.sw ing.*;

278 W hich TextComponent method is used to set a TextComponent to the read-only state?1 N R 1 setEditable

279 w hich type of button is belongs to a group such that only one button in the group may 1 N R 1 CheckboxGroup

280 W hich of these events is generated w hen a button is pressed? 1 N R 1 B.) ActionEvent

281 W hy are sw ing component termed as lightw eight ? 1 N R 1 they do not depend on native platform
282 W hy w e use Applet? 1 N R 1 Option A) and B) FROM this
283 W indow is super class of ____________ 1 N R 1 Frame

284 W indow , frame and dialog use ________ as their default layout. 1 N R 1 BorderLayout

285 You can construct a JTabbedPane using ____________. 1 N R 1 new JTabbedPane()

286 You Can set the alignment of the string w ithin the label by calling 1 N R 1 setAlignment()
_______________________

287 You w ant to construct a text area that is 80 character-w idths w ide and 1 N R 1 new TextArea( 10,80)
10 character-heights tall. W hat code do you use ?

288 ________ class used to create node in tree. 1 N R 1 DefaultMutableTreeNode

289 ________dialog box is active input is directed to it until it is closed. 1 N R 1 Model

290 _________is the Superclass of TextField and the TextArea classes: 1 N R 1 TextComponent

291 _________Positions are the components into five regions east, w est, north , south, cen1 N R 1 BorderLayout

292 __________ is a Sw ing class that allow s the user to enter a single line of text. 1 N R 1 JTextField

293 __________ is a Sw ing layout manager that arranges components in a row or a colum 1 N R 1 GridLayout

294 __________ method is used to add items in Combobox. 1 N R 1 addItem()

295 __________ method is used to add the menubar on frame w indow . 1 N R 1 setMenuBar()

296 __________ method returns currently selected item in choice. 1 N R 1 getSelectedItem( )

297 ____________ can be used to enter and display a string 1 N R 1 A TextField

298 ____________ class is used to create set of mutually exclusive checkboxes. 1 N R 1 CheckboxGroup

299 ____________ Layout lays components in a Tw o Dimensional Grid 1 N R 1 GridLayout

300 ____________arranges the component in row s and columns 1 N R 1 GridLayout

301 ____________creates a dropdow n list of textual entries 1 N R 1 Choice

302 ______________this is constructor of List control 1 N R 1 List(int numRow s, boolean multipleSelect)

303 _______________contols are platform dependant 1 N R 1 AW T

304 ________________ lays out components in a tw o dimensional grid 1 N R 1 GridLayout

305 ___________________ AW T component is used to create popup list of string items from
1 N R 1 Choice

306 ___________________ class is used to display hierarchical data. 1 N R 1 JTree

307 ____________________class creates blank sementics free w indow 1 N R 1 Canvas

308 _____________________ is not a Sw ing Component 1 N R 1 CheckboxGroup

309 _____________________ is the default layout manager for APPLET. 1 N R 1 Flow Layout

310 ______________________class encapsulates AW T events. 1 N R 1 AW TEvent

311 ________________________ Constructs a new scroll bar w ith the specified orientatio 1 N R 1 Scrollbar(int)

312 ___________________________ component may have different size row s may have d1 N R 1 GridLayout

313 ___________________________ method is used to append the string str to end of the 1 N R 1 append ()

314 ______________________________method is used to add a tab to the pane. 1 N R 1 addTab ()

315 ………….are responsible for placing components on a w indow 1 N R 1 LayoutManagers

316 ………………………. method is used to lock text box components. 1 N R 1 setEditable(boolean flag)

317 A checkbox is a control that consist of a : 1 N R 1 Both a & b

318 Most Sw ing components are __________ components because they are rendered and 1 N R 1 lightw eight
319 Figure:- 1 Y1 A 2 public class HelloSw ing { public HelloSw
Name"); JLabel l2 = new JLabel(&q
JTextField(); JTextField t2 = new JTextFi
JButton("Submit"); JBut

320 The Jtable used to display data in form of? 1 N U 2 JTable object displays row s and columns of data.

321 W hich method is used to display icon on a Button? 1 N U 2 setIcon(ImageIcon i)

322 //Find out the error. import javax.sw ing.JFrame; import javax.sw ing.JTree; import 1 N A 2 Error in statement in w hich JTree is crea
javax.sw ing.Sw ingUtilities; import javax.sw ing.tree.DefaultMutableTreeNode; public
class TreeExample extends JApplet { JTree tree; public void init() {
DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root");
DefaultMutableTreeNode vegetableNode = new
DefaultMutableTreeNode("Vegetables"); DefaultMutableTreeNode fruitNode = new
DefaultMutableTreeNode("Fruits"); root.add(vegetableNode); root.add(fruitNode); tree
= new JTree(); add(tree); } } /*<applet code=”TreeExample” w idth=300
height=300>
</applet>*/

323 //Identify the correct output for the given code. import java.aw t.*; import java.applet.*1 Y2 A 2

//Identify the error import java.aw t.*; import javax.sw ing.*; /*<applet code="JTableD

324 BorderLayout()); final String[] colHeads = { "Roll No", "Name", "Branch" 1 N A 2 Error in statement in w hich JTable is cre
}; final Object[][] data = { { “11”,"Mayur", “CO” }, { “22”,"Ritesh", “IF”
}, { "33", “Rahul”, “CM” } }; JTable table = new JTable(data); int v =
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED; int h =
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED; JScrollPane jsp = new
JScrollPane(table, v, h); contentPane.add(jsp, BorderLayout.CENTER); } }

325 //Select the correct option for the follow ing code. import java.aw t.*; import 1 N A 2 background w ith combination of r,g an
java.applet.*; import java.aw t.event.*; /*<applet code=scrolldemo w idth=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 TextField(5);
b=new TextField(5); add(s1); add(r); add(s2); add(g); 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); }
}
326 1. W hich components are used in the follow ing output? Figure:- 1 Y1 U 2 Label, TextField, Button

327 1.import java.aw t.*; 2.import java.applet.*; 3.public class sample3 extends Applet 1 N A 2 Line number 10
4.{ 5.public void init() 6.{ 7.Choice country=new Choice(); 8.country.add("india");
9.country.add("america");
10.country.add("shrilanka",true); 11.country.add("japan");
12.add(country); 13.} 14.}

1.public class sample5 extends Applet 2.{ 3.public void init() 4.{
5.//CheckboxGroup cg=new CheckboxGroup(); 6.Checkbox c1,c2,c3,c4;

328 7.c1=new Checkbox("maths",true); 8.c2=new 1 N A 2 Line number 14


Checkbox("physics",false); 9.c3=new Checkbox("science",false);
10.c3=new Checkbox("computer",true); 11.add(c1); 12.add(c2);
13.add(c3); 14.add(c4); 15 .} 16. }

329 1.W hich is missing statement in follow ing program? import java.aw t.*; import java.ap1 N A 2 setLayout(new BorderLayout()

330 2. Consider the follow ing program. Find w hich statement contains 1 N A 2 A. Error in statement in w hich JTable is
error.importjava.aw t.*; import javax.sw ing.*; /* <applet code="JTableDemo" w
idth=400 height=200> </applet> */ public class JTableDemo extends JApplet {
public void init() { Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout()); final Object[][] data = { { "Ramesh",
"111", "50000"
}, 15 { "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, v, h); contentPane.add(jsp, BorderLayout.CENTER); } }

331 2. W hat is the purpose of JTable? 1 N U 2 JTable object displays row s and columns of data.

332 2.W hat should be w ritten in blank space. import java.aw t.*; import java.aw 1 N A 2 cbg
t.event.*; import java.applet.*; /* <applet code="CBGroup" w idth=250
height=200> </applet> */ public class CBGroup extends Applet { String msg = "";
Checkbox W in98, w inNT; CheckboxGroup cbg; public void init() { cbg = new
CheckboxGroup(); W in98 = new
Checkbox("W indow s 98/XP", , true); w inNT = new Checkbox("W indow s
NT/2000", , false); add(W in98); add(w inNT); W in98.addItemListener(this); w
inNT.addItemListener(this); } }
333 3. Observe the follow ing code and find w hich statement contains error.import java.aw 1 N A 2 C.Error in adding and registering listener

334 3. Select the proper command to run the follow ing code import java.aw t.*; import 1 N A 2 appletview er combodemo11.java
java.aw t.event.*; import javax.sw ing.*; import java.applet.*; /* <applet
code="combodemo11" w idth=300 height=100> </applet> */ public class
combodemo11 extends JApplet
{ public void init() { Container co = getContentPane(); co.setLayout(new Flow
Layout()); JComboBoxjc=new JComboBox(); jc.addItem("cricket");
jc.addItem("football"); jc.addItem("hockey"); jc.addItem("tennis"); co.add(jc); } }

4.To create a Follow ing output w hich control is required.


335 Figure:- 1 Y1 U 2 2 Label, 1 Button

336 A JFrame supports three operations w hen the user closes the w indow . W hich of the ch1 N U 2 LOW ER_ON_CLOSE

337 A menu bar represents 1 N U 2 A list of menus w hich can be added to the top of a top-level

338 A Sw ing component can be view ed based on w hat state it’s in, how it looks, and w hat1 N U 2 Controller

339 A toggle button looks just like a push button, but it acts differently because __________1 N U 2 it has tw o states: enabled and disabled

340 A user w ant’s to create an Applet w ith menubar consisting three menu items and 1 N A 2 . import java.aw t.*; import java.applet.
one checkable menu item select correct coding?

341 All java classes are derived from 1 N U 2 java.lang.Object

342 An Applet has its Layout Manager set to the default of Flow Layout. W hat code w ould b1 N A 2 setLayout(new GridLayout(2,2));

343 Analyse the follow ing code import javax.sw ing.*; Import javax.sw ing.border.*; Impor 1 N A 2 The program has compile error.
344 Analyse the follow ing code? import javax.sw ing.*; import java.aw t.*; public class Tes 1 N A 2 Four buttons are displayed w ith the sam

345 Arranges the compents as a deck of cards such that only one 1 N U 2 B.CardLayout

import java.aw t.*; import java.applet.*; /*&lt;applet code=&quot;Login&quot;

w idth=400 height=200&gt; &lt;/applet&gt;*/ public class Login extends Applet {


TextField nm; TextField psw ; public void init() { Label nml = new
Label(&quot;USername:&quot;, Label.RIGHT); Label psw l =new
Label(&quot;Passw ord:&quot;, Label.RIGHT); nm=new TextField(12); psw = new
TextField(12); Button b=new Button(&quot;Submit&quot;); add(nml); add(nm);
add(psw l); add(psw ); add(b); } }

super(); } } W hich statement are true?

368 Components in the frame is add at appropriate place using 1 N A 2 setBounds(int,int,int,int)

Consider follow ing output. Find the missing statement in the follow ing program to get a

Figure:-

369 1 Y1 U 2 mb.add(jmenu);

370 Consider follow ing output.Identify controls used. Figure:- 1 Y1 U 2 Checkbox,TextArea,Button,Label


371 Consider follow ing program and find the missing statement in the code import 1 N A 2 setLayout(new BorderLayout());
java.aw t.event.*; import java.aw t.*; import java.applet.*; /*
<applet code=exp1.class w idth=200 height=200> </applet> */ public class exp1
extends Applet { public void init() { add(new Button("TOP"),BorderLayout.NORTH);
add(new Button("BOTTOM"),BorderLayout.SOUTH); add(new
Button("RIGHT"),BorderLayout.EAST); add(new Button("LEFT"),BorderLayout.W EST);
}}

372 Consider follow ing program and state how meny main menu and sub menu displayed in1 N A 2 3 Main,3 Sub menu

Consider follow ing program.Select the missing statement from options. import javax.sw

373 w idth=200 height=200> </applet>*/ public class TableDemo extends JApplet { 1 N A 2 Table table = new JTable(data,col);
public void init() { Container cp=getContentPane(); cp.setLayout(new
BorderLayout()); String data[][] =
{{"Neeta","CO","A"},{"Mahesh","CE","B"},{"Akanksha","IF","C"},
{"Neha","ME","A"}}; String col[] = {"Name","Branch","Grade"}; int
v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED; int
h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALW AYS; JScrollPane jsp=new
JScrollPane(table,v,h); cp.add(jsp,BorderLayout.CENTER); } }

374 Consider the follow ing program W hat w ill be displayed in the output? import java.aw t1 N A 2 Applet w ithout any controls.

375 Consider the follow ing program W hich statemnet is prepare for blank space import java1 N A 2 add(new Button(&quot;&quot;+n));

376 Consider the follow ing program. W hat should be the correction done in the program to 1 N A 2 package not imported correctly

377 Consider the follow ing program. Find the error. import java.aw t.*; import java.applet.*1 N A 2 All of above
Consider the follow ing program. Find w hich missing statement. import java.aw t.*; imp DefaultMutableTreeNode top = new Defa

378 DefaultMutableTreeNode("SW E"); a.add(a2); DefaultMutableTreeNode b = new DefaultM


1 N A 2 Computer Engineering&quot;);

379 Consider the follow ing program. Find w hich statement contains error. import java.aw t 1 N A 2 Class should not be public.

380 Consider the follow ing program. Find w hich statement contains error. import java.aw t 1 N A 2 No error.

381 Consider the follow ing program. Find w hich statement contains error. import java.aw 1 N A 2 Error in statement in w hich JTable is cre
t.*; import javax.sw ing.*; /* <applet code="JTableDemo" w idth=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"
}, { "Sagar", "222", "52000" }, { "Virag", "333", "40000" }, { "Amit", "444", "62000"
}, { "Anil", "555", "60000" }, }; JTable table = new JTable(data); int v =
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED; int h =
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED; JScrollPanejsp = new
JScrollPane(table, v, h); contentPane.add(jsp, BorderLayout.CENTER); } }

382 Consider the follow ing program. Find w hich statement contains error. import java.apple1 N A 2 Error in the statement creating panel obj

Consider the folow ing code.Select the proper scrollbar constant for blank line in code . i
383 </applet> */ public class ScrollDemo extends JApplet { public void init() 1 N U 2 Both I and ii
{ Container cp=getContentPane(); cp.setLayout(new BorderLayout()); JTextArea
ja=new JTextArea(); int v=ScrollPaneConstants.____________________________ ;
int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALW AYS;
JScrollPane jsp=new JScrollPane(ja,v,h);
cp.add(jsp,BorderLayout.CENTER); } }

384 Debug the follow ing code and find out w hich statement contains error. import java.aw 1 N A 2 statement w here setMenuBar() method

385 Debug the follow ing code and find w hich statement contains error. import javax.sw 1 N A 2 Error in statement to create button group
ing.*; import java.aw t.*; public class JRadioButtonDemo extends JApplet {
JRadioButton r1,r2,r3; Container c; public void init() { c=getContentPane();
c.setLayout(new Flow Layout()); r1=new JRadioButton("Red"); r2=new
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 w idth=500 height=500>
</applet>*/

386 Dectate Error in folloing code , Specify line number if any; 1. import java.applet.*; 2. im1 N A 2 Line number 10 and 3

387 EventObject class is defined in w hich of these libraries? 1 N A 2 java.util

388 Fill in the blanks so that the follow ing draw s a Frame containing "Hello". import 1 N A 2 extends, paint, draw String
java.aw t.*; class HelloFrame ___________ Frame { public void ___________(
Graphics g ) { g.___________("Hello", 10,
50 ); } } public class Tester { public static void main ( String[] args ) { helloFrame
frm = new helloFrame(); frm.setSize( 150, 100 ); frm.setVisible( true ); } }

389 Fill in the blanks so that this program displays a Frame: import java.aw t.*; public 1 N A 2 Frame, setSize, setVisible
class microGUI { public static void main ( String[]
args ) { Frame frm = new ___________(); frm.___________( 150, 100
); frm.___________( true ); } }

Find error from follow ing code import java.aw t.*; import java.aw t.event.*; import
javax.sw ing.*; import javax.sw ing.tree.*; /*
<applet code="JTreeEvents" w idth=400 height=200> </applet> */ public class
JTreeEvents extends JApplet { JTree tree; JTextField jtf; public void init() { // Get
content pane Contain contentPane = getContentPane(); contentPane.setLayout(new
BorderLayout()); DefaultMutableTreeNode top = new
DefaultMutableTreeNode("Options"); DefaultMutableTreeNode a = new

390 DefaultMutableTreeNode("A"); top.add(a); DefaultMutableTreeNode a1 1 N A 2 contentPane must be object of Containe


= new DefaultMutableTreeNode("A1"); a.add(a1); DefaultMutableTreeNode a2 = new
DefaultMutableTreeNode("A2"); a.add(a2); DefaultMutableTreeNode b = new
DefaultMutableTreeNode("B"); top.add(b); DefaultMutableTreeNode b1
= new DefaultMutableTreeNode("B1"); b.add(b1); DefaultMutableTreeNode b2 = new
DefaultMutableTreeNode("B2"); b.add(b2); DefaultMutableTreeNode b3 = new
DefaultMutableTreeNode("B3"); b.add(b3); tree = new JTree(top); int v
= ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED; int h =
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED; JScrollPane jsp = new
JScrollPane(tree, v, h); contentPane.add(jsp, BorderLayout.CENTER); jtf = new
JTextField("", 20); contentPane.add(jtf, BorderLayout.SOUTH); }}
391 Find error in follow ing code. import java.aw t.*; import java.applet.*; public class Choic1 N A 2 applet code is missing

392 Find missing statement from given code: public class ButtonLabelDemo extends 1 Y1 A 2 l1=new Label(&quot;one&quot;); l2=new
Applet { Label l1,l2; Button b1; public void init() { ** ** ** Button(&quot;OK&quot;);
//Adding the controls to the applet add(l1); add(l2); add(b1); } } Figure:-

393 find out missing line in follow ing code. Import java.aw t.*; import java.sw ing.* public 1 N U 2 Container cp=getContentPane()

394 Find out missing statement in follow ing code: import java.aw t.*; import 1 N A 2 add(l1); add(l2);
java.applet.*; /* <applet code=exp4.class w idth=200 height=200>
</applet> */ public class exp4 extends Applet { List l1,l2; public void init() { l1=new
List(4); l2=new List(4,true); l1.add("abc"); l1.add("def"); l1.add("ghi");
l1.add("lmk"); l2.add("1"); l2.add("2"); l2.add("3"); l2.add("4"); } }

395 Find the error in the follow ing code. import java.aw t*; import java.aw t.event.*; impor1 N A 2 A and B

396 Find the error. /*<applet code="MyJTabbedPane" w idth=900 height=900> </applet>* 1 N A 2 b)JTabPane Constructor is incorrect

JTabPane jtp=new JTabPane(); jtp.addTab("Cities",new CitiesPanel()); jtp.addTab("Colo

397 Find the missing statement from the follow ing program. import java.aw t.*; import 1 Y1 U 2 Missing add statement
java.aw t.event.*; import javax.sw ing.*; import java.applet.*; /* <applet
code="ctest" w idth=300 height=100>
</applet> */ public class ctest extends JApplet { public void init() { Container co =
getContentPane(); co.setLayout(new Flow Layout()); JComboBox jc=new
JComboBox(); jc.addItem("cricket"); jc.addItem("football"); jc.addItem("hockey");
jc.addItem("tennis"); } }
Figure:-
398 Find the missing statement in the follow ing code import java.aw t.*; class MenuDemo e1 N A 2 setMenuBar(mb);

399 Find the missing statement. import javax.sw ing.*; class MyFrame extends JFrame { pu 1 N U 2 public static void main(String[] args)

400 find the ouptut of the follow ing : import javax.sw ing.*; class Demo extends JApplet { p1 Y2 A 2 S1Q43O1

401 Follow ing program output display w hich type of layout manager : 1 N A 2 CardLayout
import java.aw t.*; import java.applet.*; import java.aw t.event.*; /*
<applet code=cl.class w idth=200 height=200> </applet> */ public class cl extends
Applet { CardLayout cardLayout; Panel panel; Button button1, button2, button3;
public void init() { panel = new Panel(); add(panel); cardLayout = new
CardLayout(0,0); panel.setLayout(cardLayout); button1 = new Button("Button1");
button2 = new Button("Button2"); button3 = new Button("Button3");
panel.add("Button1", button1); panel.add("Button2", button2); panel.add("Button3",
button3); }

For producing follow ing outputs w hich program code is correct


Figure:-

402 1 Y1 A 2 import java.aw t.*; class Demo3 extends

403 For the below code, how is a JTable object created? String[] colHeads 1 N U 2 JTable jt=new JTable(data,colHeads);
= { "Name", "Extension", "ID#" }; Object[][] data = {{ "Gail", "4567", "865" },{
"Ken", "7566", "555" }};

404 From follow ing list W hich is not Sw ing class? 1 N U 2 JImageIcon

405 Give proper command to compile & run follow ing program code? import java.applet.*; i1 N A 2 C:\javac A1.java C:\appletview er A1.jav

406 Given the follow ing code import java.aw t.*; public class SetF extends Frame { public s1 N A 2 s.setBackground(Color.pink);

407 How many components are used for form validation i.e input username and passw ord 1 N U 2 2 Label,1 Button,2 Textfield
408 How many controls are show n on Applet after executing follow ing program import 1 N U 2 3
java.aw t.*; import java.aw t.event.*; import java.applet.*; /* <applet
code="app2.class" height=100 w idth=200>
</applet>*/ public class app2 extends Applet { Checkbox cb1,cb2; TextField tf1;
String str,str1; public void init() { Label c=new Label("COLORS"); cb1=new
Checkbox(); cb2=new Checkbox("W HITE"); tf1=new TextField("ABC"); add(cb1);
add(c); add(tf1); } }

409 How to add image on button 1 N A 2 ImageIcon ii = new ImageIcon(“India.gif”); JButton Jb= new

410 how to disable the default layout manager 1 N U 2 setLayout(null)

411 Identify components used 1 Y1 A 2 JButton,ScrollPane


Figure:-

412 Identify controls used in follow ing output 1 Y1 U 2 TextFiled and Scrollbars
Figure:-

413 Identify default output for given code import java.aw t.event.*; import java.applet.*; 1 Y2 A 2 S1Q45O4
public class Flow LayoutDemo extends Applet implements ItemListener { String msg
= ""; Checkbox W in98, w inNT, solaris, mac; public void init() { setLayout(new Flow
Layout(Flow Layout.LEFT));
W in98 = new Checkbox("W indow s 98/XP", null, true); w inNT = new Checkbox("W
indow s NT/2000"); solaris = new Checkbox("Solaris", null, true); mac = new
Checkbox("MacOS"); add(W in98); add(w inNT); add(solaris); add(mac); W
in98.addItemListener(this); w inNT.addItemListener(this);
solaris.addItemListener(this); mac.addItemListener(this); } public void
itemStateChanged(ItemEvent ie) { repaint(); } public void paint(Graphics g) { msg
= "Current state: "; g.draw String(msg, 6, 80); msg = " W indow s 98/XP: " + W
in98.getState(); g.draw String(msg, 6, 100); msg = " W indow s NT/2000: " + w
inNT.getState(); g.draw String(msg, 6, 120); msg = " Solaris: " + solaris.getState();
g.draw String(msg, 6, 140); msg = " Mac: " + mac.getState(); g.draw String(msg, 6,
160); } }
414 Identify layout used in the output given below . Figure:- 1 Y1 U 2 GridLayout

415 Identify proper syntax from follow ing options of TextArea constructor 1 N U 2 TextArea(int numlines, int numChars)

416 Identify the code for the output given below . Figure:- 1 Y1 A 2 import java.aw t.*;import javax.sw ing.*
JCheckBox cb1,cb2; public void init() { C
c.setLayout(new Flow Layout()); cb1=ne
cb2=new JCheckBox(&quot;Blue&quot;,
JButton(&quot;Submit&quot;);b2=new
JButton(&quot;Reset&quot;);c.add(cb1);

417 Identify the components required to design this applet w indow show n in image? 1 Y1 A 2 Label, Button, TextField, Checkbox, Chec
Figure:-
418 Identify the correct code for follow ing output. Figure:- 1 Y1 A 2 import java.aw t.*; public class MenuDem
new MenuBar(); setMenuBar(mbr); Menu
Menu(&quot;Edit&quot;); Menu v =new
MenuItem(&quot;New &quot;); Checkbox
CheckboxMenuItem(&quot;Open&quot;,t
mbr.add(e); mbr.add(v); } public static
MenuDemo(); m.setVisible(true); m.setS

419 Identify the layout of the image . Figure:- 1 Y1 A 2 Border Layout

420 If a progam consist of three classes,then after compilation how many class file (s) is ar 1 N U 2 Three

421 If user does not set size of frame then in output size of frame is _____ 1 N U 2 0,0
w idth ______ height

422 import java.aw t.*; class Demo extends Frame { public static void main(String args[]){1 N A 2 using setVisible(false);

423 import java.aw t.*; import java.applet.* /*<applet code="my.class" w idth=300 height1 N A 2 Compilation Error

424 import java.aw t.*; import java.applet.*; /*<applet code="Choice_Demo.class" w idth=1 N A 2 Applet

425 import java.aw t.*; import javax.sw ing.*; public class Test { public static void main(Str1 N A 2 Only button Cancel is displayed.

426 import java.aw t.*; import javax.sw ing.*; /*<applet code="L.class" w idth=200 height1 N A 2 Button is created w ith given image
427 import java.aw t.*; import javax.sw ing.*; public class Sw ing_Demo extends JApplet 1 Y1 A 2 Container c=getContentPane();
{ public void init() { ImageIcon ii=new ImageIcon("Sunset.jpg"); JLabel l1=new
JLabel("Sunset Image",ii,JLabel.CENTER); c.add(l1); } }
Figure:-

428 In CardLayout w e are going to add components for every card to 1 N U 2 Panel

429 In given constructor w hat 3rd parameter indictaes Scrollbar s=new 1 N A 2 Size of thumb
Scrollbar(0,10,20,0,1000)

430 In the applet w indow a user w ants to arrange all component one after another W hich 1 N U 2 setLayout(new Flow Layout());

431 In the below program, w hy is java.aw t package imported? import javax.sw ing.*; 1 N U 2 Because Container belongs to the packag
import java.aw t.*; public class New Main extends JFrame { public static void
main(String[] args) { JFrame jf=new JFrame(""My Frame""); Container
cpane=jf.getContentPane(); JLabel l1=new JLabel(""Name""); JButton b1=new
JButton(""OK""); JButton b2=new JButton(""CANCEL""); JTextField t1= new
JTextField(); jf.setLayout(new GridLayout(2,2)); cpane.add(l1); cpane.add(t1);
cpane.add(b1); cpane.add(b2); jf.setSize(100,100); jf.setVisible(true);
jf.setDefaultCloseOperation(EXIT_ON_CLOSE); } }

432 Insert the correct code in the follow ing program segment in order to display follow 1 Y1 A 2 JRadioButton b1,b2,b3; b1= new JRadio
ing output. JRadioButton(&quot;American&quot;); b
Figure:-

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)

435 Matches the follow ing Component from Figure 1 Y1 U 2 fig(a)-TextField,fig(b)-Button,fig(c)-Labe


Figure:- checkbox,fig(g)-Choice
436 Modification of the text can be controlled by 1 N U 2 setEditable()

437 Multiple layouts in the single conainer can be created w ith the help of 1 N U 2 Panel
_______________

438 No of constructors of JComboBox are______________ 1 N U 2 2

439 Observe the follow ing code import java.aw t.*; import javax.sw ing.*; /* 1 N A 2 The output is obtained in table w ith tw o
<applet code="JTableDemo.class" w idth=400 height=500> </applet> scrollbar
*/ public class JTableDemo extends JApplet { public void init() { Container
contentPane = getContentPane(); contentPane.setLayout(new Flow Layout()); final
String[] colHeads = { "Name", "Phone", "Fax"}; final Object[][] data = { {"Prashant",
"12345","6789"}, {"Rupesh", "12345", "23456"} }; JTable table = new JTable(data,
colHeads); int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_ALW AYS; int h =
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALW AYS; JScrollPane jsp = new
JScrollPane(table, v, h); contentPane.add(jsp, BorderLayout.CENTER); } }

440 Observe the follow ing code import java.aw t.*; import java.applet.*; import 1 N A 2 The output is obtained in Applet w ith Bo
java.util.*; /* <applet code="BorderLayoutDemo" w idth=400 height=200> est,north,south and TextArea at center
</applet> */ public class BorderLayoutDemo extends Applet { public void init() {
setLayout(new BorderLayout()); add(new Button("This is across the top."),
BorderLayout.NORTH); add(new Label("The footer message might go here."),
BorderLayout.SOUTH); add(new Button("Right"), BorderLayout.EAST); add(new
Button("Left"), BorderLayout.W EST); String msg = "The reasonable man adapts " +
"himself to the w orld;\n" + "the unreasonable one persists in " +
"trying to adapt the w orld to himself.\n" + "Therefore all progress depends " + "on
the unreasonable man.\n\n" + " - George Bernard Shaw \n\n"; add(new
TextArea(msg), BorderLayout.CENTER); } } W hat w ill be the output of the above
program?

441 Observe the follow ing code importjava.aw t.*; importjava.applet.*; public class LayoutD1 N A 2 The output is obtained in Applet w ith tw

Observe the follow ing code import java.aw t.*; import java.applet.*; /*

442 <APPLET Code="TextFieldPassw ord" W idth=500 Height=200> 1 N A 2 The output is obtained in Applet w ith tw
</APPLET> */ public class TextFieldPassw ord extends Applet { public void init() {
Label lblName = new Label("enter name"); Label lblPassw d
= new Label("enter passw ord"); TextField txtName = new TextField("your name
here", 20); TextField txtPassw d = new TextField(20); add(lblName); add(txtName);
add(lblPassw d); txtPassw d.setEchoChar('*'); add(txtPassw d); } }
443 Observe the follow ing program and point out w hich statement contains error. 1 N A 2 Error in statement in w hich JScrollPane
importjava.aw t.*; importjavax.sw ing.*; /* <applet code="JTableDemo" w idth=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"
}, { "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); } }

444 Observe the image show n below . S1Q42 W hich AW T component w ill the image as 1 Y1 A 2 CheckboxGroup
show n
Figure:-

445 Picture is a ________________ Figure:- 1 Y1 U 2 CheckboxMenuItem

446 Point out missing w ord in syntax in given code import java.aw t.*; import java.aw t.eve1 N U 2 new
447 Positions the components into five regions:east, w est, north, south, center 1 N U 2 BorderLayout

448 Say that a Frame contains three Panels. Could each Panel have a different layout manag1 N U 2 Yes---each one can use setLayout() w ith

449 select correct code for display given output 1 Y1 A 2 import java.aw t.*; imort java.applet.*;
Figure:- idth=200 height=300&gt;&lt;/applet&gt;
void init() { // setLayout(new Flow Layo
Button(&quot;Button &quot; + i)); } } }

450 Select correct statement to add component in south region. 1 N U 2 add(component obj,BorderLayout.SOUTH);

451 Select proper code for given image as shw on in below 1 Y1 A 2 import java.aw t.*; import java.applet.*;
Figure:- init() { Choice os=new Choice(); os.add(
os.add(&quot;w nn nt&quot;); os.add(&q
} /*&lt;applet code=&quot;choice11&quo
&lt;/applet&gt;*/

import java.aw t.*; import java.aw t.event.*; import javax.s

455 1 Y1 A 2 import java.aw t.*; import java.applet.*;


init() { CheckboxGroup cbg=new Check
Checkbox(&quot;Red&quot;,false,cbg); C
Checkbox(&quot;Green&quot;,false,cbg)
Checkbox(&quot;Blue&quot;,false,cbg);

456 Select the correct output of the follow ing program: import java.aw t.*; import java.app 1 Y2 A 2 .

457 Select the missing statement in given code import java.aw t.*; import java.applet.*; 1 N U 2 JTable it=new JTable(data,s);
import javax.sw ing.*; public class table extends JApplet
{ public void init() { String s[]={"srno","name","rollno"}; Object data[]
[]={{"1","abc","01"},{"2","xyz","0"}}; int
v=JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED; int
h=JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED; JScrollPane p=new
JScrollPane(it,v,h); Container co=getContentPane(); co.add(p,BorderLayout.CENTER);
} } /*<applet code=table w idth=300 height=300></applet>*/
458 select the missing statement in the follow ing code import java.aw t.Flow Layout; public1 N A 2 import javax.sw ing.*;

459 Select the missing statement in the follow ing program for follow ing output import 1 Y1 A 2 nw .add(nw 1);
java.aw t.*; public class MenuTest extends Frame { MenuTest(String title) {
super(title); MenuBar mb=new MenuBar(); Menu file=new Menu("File"); Menu
edit=new Menu("Edit"); Menu view =new Menu("View "); MenuItem nw =new
MenuItem("New "); MenuItem open=new MenuItem("Open"); MenuItem nw 1=new
MenuItem("Blank document"); file.add(nw ); file.add(open); mb.add(file);
mb.add(edit); mb.add(view ); setMenuBar(mb); } public static void main(String
arg[]) { MenuTest obj=new MenuTest("My Frame"); obj.setSize(200,400);
obj.setVisible(true); }}
Figure:-

460 Select the missing statement in the program for follow ing output import java.aw t.*; pu1 N A 2 mbr.add(view menu);

461 Select the missing statement in the program to get the follow ing output import 1 N U 2 city = new Choice();
java.aw t.*; import java.aw t.event.*; import java.applet.*; /* <applet
code="ChoiceDemo" w idth=300 height=180>
</applet> */ public class ChoiceDemo extends Applet implements ItemListener {
Choice city; public void init() { city.add("Nagpur"); city.add("Mumbai");
city.add("Pune"); city.add("Nashik"); add(city); city.addItemListener(this); } public
void itemStateChanged(ItemEvent ie) { repaint(); } public void paint(Graphics g) {
String msg = "Select city: "; msg += city.getSelectedItem(); g.draw String(msg, 6,
120); } }
462 Select the missing statements in the program to get follow ing output: import 1 Y1 A 2 CheckboxMenuItem bold = new Checkbo
java.aw t.*; class Sample extends Frame { Sample(String title) { super(title); CheckboxMenuItem italic = new Checkbo
MenuBar mbar = new MenuBar(); setMenuBar(mbar); CheckboxMenuItem under = new Checkb
Menu font = new Menu("Font"); font.add(bold);font.add(italic);font.add(under); CheckboxMenuItem strike = new Checkb
font.add(strike); mbar.add(font); Menu para = new Menu("Paragraph");
mbar.add(para); Menu styles = new Menu("Styles"); mbar.add(styles);
setSize(400,400); setVisible(true); } public static void main(String args[]) { new
Sample("Menu Example"); } }
Figure:-

463 Select the proper code for follow ing output? Figure:- 1 Y1 A 2 import java.aw t.*; import java.applet.*;
idth=200 height=80&gt; &lt;/applet&gt;
{ Label jlb1=new Label(&quot; Enter Num
Choice ch=new Choice();

464 Select the proper command to run the follow ing code import java.aw t.*; import java.a 1 N A 2 appletview er textdemo25 .java

465 Select the proper command to run the follow ing code import java.aw t.*; import 1 N A 2 appletview er combodemo.java
java.aw t.event.*; import javax.sw ing.*; import java.applet.*; /* <applet
code="combodemo" w idth=300 height=100>
</applet> */ public class combodemo extends JApplet { public void init() { Container
co = getContentPane(); co.setLayout(new Flow Layout()); JComboBoxjc=new
JComboBox(); jc.addItem("pen"); jc.addItem("pencil"); jc.addItem("eraser");
jc.addItem("sharpner"); co.add(jc); } }

466 Select the proper command to run the follow ing code import java.aw t.*; import 1 N A 2 Javac combodemo11.java &amp; appletv
java.aw t.event.*; import javax.sw ing.*; import java.applet.*; /* <applet
code="combodemo11" w idth=300 height=100> </applet> */ public class
combodemo11 extends JApplet
{ public void init() { Container co = getContentPane(); co.setLayout(new Flow
Layout()); JComboBoxjc=new JComboBox(); jc.addItem("cricket");
jc.addItem("football"); jc.addItem("hockey"); jc.addItem("tennis"); co.add(jc); } }

467 Select the proper command to run the follow ing code import java.aw t.*; import 1 N A 2 appletview er combodemo11.java
java.aw t.event.*; import javax.sw ing.*; import java.applet.*; 90 /* <applet
code="combodemo11" w idth=300 height=100> </applet> */ public class
combodemo11 extends JApplet
{ public void init() { Container co = getContentPane(); co.setLayout(new Flow
Layout()); JComboBoxjc=new JComboBox(); jc.addItem("cricket");
jc.addItem("football"); jc.addItem("hockey"); jc.addItem("tennis"); co.add(jc); }
Select the proper command to run the follow ing code import java.aw t.*; import java.a

468 public mymenu(String title) { super(title); file.add(fnew ); file.add(fopen); file.add(fsa1 N A 2 java mymenu

469 Select the proper command to run the follow ing code import java.aw t.*; import 1 N A 2 appletview er tabbeddemo.java
javax.sw ing.*; public class tabbeddemo extends JApplet { public void init() {
Container ContentPane=getContentPane(); JTabbedPane jt=new JTabbedPane();
jt.addTab("City",new CityPanel()); jt.addTab("Color",new ColorPanel());
jt.addTab("Flavours",new FlavoursPanel()); getContentPane().add(jt); } } class
CityPanel extends JPanel { public CityPanel() { JButton b1=new JButton("Kolhapur");
add(b1); JButton b2=new JButton("Pune"); add(b2); JButton b3=new
JButton("Mumbai"); add(b3); JButton b4=new JButton("Sangali"); add(b4); } } class
ColorPanel extends JPanel { public ColorPanel() { JRadioButton rb1=new
JRadioButton("Red"); add(rb1); JRadioButton rb2=new JRadioButton("Green");
add(rb2); JRadioButton rb3=new JRadioButton("Blue"); add(rb3); JRadioButton
rb4=new
JRadioButton("Pink"); add(rb4); } } class FlavoursPanel extends JPanel
{ public FlavoursPanel() { JComboBox jc=new JComboBox(); jc.addItem("Vanilla");
jc.addItem("Chocalate"); jc.addItem("Straberry"); add(jc); } } /*<applet
code="tabbeddemo.class" w idth=500 height=500> </applet>*/

470 Select the proper command to run the follow ing code import javax.aw t.* import 1 N A 2 appletview er JListDemo.java
javax.sw ing.*; public class JListDemo extends JApplet { JTextField t1; JList jl; String
data[ ]={“Red”, “Green”, “Blue”, “Yellow ”, “Pink”}; Public void init() { Container
cp=getContentPane(); cp.setLayout(new Flow Layout()); T1=new JList(data);
cp.add(jl); cp.add(t1); } } /*<applet code=”JListDemo” w idth=300 height=300>
</applet>*/

471 Select the proper command to run the follow ing code import java.aw t.*; import 1 N A 2 appletview er TextFieldDemo.java
java.applet.*; /* <applet code="TextFieldDemo" w idth=380 height=150> </applet>
*/ public class TextFieldDemo extends Applet { TextField name, pass; public void
init() { Label namep
= new Label("Name: ", Label.RIGHT); Label passp = new Label("Passw ord: ",
Label.RIGHT); name = new TextField(12); pass = new TextField(8);
pass.setEchoChar('?'); add(namep); add(name); add(passp); add(pass); } public void
paint(Graphics g) { } }

Select the proper command to run the follow ing code /*<applet code=frameinapp w idt
472 java.aw t.*; import java.aw t.event.*; import java.applet.*; class framein extends Fram1 N A 2 Appletview er frameinapp.java

473 Select the proper output for follow ing code import java.aw t.*; import java.applet.*; 1 Y2 A 2 S1Q42O2
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"); b5=new Button("Center"); add(b1,BorderLayout.NORTH);
add(b2,BorderLayout.EAST); add(b3,BorderLayout.SOUTH); add(b4,BorderLayout.W
EST); add(b5,BorderLayout.CENTER); } } /*
<applet code="DemoBorderLayout.class" w idth=350 height=300>
</applet>*/

474 Select the suitable statement for given output 1 Y1 U 2 Buttons,Flow Laout.RIGHT
Figure:-

475 setEnabled(false); method used in menubar for 1 N U 2 Used to disable menu


_______________________

476 Show a single line of code that w ill convert char ch into String s 1 N A 2 String s=””+ch;

477 Show the output of follow ing code. import javax.sw ing.*; public class Test { public sta 1 N A 2 true,false

State the method that w ill be used so as to display the passw ord as '?' in the output
show n in S1Q43
Figure:-

478 1 Y1 A 2 setEchoChar('?')
479 state the output and assume suitable data import java.aw t.*; import java.applet.*; clas1 N U 2 label of c2 w ill print

480 State true of false. i) AW T is an extended version of sw ing ii) Paint( ) of 1 N U 2 i-false, ii-false
Applet class cannot be overridden

481 Steps for Adding TabbedPane Control 1 N U 2 1. Create a JTabbedPane object 2. Call a
Step 2 for each Tab 4. Add the Tabbed P

482 Suppose a Panel is added to a Frame and a Button is added to the Panel. If the Frame's 1 N U 2 10-point TimesRoman

483 Sw ing components are light w eight because: 1 N A 2 Sw ing components are platform independent.

484 Sw ing provides a combo box (a combination of a text field and a drop- dow n list) 1 N U 2 Jcomponent
through the JComboBox class, w hich extends
__________________.

485 Tabbedpane Layout can be changed using: 1 N U 2 Mentioning layout in constructor only.

486 The code Code w ill produce how many buttons: public class JScrollPaneDemo extends 1 N A 2 400 Buttons
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
< 20; i++) { for(int j = 0; j < 20; j++) { jp.add(new JButton("Button " + 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 Flow Layout is….. 1 N U 2 5 Pixel

The follow ing constructors are required in the program to get output
Figure:-

489 1 Y1 U 2 Cellphones=new List(4,true) Companies=new List(4,false)

490 The follow ing is an example of w hich layout? Figure:- 1 Y1 U 2 BorderLayout


491 The follw ow ing is an example of w hich layout? Figure:- 1 Y1 U 2 CardLayout

492 The JComboBox is having follow ing constructor 1 N U 2 JComboBox(Vector v)

493 The layout manger that show s how w ords flow in a text editor?Use 1 N U 2 Flow

494 The main difference betw een model and models dialog box is 1 N U 2 W hen box is active input focus can not be directed to anoth

495 The method _______ assigns the name Result to the Text of variable jlbl. 1 N A 2 jlbl.setText(&quot;Result&quot;)

496 The method __________ separates menu items in a menu mu. 1 N A 2 mu.addSeparator()

497 To construct a text area that is 80 character-w idths w ide and 10 1 N U 2 new TextArea(10, 80)

character-heights tall, select appropriate code.


498 To creat panel of borderlayout use_________ 1 N A 2 Jpanel p=new Jpanel(new BorderLayout())

499 To create a compact,multiple-choice,scrolling selection list,Use? 1 N U 2 List

500 To create group of check boxes ,Use? 1 N U 2 CheckBoxGroup

501 To get the depth of a JTree jTree, invoke ________________ 1 N A 2 jTree.getRoot().getDepth()

502 To implement a single –line text area entry area, Use? 1 N A 2 TextField

503 To place any component in AW T/Sw ing w hich method w ill be used 1 N U 2 setBounds(int x,int y,int height,int w idth)

504 To position components in an applet w indow ? Use 1 N U 2 Layout Mangager


505 To produce follow ing output in given program w hich statement should be placed to 1 Y1 A 2 if(ie.getItemSelectable()==r) cp.setBack
change the background color of applet import javax.sw ing.*; import java.aw t.*; if(ie.getItemSelectable()==g) cp.setBack
import java.aw t.event.*; /* <applet code=JRadioButtonDemo.class w idth=500 if(ie.getItemSelectable()==b) cp.setBack
height=500> </applet> */ public class JRadioButtonDemo extends JApplet
implements ItemListener { JRadioButton r,g,b; ButtonGroup bg; Container cp; public
void init() { r=new JRadioButton("RED"); g=new JRadioButton("GREEN"); b=new
JRadioButton("BLUE"); cp= getContentPane(); cp.setLayout(new Flow Layout());
cp.add(r); cp.add(g); cp.add(b); bg=new ButtonGroup(); bg.add(r); bg.add(g);
bg.add(b); r.addItemListener(this); g.addItemListener(this); b.addItemListener(this);
} public void itemStateChanged(ItemEvent ie)
{ ...........................................................................
..........................................................................
....................................................................... } } Figure:-

506 To set new font object w ith size 48 , name: Serif , Style PLAIN, w hat w ill be the 1 Y1 U 2 new Font(&quot;Serif&quot;, Font.PLAIN
statement from the follow ing
Figure:-

507 To set passw ord as '******' w hich command should be added in the follow ing code im1 N A 2 psw .setEchoChar('*');
508 W hat AW T classes (components) w ill be needed to get follow ing output? 1 Y1 U 2 Label,Checkbox,checkboxGroup,Flow Lay
Figure:-

W hat code should be added so that w e can get follow ing Code? import java.aw t.*;
import java.applet.*; import java.aw t.event.*; /*<applet code=SignIn.class w
idth=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();

509 if(msg.equals("Admin")&&msg1.equals("Admin")) { l.setText("Correct 1 Y1 A 2 Both A &amp; B


Passw ord"); } else { l.setText("Incorrect Passw ord"); } } } } Figure:-

510 W hat code should be added so that w e can get follow ing Code? import java.aw t.*; 1 Y1 A 2 setLayout(new Flow Layout());
import java.aw t.event.*; class W indow CloseDemo extends Frame { Button exit; W
indow CloseDemo() { exit=new Button("Exit"); add(exit); W indow Close w =new W
indow Close(); addW indow Listener(w ); setTitle("W indow "); setSize(400,300);
setVisible(true); } public static void main(String []cd) { W indow CloseDemo w
cd=new W indow CloseDemo(); } } class W indow Close extends W indow Adapter {
public void w indow Closing(W indow Event w e) { System.exit(1); } }
Figure:-

511 W hat code w ould you use to construct a 24-point bold Calibri font? 1 N U 2 new Font(&quot;Calibri&quot;, Font.BOLD,24);
512 W hat Component w ill be displayed in output of Follow ing Code import java.aw t.*; im 1 N A 2 TextBox and Button

513 W hat component w ill be needed to get follow ing output? Figure:- 1 Y1 U 2 D) JPanel, JTextField, JScrollPane and C

514 W hat components w ill be needed to get follow ing output? Figure:- 1 Y1 U 2 Applet, TabbedPane, ComboBox

515 W hat components w ill be needed to get follow ing output? Figure:- 1 Y1 U 2 Button,Checkbox,RadioButton
W hat components w ill be needed to get follow ing output? Figure:-

516 1 Y1 U 2 Frame, MenuBar, Menu, CheckboxMenuIt

517 W hat components w ill be needed to get follow ing output? Figure:- 1 Y1 A 2 Icon, Button, Panel, Frame

518 W hat components w ill be needed to get follow ing output? Figure:- 1 Y1 U 2 JApplet, JCheckBox, JComboBox, Jbutton

519 W hat components w ill be needed to get follow ing output? Figure:- 1 Y1 U 2 JPassw ordField,JComboBox,ToolTipText,
520 W hat components w ill be needed to get follow ing output? Figure:- 1 Y1 U 2 Jtable, JScrollPane

521 W hat components w ill be needed to get follow ing output? Figure:- 1 Y1 U 2 Label , Button, ComboBox

522 W hat components w ill be needed to get follow ing output? Figure:- 1 Y1 U 2 Label, Choice
523 W hat components w ill be needed to get follow ing output? Figure:- 1 Y1 U 2 Label,textfield,Button

524 W hat components w ill be needed to get follow ing output? Figure:- 1 Y1 U 2 TextField , Label , Button

525 W hat correction is required in the follow ing program to get output? import java.aw t.*;1 N A 2 JComboBox jc=new JComboBox() ;

W hat Correction should be done in the follow ing program to get the proper output? /*

526 ColorsPanel()); getContentPane().add(jtp); } } class CitiesPanel extends JPanel { public1 N A 2 Missing package sentences
527 W hat is output of follw ing programmissing statement? import java.aw t.*; import 1 Y1 A 2 Buttons are displayed in 3 row s and 3 co
javax.sw ing.*; public class MyGridLayout{ JFrame f; MyGridLayout(){ f=new
JFrame(); JButton b1=new JButton("1"); JButton b2=new JButton("2"); JButton
b3=new JButton("3"); JButton b4=new JButton("4"); JButton b5=new JButton("5");
JButton b6=new JButton("6"); JButton b7=new JButton("7"); JButton b8=new
JButton("8"); JButton b9=new JButton("9");
f.add(b1);f.add(b2);f.add(b3);f.add(b4);f.add(b5);
f.add(b6);f.add(b7);f.add(b8);f.add(b9); f.setLayout(new GridLayout(3,3));
f.setSize(300,300); f.setVisible(true); } public static void main(String[] args) { new
MyGridLayout(); } }
Figure:-

528 W hat is an event in delegation event model used by Java programming language? 1 N U 2 An event is an object that describes a sta

529 W hat is mising statement in follow ing code? import 1 N U 2 Both a &amp; b
java.aw t.Container; import java.aw t.Font; import java.aw t.GridLayout; import
javax.sw ing.JButton; import javax.sw ing.JFrame; public class GridSizeTest extends
JFrame { public static void main(String[] args) { GridSizeTest gst = new
GridSizeTest(); gst.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); gst.pack(); }
public GridSizeTest() { Container pane = getContentPane(); pane.setLayout(new
GridLayout(2, 2)); JButton button = new JButton("First"); pane.add(button); button =
new JButton("Hi"); button.setFont(new Font("Courier", Font.PLAIN, 36));
pane.add(button); button = new JButton("There"); } }

530 W hat is output of follow ing program? import javax.sw ing.*; import java.aw t.event.*; 1 Y2 A 2

New Roman",Font.BOLD,20)); lblPass.setFont(new Font("Times New


Roman",Font.BOLD,20)); txtName.setFont(new Font("Times New
Roman",Font.BOLD,20)); txtPass.setFont(new Font("Times New
Roman",Font.BOLD,20)); add(lblName); add(lblPass); add(txtName);
add(txtPass); btnOk=new JButton("Ok"); btnOk.setFont(new
Font("Times New Roman",Font.BOLD,20));
btnOk.setBounds(100,160,80,50); add(btnOk);
lblPass.setForeground(new Color(0,255,0));
lblName.setForeground(new Color(0,255,0)); } public static void
main(String args[]) { new Login().setVisible(true); } }

531 W hat is Purpose of Jtree ? 1 N U 2 A tree is a component that presents a hierarchical view of data

532 W hat is purpose of default constructor of Scrollbar( ) class? 1 N U 2 To create vertical Scrollbar

533 w hat is Runnable from follow ing? 1 N U 2 interface


W hat is the code for follow ing output S1Q27.jpg
Figure:-
537 W hat is the effect of issuing a w ait() method on an object ? 1 N A 2 The object issuing the call to w ait() w ill

538 W hat is the layout of the given output 1 Y1 U 2 Flow Layout


Figure:-

539 W hat is the length of the application box made by this program? import java.aw t.*; 1 N A 2 Compilation Error
import java.applet.*; public class myapplet extends Applet
{ Graphic g; g.draw String("A Simple Applet", 20, 20); }

540 W hat is the output of follow ing program: import java.aw t.*; import java.aw 1 N A 2 doesn't show frame
t.event.*; import java.applet.*; public class app3 extends Frame { public static void
main(String m[]) { Frame f=new Frame("BUTTON FRAME"); Button b=new
Button("save"); f.add(b); f.setSize(100,200); f.setLayout(new Flow Layout());
f.setVisible(false);
}}

541 W hat is the output of the follow ing code: import java.aw t.*; import java.applet.*; 1 Y2 A 2 A
/* <applet code="GridLayoutDemo" w idth=300 height=200> </applet> */ public
class GridLayoutDemo extends Applet
{ int n = 4; public void init() { setLayout(new GridLayout(n,n,10,10)); for(int i = 0; i
<n; i++) { for(int j = 0; j <n; j++) { add(new Button("k")); } } } }

542 W hat is the output of this program? Figure:- 1 Y1 A 2 Tw o coincided lines


543 W hat is the output of this program? Figure:- 1 Y1 A 2 W ill display list

544 W hat is the output of this program? Figure:- 1 Y1 A 2 w ill not display any output

545 W hat is the purpose of follow ing code? JTextField jtf=new 1 N U 2 Defining Textfield
JTextField(15)

546 W hat is the purpose of JTabbedPane? 1 N U 2 JTabbedPane manages a set of components of linking them

547 W hat is the purpose of ScrollPane 1 N U 2 ScrollPane Displays component in a rectangular area

548 W hat is the purpose of TextArea 1 N U 2 To handle multiline text input

549 W hat is the purpose of ToggleButton? 1 N U 2 On or Off Sw itch

W hat is the result of executing the follow ing Java class: import java
.aw t.*; 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 [] { n

W hat is the use of panel in the program given below import java.aw t.*; import java.ap

c.addItemListener(new ItemListener(){

563 W hat w ill be the order of four items added Choice c1 = new Choice(); c1.add("First"); 1 N U 2 First,Second,Lastadded,Third
564 W hen the size of componant is change___________event is generated. 1 N A 2 ComponantEvent

565 W hen there is a sw itching condition like on or off, w hich control is used of follow ing? 1 N U 2 toggle button

566 W hen w e create a Dialog box using the Constructor Dialog (Frame f,true) the dialog bo1 N U 2 Modal

567 W hen w e invoke repaint() for a java.aw t.Component object, the AW T 1 N U 2 update()
invokes the method:

568 W here g is a graphics instance w hat w ill the follow ing code draw on the screengfillArc1 N A 2 An arc bounded by a box of height 50, w

569 W here the panel add on frame? import java.aw t.*; public class CompLay extends Fram1 N A 2 A.On left side of Frame

570 W hether the code is correct to generate the given output? /*<applet 1 Y1 A 2 Yes
code="MyJRadioButton" w idth=900 height=900> </applet>*/ import java.aw t.*;
import javax.sw ing.*; public class MyJRadioButton extends JApplet { public void
init() { Container c=getContentPane(); c.setLayout(new Flow Layout()); JRadioButton
r1=new JRadioButton("A"); c.add(r1); JRadioButton r2=new JRadioButton("B");
c.add(r2); JRadioButton r3=new JRadioButton("C"); c.add(r3); add(r1); add(r2);
add(r3); } }
Figure:-

571 w hich abstract class is the super class of all menu related classes? 1 N U 2 MenuComponent

572 W hich among the below is not the method applicable for Button in sw ing 1 N U 2 setDisableIcon()

573 W hich among the follow ing is not correct regarding dialog? 1 N U 2 Use of Dialog effects the w orking of Application

574 W hich among the follow ing is the feature of Jtable 1 N U 2 all of these

575 W hich are the valid w ays to create DataInputStream streams? 1 N A 2 new DataInputStream(new FileInputStream(&quot;in.dat&q

576 W hich are true about the Container class? 1 N U 2 All of the above

577 w hich AW T complonents are used to produce given output? 1 N U 2 Button, Label, TextField, TextArea
578 W hich AW T control is uesd to produce given output 1 Y1 U 2 GridLayout, Label, TextField, Button
Figure:-

579 W hich checkbox w ill be selected in the follow ing code ( Assume w ith main and added 1 N U 2 cb3

580 W hich class can be used to represent a checkbox w ith a textual label that can appear i 1 N U 2 Checkbox MenuItem

581 w hich class provides method for accessing a font's properties? 1 N U 2 FontMerices

582 W hich classes are used to generate follow ing output as show n in figure. 1 Y1 U 2 Both options i and iii correct.
Figure:-
583 W hich code is correct to generate the follow ing output? Figure:- 1 Y1 A 2 a) Scrollbar vert = new Scrollbar(Scrollb
Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0,

584 W hich code w ill produce the out show n in figure 1 Y1 U 2 f=new Font(&quot;Times New Roman&qu
Figure:- new font setForeground(Color.red);

585 W hich componenet is needed to get the follow ing output? Figure:- 1 Y1 U 2 JScrollPane,Icon
586 W hich Componenets and layout manager are used in follow ing output 1 Y1 U 2 Buttons,Borderlayout
Figure:-

587 W hich Component are present in follow ing image 1 Y1 U 2 JButton, JLabel, JTable, JProgressBar
Figure:-

588 W hich component is display area for a short string of text, image or both? 1 N U 2 Jlabel

589 W hich component represents the hierarchical view of data 1 N U 2 Jtree

W hich component required to get folow ing output


Figure:-

590 1 Y1 U 2 Label,TextArea,Button

591 W hich Component subclass is used for draw ing and painting? 1 N U 2 Canvas
592 W hich components are needed to get above show n output 1 Y1 U 2 List, Button
Figure:-

593 W hich components are needed to get below show n output? Figure:- 1 Y1 U 2 JComboBox, Button

W hich components are needed to get below show n output? Figure:-

594 1 Y1 A 2 Button, Textfield,List


595 W hich components are needed to get below show n output? Figure:- 1 Y1 A 2 Choice, Button

596 W hich components are needed to get below show n output? Figure:- 1 Y1 A 2 Label,Choice

W hich components are required to display follow ing output? Figure:-

597 1 Y1 U 2 Frame, Label, CheckboxGroup, Button


598 W hich components are required to get follow ing output? Figure:- 1 Y1 U 2 Applet, Choice, Button, Label, List

599 W hich components are reuired to get follow ing output (S1Q28) Figure:- 1 Y1 U 2 List and Button

w hich components are used in follow ing diagram


Figure:-

600 1 Y1 U 2 JRadioButton,JTextField
601 W hich components are used in follow ing output 1 Y1 U 2 Label,TextArea,Button
Figure:-

602 W hich Components are used in Follow ing output? Figure:- 1 Y1 U 2 JRadioButton ,JTextField

W hich components are used in the follow ing output? Figure:-

603 1 Y1 U 2 Applet,Label,TextField,Button

604 W hich components are used in the follow ing output? Figure:- 1 Y1 U 2 Checkbox,Label
605 W hich components are used in the follow ing output? Figure:- 1 Y1 U 2 JButton,JTextField

W hich components are used in the follow ing output? Figure:-

606 1 Y1 U 2 Label, Button, TextField

607 W hich components are used in the follow ing output? Figure:- 1 Y1 U 2 Label, TextField, Button
608 W hich components are used in the follow ing output? Figure:- 1 Y1 U 2 Label, TextField, Button

609 W hich components are used in the follow ing output? Figure:- 1 Y1 U 2 Label,TextField,Button

610 W hich components are used in the follow ing output? Figure:- 1 Y1 U 2 Label,TextField,Button
611 W hich components are used in the follow ing output? Figure:- 1 Y1 U 2 Scrollbar, Label, Choice

W hich components are used in this code? import javax.sw ing.*; import java.aw t.*; 1 N U 2 Button and ImageIcon
public class Iconbutton{ public static void main(String[] args){ JFrame frame = new
JFrame("Icon on button"); JButton button
= new JButton("JAVA"); Icon imgicon = new ImageIcon("java.gif");

612 JPanel panel = new JPanel(); button.setIcon(imgicon); panel.add(button); frame.add(pa

613 W hich components are used to devlope follow in w indow 1 Y1 U 2 Label, TextField, Button
Figure:-

614 W hich Components need to be used to produce this output 1 Y1 A 2 JtabbedPane,JLabel and ImageIcon
Figure:-

615 W hich components provide support for tw o-state buttons? 1 N U 2 JCheckBox, JRadioButton

616 W hich constructor creates a TextArea w ith 10 row s and 20 columns? 1 N U 2 new TextArea(10, 20);
617 W hich constructor w as correct to get output 1 Y1 U 2 Jtable(2,3)
Figure:-

618 W hich control is a combination of text field and dropdow n list? 1 N U 2 combo boxes

619 W hich Gridlayout class constructor creates single column grid Layout? 1 N U 2 GridLayout()

620 W hich is componant in AW T w hich contain another componant? 1 N U 2 Container


621 w hich is correct code for follow ing image 1 Y1 A 2 import java.aw t.*; import java.applet.*;
Figure:-

622 W hich is the layout manger that occupies the same size on the w indow ? 1 N A 2 Grid

623 W hich is the correct code for the follow ing output 1 Y1 A 2 import java.aw t.*; import java.applet.*;
Figure:- void init() { Button b1=new Butto
b2=new Button(&quot;Cancel&quot;);
Flow Layout(Flow Layout.RIGHT); se

624 W hich Label defines the constructor? 1 N U 2 all of above


625 W hich layout example is this? Figure:- 1 Y1 U 2 Flow Layout

W hich Layout is used in follow ing o/p

626 Figure:- 1 Y1 U 2 GridBagLayout

627 W hich layout is used in the follow ing output? Figure:- 1 Y1 U 2 BorderLayout

628 W hich Layout is used to obtain the follow ing output 1 Y1 U 2 GridLayout
Figure:-
629 W hich layout manager can be used to get the follow ing output? Figure:- 1 Y1 U 2 BorderLayout

630 W hich layout manager can be used to get the follow ing output? Figure:- 1 Y1 U 2 GridLayout

631 W hich layout manager is show n in the output? Figure:- 1 Y1 U 2 GridLayout

632 W hich Layout Manager places compenent inone of the five region 1 N A 2 BorderLayout
NORTH,SOUTH,W EST,EAST,CENTER.

633 W hich method executes only once? 1 N U 2 init()

634 W hich method is incorrect w hile creating menubar 1 N U 2 MenuItem.add(MenuItem)

635 W hich method is used to display title on titlebar of Frame? 1 N U 2 setTitle(String title)

636 W hich method is used to processes mouse click? 1 N U 2 MouseClicked()


637 W hich method is used to translate a mouse click on a specific point of the tree to a tree1 N U 2 getPathForLocation()

638 W hich method of Graphics class is to display "HelloW orld" on the 1 Y1 U 2 draw String(&quot;HelloW orld&quot;,30
Applet show n in figure. Figure:-

639 W hich method of the component class is used to set the position and the size of a comp1 N U 2 setBounds()

640 W hich method show s the complete process in percent on the progress bar? 1 N U 2 setStringPainted(boolean)

641 W hich method specifies that the text and icon are horizontally aligned to the right in th 1 N U 2 jbt.setHorizontalTextPosition(JButton.RIG

642 W hich methods are used to draw the follow ing output? Figure:- 1 Y1 U 2 a)draw Polygon(),fillPolygon()

643 W hich of follow ing is true? 1 N U 2 All the methods in the JButton class are

644 W hich of the follow ing applet tags is legal to embed an applet class named Test into a 1 N A 2 B.&lt;applet code = Test. Class w idth =

W hich of the follow ing are container classes? Figure:-

645 1 Y1 U 2 Frame and Panel

646 W hich of the follow ing commands w ill set a layout manager that divides the container 1 N U 2 setLayout( new GridLayout(4, 3) )

647 W hich of the follow ing constructor creates a Checkbox? 1 N U 2 Checkbox(String str, boolean s, null)
648 W hich of the follow ing create a list w ith five visible items and multiple selection enabl 1 N U 2 new List(5,true)

649 W hich of the follow ing creates a List w ith 3 visible items and multiple mode selection 1 N U 2 new List(3,false)

650 W hich of the follow ing is not a AW T control 1 N U 2 Panel

651 W hich of the follow ing is not a constructor of FileDialog? 1 N U 2 FileDialog()

652 W hich of the follow ing is not a constructor of Jtree? 1 N U 2 JTree(int x)

653 W hich of the follow ing layout mangers honours the preferred size of component( Multip1 N U 2 Flow Layout

654 W hich of the follow ing method adds item "I" to the List w ith deprecation w arnings at 1 N U 2 addItem(“I”)

655 W hich of the follow ing method use to check w hether the JCheckBox jchk is selected? 1 N U 2 jchk.isSelected()

656 W hich of the follow ing method use to get the text or caption of the button jbt? 1 N U 2 jbt.getText()

657 W hich of the follow ing methods can be used to change the size of a java.aw t.Compone1 N A 2 (B) &amp; (E)

658 W hich of the follow ing methods can be used to change the size of a java.aw t.Compone1 N U 2 setSize()

659 W hich of the follow ing methods create a LineBorder? 1 N U 2 B AND C

660 W hich of the follow ing options is correct about Layout Manager 1 N U 2 Both B and C

661 W hich of the follow ing statement is for placing the frames upper left corner to (200,10 1 N A 2 frame.setLocation(200,100)

W hich of the follow ing statement is used to create GridLayout in the output show n
below ?
Figure:-

662 1 Y1 U 2 GridLayout g=new GridLayout(3,2);

663 W hich of the follow ing statements are true i) Scrollbar is a component but not a Conta1 N U 2 i and ii both are true

664 W hich of the follow ing statements are true? 1 N A 2 ALL

665 W hich of the follw ing is true about Flow Layout 1 N U 2 both A and B

666 W hich of these classes can be added to any Container class, using the add method defin1 N U 2 Button

667 W hich of these events w ill be notified if scroll bar is manipulated? 1 N U 2 AdjustmentEvent

668 W hich of these is not a constructor of the FileDialog? 1 N U 2 FileDialog(Frame parent,int how )

669 W hich of these methods are used to register a keyboard event listener? 1 N U 2 addKeyListener()

670 W hich of these methods can be used to determine the type of event? 1 N U 2 getID()

671 W hich of these methods can be used to know w hich key is pressed 1 N U 2 getModifier()

672 W hich of these methods returns the class of the object? 1 N U 2 getClass()

673 W hich one is not the Layout Manager 1 N A 2 setLayout


674 W hich one is the constructor of the Jtable? 1 N U 2 JTable(Object data[ ][ ], Object colHeads[ ])

675 W hich option is correct to adding Jtree in an Applet? 1 N U 2 Create a Jtree Object, Create a JScrollPa
Add the scroll pane to the content pane o

676 w hich package contains color class? 1 N U 2 java.aw t

677 W hich package is used to add progress bar in an application? 1 N U 2 javax.sw ing.JProgrssBar

678 W hich part of program Below w ill show an error: import java.aw t.*; import java.aaple 1 N A 2 super();

w hich statement is required for follow ing output? import java.aw t.*; import
java.applet.*; public class TextArea_Demo extends Applet { TextArea ta1; public
void init() { ta1=new TextArea("My name Is troy",25,25); ta1.append(" name is
khan "); } }
Figure:-

679 1 Y1 A 2 add(ta1)

680 W hich Statement is required to obtain given output by using follow ing code public 1 Y1 A 2 setLayout(new Flow Layout());
class fldemo extends Frame{ fldemo() { Button b1=new Button("Save"); Label
l1=new Label("Name"); TextField t1=new TextField(10); add(l1); add(t1); add(b1);
//Statement required here setSize(new Dimension(500,500)); setTitle("Flow
Layout"); setVisible(true); } public static void main(String arg[]) { fldemo f=new
fldemo(); } }
Figure:-

681 W hich statement should be added to display button. import java.aw t.*; import javax.s 1 N A 2 contentPane.add(jb);
W hich statements are missing in follow ing program to get the output
as show n in fig /*<applet code=GridBagDemo w idth=300 height=300>
</applet>*/ import java.aw t.*; import java.applet.*; public class GridBagDemo
extends Applet { GridBagLayout gdb=new GridBagLayout(); GridBagConstraints c
______________________________: Button b1=new Button("One"); Button b2=new
Button("Tw o"); Button b3=new Button("Three"); Button b4=new Button("Four");
Button b5=new Button("Five"); public void init() { __________________
c.gridx=0;c.gridy=0;c.w eightx=0.5; c.w eighty=0.5; gdb.setConstraints(b1,c);
c.gridx=1;c.gridy=0; gdb.setConstraints(b2,c); c.gridx=2;c.gridy=0;
gdb.setConstraints(b3,c); c.gridx=0;c.gridy=1; c.gridw idth=3; c.ipady=20;
c.fill=GridBagConstraints.BOTH; gdb.setConstraints(b4,c);

682 c.gridx=0;c.gridy=3; c.ipady=0; c.insets=new Insets(20,20,20,20); 1 Y1 A 2 both a&amp; b


c.fill=GridBagConstraints.NONE; c.anchor=GridBagConstraints.PAGE_START;
c.fill=GridBagConstraints.HORIZONTAL; gdb.setConstraints(b5,c);
add(b1);add(b2);add(b3);add(b4);add(b5); } }
Figure:-

683 W hich statements are missing in the given code below . import java.aw t.*: Import 1 N A 2 t= new TextArea ( 5,20);
java.aw t.event.*; Importjava. Applet.*; public class Pral extends Applet implements
ActionListener { String s; Label a ; Button b; TextArea t; public void init () { a = nw
Label ( Enter Address: ",LabelLEFT); b = new Button ("OK"); add (a); add(t ); add
(b); b.addActionListener(this); } public void actionPerformed (ActionEventae) { if
(ae.getSource()==b) { repaint(); } } public void paint ( Graphics gr ) {
s=t.getText(0); gr.draw String ("User Address is : " +s,150,150); } } /*<applet code
= Pral w idth = 400 height = 300 >
</applet>*/

684 W hich statements is missing in the given code below . import java.aw t.*; import 1 N A 2 ButtonGroup bg= new ButtonGroup()
java.aw t. Event.*; import javax.sw ing.*; /*<applet code = Colur w idth = 500
height = 500 ></applet>*/ public class Colur extends J Applet implements
ActionListener { Container cp = getContentPane (); public void init () { cp.setLayout
(new Flow Layout()); JRadioButton b1= new JRadioButton("Red");
b1.addActionListener(this); cp.add(b1); JRadioButton b2 = new
JRadioButton("Green"); b2.addActionListener(this); cp.add(b2);
JRadioButton("Green"); b3.addActionListener(this); cp.add(b3); }
public void action Performed(ActionEvent ae ) { String S; s= ae.getActionCommand();
if (s=="Red") cp.setBackground(Color.red); else if (if s=="Green")
cp.setBackground(Color.green); else if (s=="Blue") cp.setBackground (Color.blue.); }
}

685 W hich statements is missing in the given code below . import javax.sw ing.*; public 1 N A 2 f.SetVisible(true);
class FirstSw ingExample { public static void main ( String [] args) { Jframe f =new
Jframe();//creating instance of Jframe Jbutton b = new Jbutton ("click") ;// creating
instance of Jbutton b. setBounds( 130,100,100,40);//x axis ,y axis , w idth,height f.
add(b);//adding button in JFrame f.seSize(400,500);//400 w idth and
500 height f.setLayout (null);//using no layout manager }}

W hich statemnet is missing w here ******* is marked to produce given output


public class login extends JApplet { JTextField t1,t2; JLabel l1,l2; JButton b1,b2;
public void init() { Container CP=getContentPane(); CP.setLayout(new
GridLayout(3,2)); t1=new JTextField(15); t2=new JTextField(15); l1=new
JLabel("Name :: ");
******** b1=new JButton("Login"); b2=new JButton("Cancel");
//Adding the controls to the content pane CP.add(l1);CP.add(t1);
686 CP.add(l2);CP.add(t2); CP.add(b1);CP.add(b2); } } Figure:- 1 Y1 A 2 l2=new JLabel(&quot;Passw ord :: &quot

687 W hich statemnet is missing in follow ing code w hich w ill generate given output:: 1 Y1 A 2 MenuBar mbar=new MenuBar();
public class MenuDemo extends Frame { public static void main(String args[]) {
MenuDemo m=new MenuDemo(); m.setTitle("Menu Demo"); m.setVisible(true);
m.setSize(300,200);
********** //Setting the menu bar m.setMenuBar(mbar); //Creating menus Menu
format=new Menu("Format"); Menu Tool =new Menu("Tool"); Menu Help=new
Menu("Help"); //Creating menu items MenuItem
item1,item2,item3,item4,item5,item6; format.add(item1=new MenuItem("Font"));
format.add(item2=new MenuItem("Bullets")); format.add(item3=new
MenuItem("Paragraph")); Tool.add(item4=new MenuItem("Spelling and Grammar"));
Tool.add(item5=new MenuItem("W ord Count")); Help.add(item6=new
MenuItem("Help Topics")); //Adding menus to the menu bar mbar.add(format);
mbar.add(Tool); mbar.add(Help); } }
Figure:-

688 W hich sw ing component is show n in output? Figure:- 1 Y1 U 2 c)Jtree

W hich sw ing components use ListSelectionModel 1 N U 2 Jlist and Jtable


689

690 W hich w ill be correct line of code at line no 16 1. Application level 2. Import java.aw 1 N A 2 Container contentPane=getContentPane(
t.*; 3. Import javax.sw ing.*; 4. /* 5. <applet code=”JTextField1” w idth=300
height=50> 6. </applet> 7. */ 8. Public class JTextField 1 extends JApplet 9. { 10.
JTextField jtf; 11. Public void init() 12. { 13. JTextField jtf; 14. Public void init() 15. {
16. …………………
17. contentPane.setLayout(new Flow Layout()); 18. jtf=new
JTextField(15); 19. contentPane.add(jtf); 20. } 21. }

691 W hy w e need to w rite static keyw ord to main method ? 1 N U 2 To create single copy
692 W rite a java program for follow ing Output? Figure:- 1 Y1 A 2 import java.aw t.*; public class Butt exte
{ Butt MyBut=new Butt(); } Butt() { se
Layout(Flow Layout.CENTER)); Button He
ByeBut=new Button(&quot;Bye&quot;);
setSize(300,300); setVisible(true); } }

693 w rite the command to compile the follow ing code import java.aw t.*; import java.apple1 N A 2 javac Paneldemo.java

694 W rite the missing code? import javax.sw ing.*; public class Radio { JFrame f; 1 N A 2 f.add(r1); f.add(r2);
Radio(){ f=new JFrame(); JRadioButton r1=new JRadioButton("A) Male");
JRadioButton r2=new JRadioButton("B) FeMale"); r1.setBounds(50,100,70,30);
r2.setBounds(50,150,70,30); ButtonGroup bg=new ButtonGroup();
bg.add(r1);bg.add(r2); ------------
---------------------- ----------------------------- f.setSize(300,300); f.setLayout(null);
f.setVisible(true); } public static void main(String[] args) { new Radio(); } }

695 W rite the sequence of component to be added on applet ? import java.aw t.*; import ja1 N U 2 Label, TextField, TextField, Label, Button

add(t1); t2=new TextField(10); add(t2); add(l2); add(b1); } }


696 You can create a JTable using __________ 1 N U 2 All Above

697 you can use methods___________________on any instance of java.aw t.Component 1 N U 2 setBackground

698 ______is a platform dependant. 1 N U 2 AW T

699 _______method to specify the text for a standard tooltip. 1 N U 2 setToolTipText()

700 _________ are the properties in JTable. 1 N U 2 All Above

701 __________ is a Sw ing layout manager that arranges components in a row & a column1 N U 2 BoxLayout

702 __________ is a w idget that displays progress of a lengthy task, for instance file dow n1 N U 2 Progressbar

703 ___________ is a Sw ing layout manager that arranges components on top of each oth1 N A 2 CardLayout

704 ______________ displays a message that alerts the user and w aits for the user to click1 N A 2 Message dialog box

705 ___________________ is not a constructor of JTree class 1 N U 2 JTree(Button b[])


706 ___________________is a superclass of TextField and TextArea classes that is used to1 N A 2 TextComponent

C opyright © 2014 - 2015. All rights reserved.

Maharashtra State Board of Technical Education


(A utonomous) (ISO 9001:2008) (ISO/IEC 27001:2005)

Welcome M2001 [117.239.186.68]

My Home Log Out

e-Exam Manage Questions for Advanced Java Programming (17625) for topic 2 Go Back to Subjects

Q No Question To pi Fig urQ Type Mar ksA

1 ----------------------Is super class of all the events 2 N R 1 EventObject

2 1. W hich of these packages contains all the classes and methods required for even handling in 2 N R 1 java.aw t.event
Java?

3 2. W hich of these events is generated w hen the a w indow is closed? 2 N R 1 W indow Event

4 3 ________method are used to register a keyboard event listener 2 N R 1 addKeyListener()

5 3. W hich of these methods can be used to know the degree of adjustment made by the user? 2 N R 1 getValue()

6 A MenuItem object can generate __________ events. 2 N R 1 ActionEvent

7 A source generates an event and sends it to ___________ listeners that can handle the event 2 N R 1 One or more

8 A ________________ is an object that is notified w hen an event occurs 2 N R 1 Listener

9 A ________________________ is generated w hen a component is added to or removed from a container. 2 N R 1 ContainerEvent

10 ActionEvent Class is used for W hich Controll ? 2 N R 1 Button , List ,MenuItem

11 Adapter class belongs to the package 2 N R 1 java.aw t.event

12 Adapter Class provides_____________________________ 2 N R 1 Empty implementation of all metho

13 An event is generated w hen the internal state of the event source is ___________. 2 N R 1 Changed

14 An object that w ould like to be notified of and respond to an event is 2 N R 1 EventListener

15 At the root of the Java event class hierarchy is ___________w hich is the superclass for all events. 2 N R 1 EventObject

16 Change in the state of an object is know n as __________ 2 N R 1 Event

17 CheckBox implements follow ing Listener Interface 2 N R 1 ItemListener

18 ComponenetEvent is the superclass of _______________. 2 N R 1 All of the above

19 Event class is defined in w hich of these libraries? 2 N R 1 java.aw t.event

20 Event Listeners are____________________________________ 2 N R 1 Interfaces

21 EventObject class present in__________package. 2 N R 1 java.util

22 EventObject contains tw o important methods:________ and___________ 2 N R 1 getSource() and toString()

23 Events are supported by the _____________ 2 N R 1 java.aw t.event

24 Focus events are fired w henever a component _____________________the focus 2 N R 1 gains or loses

25 FocusEvent is subclass of w hich of these calsses ? 2 N R 1 ComponenEvent

26 Generated w hen a w indow is activated, de-activated, closed, de-activated,de-iconified, iconified, opened or qu 2 N R 1 W indow Event

27 getID() method is provided by __________ class. 2 N R 1 AW TEvent


28 getKeyChar( ) and getkeyCode( ) methods belongs to w hich event class? 2 N R 1 KeyEvent

29 getSource() is method of w hich class 2 N R 1 EventObject

30 How many types of component events are in Java? 2 N R 1 4

31 How to obtain the command name for invoking ActionEvent? 2 N R 1 Using getActionCommand( ) metho
32 How to remove the event listener? 2 N R 1 Using removeTypeListener( ) meth

33 If a class extends the ActionListener interface, it must contain a method called. __________. 2 N R 1 actionPerformed()

34 If scroll bar is manipulated………….. event w ill be notified. 2 N R 1 AdjustmentEvent

35 If w e close an applet’s w indow _________ event w ill be generated. 2 N R 1 W indow Event

36 If _____________is manipulated AdjustmentEvent event w ill be notified . 2 N R 1 ScrollBar

37 In EventObject, w hich method is used to determine the type of event? 2 N R 1 getSource()

38 In java an event is an _________ w hich specifies the change of state in the source. 2 N R 1 Object

39 In Java, events are all the activities that occur betw een 2 N R 1 A and B

40 In w hich package class AW TEvent defined 2 N R 1 java.aw t package;

41 In w hich package the methods for receiving and processing events are defined 2 N R 1 java.aw t.event

42 In w hich places can put the event handling code 2 N R 1 All mentioned above

43 Interface used to handle menu events is 2 N R 1 ActionListner

44 ItemListener event defines this method… 2 N R 1 itemStateChanged()

45 KeyEvent is a subclass of ________ 2 N R 1 InputEvent

46 KeyListener interface has got _______________methods 2 N R 1 3

47 mouseDragged() method present in w hich listener 2 N R 1 MouseMotionListener

48 MouseEvent is subclass of w hich of these classes? 2 N R 1 InputEvent

49 Name the event that gets generated w hen a button is clicked. 2 N R 1 ActionEvent

50 Name the method defined in EventObject class that returns the Object generated from the event.select the one 2 N R 1 getSource()

51 On w hich aw t component event listener can not be aplied 2 N R 1 Label

52 public void mouseMoved(MouseEvent me) is method of _______________ 2 N R 1 MouseMotionListener

53 Scrollbar control generates ……………………………. Event. 2 N R 1 AdjustmentEvent

54 Select the proper constructor of EventObject class 2 N R 1 EventObject(Object src)

55 Some of the event listener interfaces are_____________ 2 N R 1 All of these

56 Source object can register only one listener 2 N R 1 False

57 Text changed ( ) method is used for______. 2 N R 1 w hen there is changes in text occu

58 TextEvent defines the follow ing integer constatnt: 2 N R 1 TEXT_VALUE_CHANGED

59 TextField generates w hich events 2 N R 1 ActionEvent,TextEvent

60 The constructor w hich the Text Event class defines. 2 N R 1 TextEvent(Object source, int event

61 The default layout of the contentPane of a JApplet is __________. 2 N R 1 BorderLayout

62 The delegation Event model is based on the concept of 2 N R 1 Both A and B


63 The delegation model is used as a standard for 2 N R 1 Event Listeneing

64 The Follow ing are event classes 2 N R 1 Action Event,FocusEvent ,Containe

65 The Follow ing are method of mouse event class 2 N R 1 getClickCount ( )

66 The follow ing method is an abstract method of TextListener interface. 2 N R 1 textChanged(TextEvent obj)

67 The follow ing method must be overriden in order to handle KeyEvent. 2 N R 1 All of the mentioned

68 The method in the ActionEvent ________ returns the action command of the button 2 N R 1 getActionCommand()

69 The method that is used for registering keyboard event is know s as ____________________. 2 N R 1 addKeyListener ()

70 The MouseEvent class does not defines the _____________integer constant. 2 N R 1 MOUSE_W HEELMOVE

71 The MouseListener interface is used to make mouse handling 2 N R 1 True

72 The MouseListener's _______________ method is called after mouse button is released 2 N R 1 public void mouseClicked(MouseEv

73 The MouseMotionListener Interface has __________________ method. 2 N R 1 void mouseDragged(MouseEvent

74 The signature for the registration method for an ActionEvent should be 2 N R 1 public void addActionListener(Actio

75 The superclass of ContainerEvent, FocusEvent and W indow Event is _______________ . 2 N R 1 ComponentEvent

76 The ________ interface is used to handle button events: 2 N R 1 ActionListener


77 The ___________ interface handles list events: 2 N R 1 ItemListener,ActionListener

78 The __________________interface handles choice events. 2 N R 1 ItemListener

79 Till now tw o models have been introduced in java for: 2 N R 1 Receiving and processing events

80 To w rite event driven programs using AW T or Sw ings, Use? 2 N R 1 Option A and B

81 W hat is a listener in context to event handling? 2 N R 1 A listener is a object that is notifie

82 W hat is a listener in the context to event handling? 2 N R 1 A listener is an object that notified

83 W hat is an event in Delegation Event model ? 2 N R 1 An event is an object that describe

84 W hat is event handling? 2 N R 1 Controling Event

85 W hat is use of MouseMotion Listener Interface? 2 N R 1 mouseDragged()

86 W hat kind of event is fired w hen the user selects an item from a menu? 2 N R 1 an ActionEvent

87 W hen a component obtains keyboard focus, w hich method is invoked? 2 N R 1 void focusGained(FocusEvent fe)

88 W hen component is added or a removed from container,…………… generated? 2 N R 1 ContainerEvent

89 W hen key is pressed w hich event is occurred 2 N R 1 Both A and B

90 W hen list item is double clicked, w hich event is generated? 2 N R 1 ActionEvent

91 W hen the size of component is changed ,----------------------- event is generated 2 N R 1 ComponentEvent

92 W hen tw o or more objects are added as listeners for the same event, w hich listener is first invoked to handle 2 N R 1 There is no w ay to

93 w hen w e need to use check boxes or item from the list or use a checkable menu,an 2 N R 1 ItemEvent
_________________is generated.

94 W hich of the follow ing are true 2 N R 1 The event - inherita

95 W hich among the follow ing is not an AW T Event 2 N R 1 AdjustEvent

96 W hich among the follow ing is true for Adaptor Classes? 2 N R 1 Adaptor classes reduce Complexit

97 W hich are various methods of W indow Listener interface from follow ing? 2 N R 1 All above

98 W hich are W indow Event class defines integer constants ? 2 N R 1 All The Above

99 W hich class is at the root in Java event class hierarchy? 2 N R 1 EventObject

100 W hich class is used for this Processing Method processActionEvent( )? 2 N R 1 Button,List,MenuItem

101 W hich event is generated by List 2 N R 1 Both A and B

102 W hich Event is generated by Scrollbar class? 2 N R 1 AdjustmentEvent

103 W hich is a method of the MouseMotionListener Interface? 2 N R 1 public void mouseDragged(MouseE

104 W hich is not the correct listener 2 N R 1 TextAreaListener

105 W hich is the interface of MouseEvent class ? 2 N R 1 MouseListener

106 W hich Listener handles all List related Events 2 N R 1 ItemListener

107 W hich method does display the message w henever there is an item selection or deselection of the CheckboxMe2 N R 1 itemStateChanged

108 W hich method is applicable if alphanumeric key is pressed. 2 N R 1 keyTyped

109 W hich method is defined w hen action event is occurs? 2 N R 1 actionPerformed()

110 W hich Method Is used to register a mouse Motion Listner 2 N R 1 addMouseMotionListener()

111 W hich method used for return for mouse co-ordinate ? 2 N R 1 getX () ,getY()

112 W hich methods are defined by ComponentListener 2 N R 1 void componentHidden(Componen

113 W hich of the follow ing are correct event handling methods 2 N R 1 mousePressed(MouseEvent e){}

114 W hich of the follow ing are true? 2 N R 1 Both A and B

115 W hich of the follow ing componant generate ActionEvent? 2 N R 1 none

116 W hich of the follow ing component can generate ItemEvent? 2 N R 1 CheckBoxMenuItem

117 W hich of the follow ing is not event class is Java? 2 N R 1 ClickEvent

118 W hich of the follow ing is the highest class in the event delegation class hierarchy? 2 N R 1 java.util.EventObject

119 W hich of the follow ing is the legal adapter classes in java. 2 N R 1 MouseAdapter
120 W hich of the follow ing Listeners have their Adapter class 2 N R 1 W indow Listener

121 W hich of the follow ing method is used to register a listener to a button ? 2 N R 1 addActionListener(ActionListener o

122 W hich of these event is generated w hen a button is pressed? 2 N R 1 ActionEvent

123 W hich of these methods can be used to obtain the command name for invoking ActionEvent object? 2 N R 1 getActionCommand

124 W hich of these a AdapterClass 2 N R 1 KeyAdapter class

125 W hich of these adapter class from follw ing? 2 N R 1 MouseAdapter

126 W hich of these are constants defined in W indow Event class 2 N R 1 All the Above

127 W hich of these constant value w ill change w hen the button at the end of scroll bar w as clicked to increase its2 N R 1 UNIT_INCREMENT

128 W hich of these event is generated w hen computer gains or loses input focus? 2 N R 1 FocusEvent

129 w hich of these event w ill be notified if scrollbar is manipulated? 2 N R 1 AdjustmentEvent()

130 W hich of these events is generated w hen a w indow is minimized? 2 N R 1 Both a and b

131 W hich of these events is generated w hen the component is added or removed? 2 N R 1 ContainerEvent
132 W hich of these events w ill be generated if w e close an Frame's w indow ? 2 N R 1 W indow Event

133 W hich of these interfaces define a method actionPerformed()? 2 N R 1 ActionListener

134 W hich of these is super class of W indow Event class? 2 N R 1 ComponentEvent

135 W hich of these is superclass of all Adapter classes? 2 N R 1 Applet

136 W hich of these methods are used to determine the type of adjustment event? 2 N R 1 getAdjustmentType()

137 W hich of these methods are used to register a mouse motion listener? 2 N R 1 addMouseMotionListener().

138 W hich of these methods can be used to know the degree of adjustment made by the user? 2 N R 1 getValue()

139 W hich of these methods is defined in MouseMotionAdapter class? 2 N R 1 mouseDragged()

140 W hich of these methods is used to get x coordinate of the mouse 2 N R 1 getX()

141 W hich of these methods is used to get Y coordinate of the mouse? 2 N R 1 getY()

142 W hich of these methods is used to know the full URL of an URL object? 2 N R 1 getHOst()

143 W hich of these methods is used to obtain the object that generated a ComponentEvent. 2 N R 1 getContainer()

144 W hich of these methods is used to obtain the object that generated a W indow Event? 2 N R 1 getW indow ()

145 W hich of these methods w ill be invoked if a character is generated? 2 N R 1 keyTyped()

146 W hich of these methods w ill respond w hen you click any button by mouse? 2 N R 1 All of the mentioned

147 W hich of these methods w ill respond w hen you click any button by mouse? 2 N R 1 All of these

148 W hich of these not a constants defined in ComponentEvent class? 2 N R 1 COMPONENT_SIZED

149 W hich tw o parameters are required for JTable constructor to create a table? 2 N R 1 Data array and Column Headings

150 w indow Event is a subclass of ________________________ 2 N R 1 ComponentEvent()

151 _______ generates action events w hen an item is double-clicked. 2 N R 1 List

152 __________is generated w hen checkbox is clicked, list item is clicked, choice selection is made or checkable m2 N R 1 ItemEvent

153 ___________class provides an empty implementation of all methods in an Event Listener interface? 2 N R 1 Adapter

154 _________________generates an event and sends it to one or more listeners. 2 N R 1 Event Source

155 ActionEvent: It indicates the component-defined events occurred b)MouseEvent: Events generated during the m2 Y2 U 2 All a,b,c and d are
156 For the follow ing code select the method that can be used to handle event. importjava.aw t.event.*; import 2 N A 2 itemStateChanged(
java.aw t.*; importjava.applet.*; public class checkbackg extends Applet implements ItemListener {
Checkbox m1,m2,m3; public void init() { m1=new Checkbox("A"); m2=new Checkbox("B"); m3=new
Checkbox("C"); add(m1); add(m2); add(m3); m1.addItemListener(this); m2.addItemListener(this); } public
void
__________________(ItemEvent ie) { if(ie.getSource()==m1) setBackground(Color.red);
if(ie.getSource()==m2) setBackground(Color.green); } } /*<applet code=checkbackg.class height=150 w
idth=150> </applet>*/

157 1)For Key events, KeyEvent class is used 2)For Mouse motion events, MouseEvent class is used 2 N A 2 1,2,3 are true
3)For For Component events, CoumponentEvent class is used 4)For W indow events, W indow E
class is used

1. W hat w ill be the output of the follow ing code? import java.aw t.*; import java.applet.*; import

158 java.aw t.event.*; public class adm extends Applet { public void init() { addMouseMotionListener(new 2 Y2 U 2 S1-chapter2(Q1.C).
mma1(this)); } } class mma1 extends MouseAdapter { adm a; public mma1(adm a) { this.a=a; } public void
mouseDragged(MouseEvent me) { a.show Status("mouse dragged"); } } /*<applet code="adm" w idth=500
height=500>
</applet>*/

159 1.W hich line of code is missing in follow ing code and error statement code line import java.aw t.*; 2 N A 2 KeyListener and pu
import java.aw t.event.*; import java.applet.*; /*<applet code="KeyEventDemo.class" w idth=400 show Status(&quot;
height=400> </applet>*/ public class KeyEventDemo extends Applet implements
_____________ { String msg=""; public void init() { addKeyListener(this); } public void
keyPressed(KeyEvent e) { show Status("Key Dow n"); int key=e.getKeyCode(); repaint(); } public void
keyTyped(KeyEvent e) { msg+=e.getKeyChar(); repaint(); } public void paint(Graphics g) { g.draw
String(msg,10,20); } }

160 4. W hat w ill happen w hen you attempt to compile and run the follow ing code? import java.aw t.*; import jav 2 N A 2 Error not override M

161 5. W hich statement is incorrect or missing in the follow ing code import java.aw t.*; import java.aw t.event*; i 2 N A 2 Container c=getCon

162 A Frame's background color is set to Color.Yellow , and a Button's background color is to Color.Blue. Suppose th 2 N A 2 Color.Yellow .

163 A Java exception is an instance of __________. 2 N U 2 Throw able

164 Abstract Methods of MouseMotion Listener Interface. 2 N A 2 mouseMoved(MouseEvent) mouse

165 Action event is applied on 2 N U 2 Button, TextField, List, Menu

166 Adapter classes are similar to EventListener interfaces? 2 N A 2 True

167 Add the missing statement.. import java.aw t.*; import java.aw t.event.*; import java.applet.*; /* 2 N A 2 no=new Button(&q
<applet code="ButtonDemo" w idth=250 height=150> </applet> */ public class ButtonDemo extends Applet
implements ActionListener { String msg = ""; Button yes, no, maybe; public void init() { yes = new
Button("Yes"); maybe = new Button("Undecided"); add(yes); add(no); add(maybe);
yes.addActionListener(this); no.addActionListener(this); maybe.addActionListener(this); } public void
actionPerformed(ActionEvent ae) { String str = ae.getActionCommand(); if(str.equals("Yes")) { msg = "You
pressed Yes."; } else if(str.equals("No")) { msg = "You pressed No."; } else { msg = "You pressed
Undecided."; } repaint(); } public void paint(Graphics g) { g.draw String(msg, 6, 100); } }

168 After inserting w hich statement in follow ing program, output w indow w ill be closed w hen close button is 2 N A 2 addW indow Listene
clicked import java.aw t.event.*; import java.aw t.*; class Demo extends Frame { Demo() {
setSize(500,500); setVisible(true); setTitle("My W indow "); } public static void main(String args[]) { new
Demo(); } } class AdapterDemo extends W indow Adapter { Demo d1;
AdapterDemo(Demo d) { d1=d; } public void w indow Closing(W indow Event w e) { d1.dispose(); }
}

169 An event adapter can be implemented using ___________. 2 N U 2 All of Above

170 An event is generated w hen internal stae of event source is________ 2 N A 2 changed

Analyse the follow ing code and Find out errors. import java.aw t.*; import java.applet.*; import java.aw t.even
171 Select Color:"); Choice ch=new Choice(); ch.addItem("Red"); ch.addItem("Green"); ch.addItem("Blue"); TextFi 2 N A 2 Error is in the statement String s=

172 Analyse the follow ing code and find out missing statement. import javax.sw ing.*; import javax.sw 2 N A 2 missing package st
ing.tree.*; public class TreeDemo extends JFrame { public static void main(String args[])
{ TreeDemo frame = new TreeDemo(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root"); DefaultMutableTreeNode mercury =
new DefaultMutableTreeNode("Mercury"); root.add(mercury); DefaultMutableTreeNode venus = new
DefaultMutableTreeNode("Venus"); root.add(venus); DefaultMutableTreeNode mars = new
DefaultMutableTreeNode("Mars"); root.add(mars); JTree tree = new JTree(root); JScrollPane scrollPane = new
JScrollPane(tree); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150);
frame.setVisible(true); } }

173 Analyse the follow ing code and select missing statement. import java.aw t.*; import java.applet.*; /*<applet c2 N A 2 All of the above

174 Analyze the follow ing code import javax.sw ing.*; import javax.sw ing.border.*; import java.aw t.*; public clas2 N A 2 Tw o buttons displa

175 Analyze the follow ing code: import javax.sw ing.*; import java.aw t.*; public class Test extends JFrame { publ 2 N U 2 Four buttons are di

176 ButtonGroup bg = new ButtonGroup(); is used to create group of 2 N A 2 RadioButton


_________________________

177 Choose correct fig. as ouput for given code import java.aw t.*; import java.applet.*; import java.aw 2 Y2 A 2
t.event.*; public class addition2 extends Applet implements ActionListener { TextField t1; TextField t2;
TextField t3; Button b; {Label num1=new Label ("Addition of tw o numbers"); Label num2=new Label("Enter
First no in text field"); Label num3=new Label("Enter Second no in text field"); t1=new TextField(); t2=new
TextField(); t3=new TextField(); b=new Button("add"); setLayout(new GridLayout(4,2)); add(num1);
add(t1); add(num2); add(t2); add(num3); add(t3); add(b); b.addActionListener(this); } public void
actionPerformed(ActionEvent ae)
{if(ae.getSource()==b) { int n1=Integer.parseInt(t2.getText()); int n2=Integer.parseInt(t3.getText()); int
sum=n1+n2; t1.setText(Integer.toString(sum)); } } } /*
<applet code="addition1" height=200 w idth=300> </applet>*/

178 Choose the correct missing statement from the given code import java.aw t.*; import java.applet.*; import java2 N A 2 b1.addActionListene

Choose the correct option for the given code import java.aw t.*; import java.aw t.event.*; import java.applet.*; The program w ill d

Complete remaining code for getting output as show n in figure. import java.aw t.*; import
java.aw t.event.*; import javax.sw ing.*; /*<applet code="jcombodemo" w idth=300 height=100>
</applet>*/ public class jcombodemo extends JApplet implements ItemListener { JLabel jl;
ImageIcon green, red, black, yellow ; public void init() { Container cp = getContentPane();
JComboBox jc = new JComboBox(); jc.addItem("Creek"); jc.addItem("Dock");
jc.addItem("Forest"); jc.addItemListener(this); cp.add(jc); jl = new JLabel(new
ImageIcon("Creek.jpg")); cp.add(jl); } Figure:-
190 Component listener can not be applicable to 2 N U 2 Frame, Label

191 Consider follow ing code and state how many keyevent generated by this program import java.aw t.event.*; 2 N A 2 3
import javax.sw ing.*; /* <applet code="KeyDemo.class " w idth=300 height=300> </applet> */ public
class KeyDemo extends JApplet implements KeyListener { String msg=""; int x=10,y=20; public void init() {
addKeyListener(this); requestFocus(); } public void keyPressed(KeyEvent ke) { show Status("Key Dow n"); }
public void keyTyped(KeyEvent ke)
{ msg+=ke.getKeyChar(); repaint(); } public void keyReleased(KeyEvent ke) { show Status("Key up"); }
public void paint(Graphics g) { g.draw String(msg,x,y); } }

192 Consider follow ing output. Find missing statement from follow ing code. import java.aw t.*; import 2 Y1 A 2 D. Missing{}
java.applet.*; import java.aw t.event.*; public class keyEp extends Applet implements KeyListener { String
msg=" "; int x=10, y=20; public void init() { addKeyListener(this); } public void keyPressed(KeyEvent k) {
show Status("key pressed"); int kl=k.getKeyCode(); sw itch(kl) { case KeyEvent.VK_LEFT: msg+="<left
arrow >"; break; case KeyEvent.VK_RIGHT: msg+="<right arrow >"; break; } repaint(); } public void
keyReleased(KeyEvent k) { show Status("key up"); } public void keyTyped(KeyEvent l) public void
paint(Graphics g) { g.draw String(msg,x,y); } }
Figure:-

193 Consider the follow ing code and identify the error. import java.aw t.*; import javax.sw ing.*; 2 N A 2 Error in statement
import javax.sw ing.JScrollPane; /*<applet code=”JScrollPane1” w idth=150 height=150>
</applet> */ public class JSCrollPane1 extends JApplet { public void init() { Container cp=getContentPane();
contentPane.setLayout(new BorderLayout()); JPanel jp=new JPanel(); jp.setLayout(new GridLayout(10,10));
Char b=’A’; for(int i=0;i<5;i++) { for(int j=0;j<5;j++) { jp.add(new JButton(“Button”+b)); ++b; } } int
v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED; int h=
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED; JScrollPane jsp=new JScrollPane(v,h);
cp.add(jsp,BorderLayout.CENTER); } }

194 Consider the follow ing code. Event handling doesn't w ork on the button because of the follow ing reason: impo2 N A 2 The action listener

actionPerformed(ActionEvent e) { show Status("Event"); } }


195 Consider the follow ing code. Find the missing statement. public class MyClass extends Frame { public static voi2 N A 2 addW indow Listene
196 Consider the follow ing code.Select proper method to handle event. import java.applet.*; import java.aw t.*; 2 N U 2 keyTyped(KeyEven
import java.aw t.event.*; /* <applet code="AppletKeyListener.class" w idth="300" height="300"> </applet>
*/ public class AppletKeyListener extends Applet implements KeyListener { char ch; String str; public void
init() { addKeyListener(this); } public void keyPressed(KeyEvent e) { } public void keyReleased(KeyEvent e)
{ } public void
____________________________ { ch = e.getKeyChar(); if(ch == 'm'|| ch == 'M') str = "Good Morning";
else if(ch == 'a'||ch=='A') str = "Good Afternoon"; else if(ch == 'e'||ch=='E') str = "Good Evining"; else if(ch
== 'n'||ch=='N') str = "Good Night"; else str = "Type only other letter";
repaint(); } public void paint(Graphics g) { g.draw String(str, 100, 150); show Status("You typed "
+ ch + " character"); } }

197 Consider the follow ing code.w hat w ill be output of code? import java.applet.*; import java.aw t.*; import java2 Y2 A 2 All of these

198 Consider the follow ing output,Find the missing Statement in program import java.aw t.*; import 2 Y1 A 2 public void mouseR
java.applet.*; import java.aw t.event.*; public class MouseEvent1 extends Applet implements
MouseListener,MouseMotionListener { String msg=" "; int mx=0,my=0; public void init() {
addMouseListener(this); addMouseMotionListener(this); } public void mouseClicked(MouseEvent me) {
mx=0; my=10; msg="mouse clicked"; repaint(); } void mouseEntered(MouseEvent me) { mx=0; my=10;
msg="mouse entered"; repaint(); } public void mousePressed(MouseEvent me) { mx=me.getX();
my=me.getY(); msg="mouse pressed"; repaint(); } { mx=me.getX(); my=me.getY(); msg="mouse
Released"; repaint(); } public void mouseExited(MouseEvent me) { mx=0; my=10; msg="mouse Exited";
repaint(); } public void mouseDragged(MouseEvent me) { mx=me.getX(); my=me.getY(); msg="*"; show
Status("Dragging mouse at"+mx+","+my); repaint(); } public void mouseMoved(MouseEvent me) {
mx=me.getX(); my=me.getY(); show Status("moving mouse at"+mx+","+my); repaint(); } public void
paint(Graphics g) { g.draw String(msg,mx,my); } } /* <applet code=MouseEvent1.class height=400 w
idth=300>
</applet>*/ S1Q47.jpg
Figure:-

199 Consider the follow ing output. Find the missing statement in the program show n by 2 N A 2 public void keyPres
____________. import java.aw t.*; import java.aw t.event.*; import java.applet.*; import javax.sw ing.*; /*
<applet code="SimpleKey1" w idth=300 height=100> </applet> */ public class SimpleKey1 extends JApplet
implements KeyListener { String msg = ""; int X = 10, Y = 20; public void init() { addKeyListener(this);
requestFocus(); } ___________________ { show Status("Key Dow n"); } public void keyReleased(KeyEvent
ke) { show Status("Key Up"); public void keyTyped(KeyEvent ke) { msg += ke.getKeyChar(); repaint(); }
public void paint(Graphics g) { g.draw String(msg, X, Y); } }

200 Consider the follow ing output. Find the missing statement in the program. import java.aw t.*; import java.aw t2 N A 2 {
201 Consider the follow ing output. Find the missing statement in the program. import java.aw t.*; import java.aw 2 Y1 A 2 repaint();
t.event.*; import java.applet.*; import javax.sw ing.*; /* <applet code="SimpleKey1" w idth=300
height=100> </applet> */ public class SimpleKey1 extends JApplet implements KeyListener { String msg =
""; int X = 10, Y = 20; public void init() { addKeyListener(this); requestFocus(); } public void
keyPressed(KeyEvent ke) { show Status("Key Dow n"); } public void keyReleased(KeyEvent ke) { show
Status("Key Up"); } public void keyTyped(KeyEvent ke) { msg += ke.getKeyChar(); } public void
paint(Graphics g) { g.draw String(msg, X, Y); } }
Figure:-

202 Consider the follow ing output. Find the missing statement in the program. import java.aw t.*; import java.aw 2 Y1 A 2 }
t.event.*; import java.applet.*; import javax.sw ing.*; /* <applet code="SimpleKey1" w idth=300
height=100> </applet> */ public class SimpleKey1 extends JApplet implements KeyListener { String msg =
""; int X = 10, Y = 20; public void init() { addKeyListener(this); requestFocus(); } public void
keyPressed(KeyEvent ke) { show Status("Key Dow n"); } public void keyReleased(KeyEvent ke) { show
Status("Key Up"); public void keyTyped(KeyEvent ke) { msg += ke.getKeyChar(); repaint(); } public void
paint(Graphics g) { g.draw String(msg, X, Y); } }
Figure:-

Consider the follow ing output. Find the missing statement in the program. import java.aw t.*;
203 import java.aw t.event.*; import java.applet.*; import javax.sw ing.*; /* <applet code="SimpleKey1" w 2 Y1 A 2 All of the Above
idth=300 height=100> </applet> */ public class SimpleKey1 extends JApplet implements KeyListener {
String msg = ""; int X = 10, Y = 20; public void init() { addKeyListener(this); requestFocus(); } public void
paint(Graphics g) { g.draw String(msg, X, Y);
} } Figure:-

204 Consider the follow ing output. Find the missing statement in the program. import javax.sw ing.*; 2 N A 2 getContentPane().a
/* <applet code="JTabbedPaneDemo" w idth=400 height=100> </applet> */ public class JTabbedPaneDemo
extends JApplet { public void init() { JTabbedPane jtp = new JTabbedPane(); jtp.addTab("Cities", new
CitiesPanel()); jtp.addTab("Colors", new ColorsPanel()); jtp.addTab("Flavors", new FlavorsPanel()); } } class
CitiesPanel extends JPanel { public CitiesPanel() { JButton b1 = new JButton("New York"); add(b1); JButton
b2 = new JButton("London"); add(b2); JButton b3 = new JButton("Hong Kong"); add(b3); JButton b4 = new
JButton("Tokyo"); add(b4); } } class ColorsPanel extends JPanel { public ColorsPanel()
{JCheckBox cb1 = new JCheckBox("Red"); add(cb1); JCheckBox cb2 = new JCheckBox("Green");
add(cb2); JCheckBox cb3 = new JCheckBox("Blue"); add(cb3); } }
205 Consider the follow ing output. Find the missing statement in the program. import java.aw t.*; import java.aw 2 Y1 A 2 addKeyListener(this
t.event.*; import java.applet.*; /* <applet code="SimpleKey" w idth=300 height=100> </applet> */ public
class SimpleKey extends Applet implements KeyListener { String msg = ""; int X = 10, Y = 20; // output
coordinates public void init() { } public void keyPressed(KeyEvent ke) { show Status("Key Dow n"); } public
void keyReleased(KeyEvent ke) { show Status("Key Up"); } public void keyTyped(KeyEvent ke) { msg +=
ke.getKeyChar(); repaint(); } // Display keystrokes. public void paint(Graphics g) { g.draw String(msg, X, Y);
}}
Figure:-

Consider the follow ing output. Find the missing statement in the program. import java.aw t.Frame; import java

206 e.getX(); y = getY(); repaint(); } public void paint(Graphics g){ g.draw String(strEvent + " at " + x 2 Y1 A 2 all of the Above
+ "," + y, 50,50); } public static void main(String[] args) { HandleMouseListenerInW indow Example myW
indow = new HandleMouseListenerInW indow Example("W indow W ith Mouse Events Example"); } } class
MyW indow Adapter extends W indow Adapter{ HandleMouseListenerInW indow Example myW indow = null;
MyW indow Adapter(HandleMouseListenerInW indow Example myW indow ){ this.myW indow = myW indow ;
} public void w indow Closing(W indow Event w e){ myW indow .setVisible(false); }
Figure:-

207 Consider the follow ing program W hat correction should be done in the program to get correct output? import 2 N A 2 Missing }
java.applet.*; import java.aw t.event.*; /* <APPLET Code="SimpleKey" W idth=200 Height=250>
</APPLET> */ public class SimpleKey extends Applet implements KeyListener { String msg=""; int
X=10,Y=20; public void init() { addKeyListener(this); requestFocus(); } public void keyPressed(KeyEvent ke)
{ show Status("Key Dow n"); } public void keyReleased(KeyEvent ke) { show Status("Key Up"); } public void
keyTyped(KeyEvent ke) { msg
+=ke.getKeyChar(); repaint(); } public void paint (Graphics g) { }

208 Consider the follow ing program Find the error in program to get correct output. import java.applet.*; import jav2 N A 2 Error in mymouseli
209 Consider the follow ing program and find out the method w hich is w rong and correct it /*<applet 2 N A 2 The method public
code=TextAreaDemo w idth=300 height=300> </applet>*/ import java.aw t.*; import java.aw t.event.*; public void textCha
import java.applet.*; public class TextAreaDemo extends Applet implements FocusListener,TextListener {
TextArea text=new TextArea("AW T stands for Abstract W indow ToolKit"); TextField tf=new TextField();
public void init() { add(text); add(tf); text.addFocusListener(this); text.addTextListener(this); } public void
focusGained(FocusEvent e)
{ show Status("TextArea got focus"); } public void focusLost(FocusEvent e) { show Status("TextArea lost
focus"); } public void valueChanged(TextEvent e) { show Status("change in value of textarea"); } }

210 Consider the follow ing program and identify the missing statement. import java.applet.Applet; import java.aw t2 N A 2 None of the above.

show Status("Dragging mouse at " + mouseX + ", " + mouseY); repaint(); } public void mouseMoved(MouseEve

211 Consider the follow ing program. W hat should be the correction done in the program to get correct output? /* <2 N A 2 missing import stat

212 Consider the follow ing program. Choose the missing statements to get correct output. import java.aw t.*; impo2 N A 2 public class Sample
year.addItemListen
itemStateChanged(

213 Consider the follow ing program. Find w hich statement contains error. import java.aw t.*; import java.aw 2 N A 2 Applet Tag not decl
t.event.*; import java.applet.*; public class choicedemo1 extends Applet implements ItemListener { Choice
os,brow ser; String msg=""; public void init() { os=new Choice(); brow ser
=new Choice(); os.add("w indow s7"); os.add("w indow sXP"); os.add("w indow s8"); os.add("w indow s98");
brow ser.add("netscape 3.x"); brow ser.add("netscape 4.x"); brow ser.add("netscape 5.x"); brow
ser.add("netscape 6.x"); brow ser.add("Internet Explorer
4.0"); brow ser.add("Internet Explorer 5.0"); brow ser.add("Internet Explorer 6.0"); brow ser.add("Lynx
2.4"); brow ser.select("Netscape 4.x"); add(os); add(brow ser); os.addItemListener(this); brow
ser.addItemListener(this); } public void itemStateChanged(ItemEvent ie) { repaint(); } public void
paint(Graphics g) { msg="Current os"; msg+=os.getSelectedItem(); g.draw String(msg,6,120);
msg="Current brow ser"; msg+=brow ser.getSelectedItem(); g.draw String(msg,6,140); } }

214 Consider the follow ing program. Find w hich statement contains error. import java.applet.*; import java.aw t.* 2 N A 2 error in the stateme
called

215 Consider the follow ing program. Identify the missing statement from the output. import java.applet.*; /* 2 N A 2 }
<applet code="ChoiceDemo" w idth=300 height=180> </applet> */ public class ChoiceDemo extends Applet
implements ItemListener { Choice os, brow ser; String msg = ""; public void init() { os = new Choice(); brow
ser = new Choice(); // add items to os list os.add("W indow s XP"); os.add("W indow s Vista");
os.add("Solaris"); os.add("Mac OS"); // add items to brow ser list brow ser.add("Internet Explorer"); brow
ser.add("Firefox"); brow ser.add("Opera"); // add choice lists to w indow add(os); add(brow ser); // register
to receive item events os.addItemListener(this); brow ser.addItemListener(this); } public void
itemStateChanged(ItemEvent ie) { repaint(); } // Display current selections. public void paint(Graphics g) {
msg = "Current OS: "; msg += os.getSelectedItem(); g.draw String(msg, 6,
120); msg = "Current Brow ser: "; msg += brow ser.getSelectedItem(); g.draw String(msg, 6,
140); }

consider the follow ing program. Identify w hich are the event need to get the correct output import java.aw
t.*; import java.aw t.event.*; class AEvent extends Frame implements
____________ { TextField tf; AEvent(){ tf=new TextField(); tf.setBounds(60,50,170,20); Button b=new
Button("click me"); b.setBounds(100,120,80,30); b._______________(this); add(b);add(tf);
setSize(300,300); setLayout(null); setVisible(true); } public void
_________________(__________ e) { tf.setText("W elcome"); } public static void main(String args[]){ new
AEvent(); } }
Figure:-
216 2 Y1 A 2 ActionListener, add

217 Consider the follow ing program. W hat should be the correction done in the program to get colored button 2 N A 2 b1.setBackground(C
output?. import java.aw t.*; import java.applet.*; public class colordemo extends Applet { Button b1; Color c;
public void init() { c=new Color(255,0,0); setBackground(c); Button b1=new Button("Click");
b.setBackground(Color.yellow ); setForeground(Color.green); add(b1); }
} /*<applet code="colordemo" height=150 w idth=150> </applet>*/

218 Consider the follow ing program. W hat should be the correction done in the program to see output?. import 2 N A 2 add(txtpsw d);
java.aw t.*; import java.applet.*; import java.aw t.event.*; public class authenticateuser extends Applet
implements ActionListener { Label lblname,lblpsw d,lblmsg; TextField txtname,txtpsw d; Button b1; String
msg=""; public void init() { lblname= new Label("Enter username:"); lblpsw d= new Label("Enter psw d:");
lblmsg= new Label(""); txtname= new TextField(8); txtpsw d= new TextField(8); b1=new Button("Submit");
setLayout(new GridLayout(3,2)); add(lblname); add(txtname); add(lblpsw d); add(b1); add(lblmsg);
b1.addActionListener(this); } public void actionPerformed(ActionEvent e) { if (txtpsw
d.getText().equals("1234")) lblmsg.setText("Hello "+txtname.getText() ); else lblmsg.setText("Invalid user");
} } /*<applet code = authenticateuser height=200 w idth=200>
</applet>*/

219 Consider the follow ing program. W hat should be the correction done to get correct output? import java.aw 2 N A 2 import java.aw t.*;
t.*; import java.aw t.event.*; import java.applet.*; public class Sample extends Applet implements class Sample exten
ItemListener { Button red, green, blue; public void init() { red=new Button("Red"); green=new green, blue; public
Button("Green"); blue=new Button("Blue"); add(red); add(green); add(blue); red.addItemListener(this); green=new Button(
green.addItemListener(this); blue.addItemListener(this); Button(&quot;Blue&
} public void itemStateChanged(ItemEvent ie) { if(ie.getSource()==red) { setBackground(Color.red); }
if(ie.getSource()==green) { setBackground(Color.green); } if(ie.getSource()==blue) {
setBackground(Color.blue); } } }

220 Consider the follow ing program. W hat w ill be displayed in the output? import java.aw t.*; import java.aw 2 N A 2 compile error
t.event.*; import java.applet.*; /* <applet code="MouseEvents" w idth=300 height=100> </applet> */
public class MouseEvents extends Applet implements MouseListener, MouseMotionListener { String msg = "";
int mouseX = 0, mouseY = 0; // coordinates of mouse public void init() { addMouseListener(this);
addMouseMotionListener(this); } public void mouseClicked(MouseEvent me){ mouseX = 0; mouseY = 10;
msg = "Mouse clicked."; repaint(); }
public void mouseMoved(MouseEvent me) { show Status("Moving mouse at " + me.getX() + ", " +
me.getY()); } public void paint(Graphics g) { g.draw String(msg, mouseX, mouseY); } }

221 Consider the follow ing program.Find the listener implemented by applet. import java.aw t.*; 2 N A 2 Both B and C
import java.aw t.event.*; import java.applet.*; /* <applet code="Loan" w idth=200 height=300>
</applet> */ public class Loan extends Applet implements
_________________________________ { double p,r,n,total,i; String param1; boolean month; Label
l1,l2,l3,l4; TextField t1,t2,t3,t4; Button b1,b2; CheckboxGroup cbg; Checkbox c1,c2; String str; public void
init() { l1=new Label("Balance Amount",Label.LEFT); l2=new Label("Number of Months",Label.LEFT); l3=new
Label("Interest Rate",Label.LEFT); l4=new Label("Total Payment",Label.LEFT); t1=new TextField(5); t2=new
TextField(5); t3=new TextField(15); t4=new TextField(20); b1=new Button("OK"); b2=new Button("Delete");
cbg=new CheckboxGroup(); c1=new Checkbox("Month Rate",cbg,true); c2=new Checkbox("Annual
Rate",cbg,true); t1.addActionListener(this); t2.addActionListener(this); t3.addActionListener(this);
t4.addActionListener(this); b1.addActionListener(this); b2.addActionListener(this); c1.addItemListener(this);
c2.addItemListener(this); add(l1); add(t1); add(l2); add(t2); add(l3); add(t3); add(l4); add(t4); add(c1);
add(c2); add(b1); add(b2); } public void

229 public MyChoice() { enableEvents(AW TEvent.ITEM_EVENT_MASK); } protected void 2 Y1 A 2 import java.aw t.ev
processItemEvent(ItemEvent ie) { //show Status("Choice selection: " + getSelectedItem());
super.processItemEvent(ie); }
Figure:-
230 Find Error in follow ing code nd select correct code : import java.io.*; import java.aw t.*; import java.aw 2 N A 2 import java.io.*; im
t.event.*; import java.applet.*; public class choiceeve extends Applet implements ItemListener {String m=" java.applet.*; publ
"; Choice os; public void init() {os=new Choice(); os.add("W indow s ItemListener {Strin
98"); os.add("W indow s XP"); os.add("W indow s Vista"); add(os); os.addItemListener(this); } public void {os=new Choice();
itemValueChanged(ItemEvent e) {repaint(); } public void paint(Graphics g) { m="Selected os.add(&quot;W ind
OS:"+os.getSelectedItems(); g.draw String(m,10,60); } } /*<applet code="choiceeve.class" w idth=400
height=300> </applet> */

231 Find error in follow ing program. import java.aw t.*; import java.applet.*; /*<applet code="choicedemo" w idth2 N A 2 both A and B

232 Find missing Lines in follow ing Program. import java.aw t.*; import java.io.*; import java.aw t.event.*; 2 Y1 U 2 public void keyType
import java.applet.*; public class ex7 extends Applet implements KeyListener
{ String msg =""; int X=10,Y=20; public void init() { addKeyListener(this); requestFocus(); } public void
keyPressed(KeyEvent k) { show Status("KeyDow n"); int key=k.getKeyCode(); sw itch(key) { case
KeyEvent.VK_UP: show Status("UP KEY PRESSED"); break; } repaint(); } public void keyReleased(KeyEvent
k) { show Status("Key Up"); } public void paint(Graphics g) { g.draw String(msg,X,Y); } } /* <applet code
=ex7 w idth =500 height =500> </applet> */
Figure:-

233 Find missing statement in given code: import java.io.*; import java.aw t.*; import java.aw t.event.*; import ja 2 N A 2 = missing

add(l1);add(t1);add(l2);add(t2); add(l3);add(t3);add(b1);add(b2); }public void actionPerformed(ActionEvent e

234 Find missing statements in order from top to end of the program import java,aw t*; import java.aw t.event.*; 2 N A 2 ActionListener
import java.applet.*; public class RadioDemo extends JApplet implements ,addActionListener,
______________ { public void init() { Container c=getContentPane(); JRadioButton b1=new
JRadioButton("Red"); JRadioButton b2=new JRadioButton("Blue"); b1.add_________________(this);
b2.add___________________(this); c.add(b1); c.add(b2); ButtonGroup bg=new ButtonGroup(); bg.add(b1);
bg.add(b2); } public void _____________ { }
}

235 find out missing statement in follow ing code import java.aw t.*; import javax.sw ing.*; import java.applet.*; 2 N U 2 All of these
public class ass1 extends JApplet implements ItemListener { JTextAreajtf; JComboBoxjb; public void init() {
Container ContentPane=getContentPane(); ContentPane.setLayout(new Flow Layout()); String alpha[]=
{"A","B","C","D","E","F","G","H","I","J","K","L"}; JComboBox jb=new JComboBox(alpha);
ContentPane.add(jb); jtf=new JTextArea(20,10); } public void itemStateChanged(ItemEvent IE)
{ String str=(String)IE.getItem(); jtf.append(str); } } /*<applet code="ass1.class" w idth="400"
height="500" ></applet>*/

236 Find out the Error statement import java.applet.*; import java.aw t.event.*; /* <applet 2 N A 2 addMouseListener(n
code="InnerClassDemo" w idth=200 height=100> </applet> */ public class InnerClassDemo extends Applet
{ public void init() { addMouseListener(new MyMouseAdapter()); } class MyMouseAdapter { public void
mousePressed(MouseEvent me) { show Status("Mouse Pressed");
}}}

237 find out the errors in the follow ing code if any and correct them: import java.aw t.event.*; /* 2 N A 2 public void mouseP
<applet code =" AdapterDemo" height = 250 w idth =350 ></applet>*/ public class Adapter Demo extends
Applet { public void init () { addMouseListener ( new Mouse Adapter() { int topX, bottom Y; public void
Mousepressed ( Mouseevent me) { topX = me.getX(); bottom Y me.get Y ();
} public void mouse Released ( MouseEvent me ) Graphics g = AdapterDemo. this getGraphics (
0; g. draw Rect( topX, bottomY, me.GetX()-topX, me. get Y ()-bottomY); } } ); } }
238 Find out the missing statement show n by _______________in the follow ing code import java.aw t.event.*; im2 N A 2 addMouseListener(n

239 Find out the missing statements show n by _____________in the follow ing code. import java.aw t.*; import ja 2 N A 2 Frame, W indow Ad

240 Find out w hich listener is used in follow ing program:import java.aw t.*; import java.aw t.event.*; import java.2 N A 2 ActionListener

241 Find the error in the code public void itemStateChanged(ItemEvent ie) { 2 N A 2 No error
l.setText(c.getSelectedItem()); }

Find the error in the follow ing code import java.aw t.*; import java.applet.*; public class Demo extends Apple

242 Button(); add(b); b.addActionListener(); } public void actionEvent(Event ae) { 2 N A 2 2 and 4 is true
show Status(“Button clicked”); } } 1) Button constructor is w rong 2) Error is addActionListener method
3)ActionListener method should be public void actionPerformed(Event ar) 4)ActionListener method should be
public void actionPerformed(ActionEvent ae)

243 Find the missing at ******** in follow ing code. import java.aw t.*; import java.applet.*; import java.aw 2 N A 2 Key
t.event.*; public class key extends Applet implements *******Listener { String msg=" "; public void init() {
addKeyListener(this); } public void keyPressed(KeyEvent k) {
show Status("key pressed"); } public void keyReleased(KeyEvent k) { show Status("key released"); } public
void keyTyped(KeyEvent k) { show Status("key typing"); } public void paint(Grapics g) { g.draw
String(msg,80,100); } } /*<applet code="Key" w idth=600 height=600>
</applet> */

244 find the missing method follow ing given code import java.aw t.*; import java.aw t.event.*; public class 2 N A 2 w indow Closing()
ButtonTest3 { public static void main(String[] args) { Frame f = new ButtonTestFrame("Button Test");
f.setSize(150, 100); f.setVisible(true); } } class ButtonTestFrame extends Frame { public
ButtonTestFrame(String title) { super(title); setLayout(new Flow Layout()); Button b = new Button("Close w
indow "); add(b); b.addActionListener(new ButtonListener()); addW indow Listener(new W indow Closer()); }
} class ButtonListener implements ActionListener { public void actionPerformed(ActionEvent evt) {
System.exit(0); } } class W indow Closer extends W indow Adapter { public void
____________(W indow Event evt) { } }
245 Find the missing statement for getting follow ing output import java.aw t.*; import javax.sw ing.*; import 2 Y1 A 2 b1=new JButton(i1
java.aw t.event.*; public class Sw ing_Demo1 extends JApplet implements ActionListener { JButton
b1,b2,b3,b4; JTextField t1; public void init() { Container c=getContentPane(); c.setLayout(new
GridLayout(3,3)); t1=new JTextField(20); c.add(t1); ImageIcon i1=new ImageIcon("Sunset.jpg"); ImageIcon
i2=new ImageIcon("Blue hills.jpg"); ImageIcon i3=new ImageIcon("W inter.jpg"); ImageIcon i4=new
ImageIcon("W ater lilies.jpg"); b2=new JButton(i2); b3=new JButton(i3); b4=new JButton(i4);
b1.setActionCommand("Sunset image"); b2.setActionCommand("Blue hills"); b3.setActionCommand("W
inter"); b4.setActionCommand("W ater lilies"); b1.addActionListener(this); b2.addActionListener(this);
b3.addActionListener(this); b4.addActionListener(this); c.add(b1); c.add(b2); c.add(b3); c.add(b4); } public
void actionPerformed(ActionEvent ae) { if(ae.getSource()==b1) t1.setText(b1.getActionCommand());
if(ae.getSource()==b2) t1.setText(b2.getActionCommand()); if(ae.getSource()==b3)
t1.setText(b3.getActionCommand()); if(ae.getSource()==b4) t1.setText(b4.getActionCommand()); } }
Figure:-

246 Find the missing statement in the program. /* <APPLET Code="InnerClassDemo" W idth=200 2 N A 2 Missing semicolon
Height=250> </APPLET> */ public class InnerClassDemo extends Applet { public void init() {
addMouseListener(new MyMouseAdapter()); } class MyMouseAdapter extends MouseAdapter { public void
mousePressed(MouseEvent me) { show Status("Mouse Pressed") } } } }

247 Find the missing statement in the program. import java.applet.Applet; import java.aw t.*; import java.aw t.eve 2 N A 2 implements ActionL

textarea1.insert(msg, 0); } } }
248 Find the statement in w hich there is error import java.aw t.*; import java.applet.*; import java.aw t.event.*; 2 N U 2 barr.addActionListe
/*<applet code="DemoButton.class" height=500 w idth=500></applet>*/ public class DemoButton extends
Applet implements ActionListener { String msg= " "; Button barr[]=new Button[3]; public void init() { Button
yes=new Button ("YES"); Button no=new Button ("No"); Button undecided=new Button ("UNDECIDED");
barr[0]=(Button)add(yes); barr[1]= (Button)add(no); barr[2]=(Button)add(undecided); for(int i=0;i<3;i++)
{ barr.addActionListener(this); } } public void actionPerformed(ActionEvent ae) { for(int i=0;i<3;i++) {
if(ae.getSource()==barr[i]) { msg=" You Pressed "+ barr[i].getLabel(); }//if end
}//for end repaint(); }//method end public void paint(Graphics g) { g.draw String(msg ,100,100);
}}

249 follow ing code select the method that can be used to handle event. import java.aw t.event.*; import java.aw 2 N A 2 itemStateChanged(
t.*; importjava.applet.*; public class checkbackg extends Applet implements ItemListener { Checkbox
m1,m2,m3; public void init() { m1=new Checkbox("A"); m2=new Checkbox("B"); m3=new Checkbox("C");
add(m1); add(m2); add(m3); m1.addItemListener(this); m2.addItemListener(this); } public void
__________________(ItemEvent ie) { if(ie.getSource()==m1) setBackground(Color.red);
if(ie.getSource()==m2) setBackground(Color.green); } } /*<applet code=checkbackg.class height=150 w
idth=150>
</applet>*

250 follow ing is an example of w hat? Frame f=new Frame(“MyFrame”); f.addW indow Listener(new 2 N U 2 Code show s the us
W indow Adapter() { public void w indow Closing(W indow Event w e) {System.exit(0);}});

251 Follow ing program is the example of import java.applet.*; import java.aw t.event.*; /* <applet 2 N A 2 Inner class
code="ClassDemo" w idth=200 height=100> </applet> */ public class ClassDemo extends Applet
{public void init() { addMouseListener(new MyMouseAdapter()); } class MyMouseAdapter extends
MouseAdapter { public void mousePressed(MouseEvent me) { show Status("Mouse Pressed"); } } }
252 For displaying coordinates of moving mouse pointer on status bar of applet, in follow ing programs w hich statem
2 N A 2 repaint() in public v

253 For the follow ing code select correct statements to complete the code. import java.aw t.*; import 2 N A 2 ActionListener , act
java.applet.*; import java.aw t.event.*; /*<applet code=demo w idth=100 height=100>
</applet> */ public class demo extends Applet implements ____________ { Label l1,l2; Button b1; String
msg=""; public void init() { l1=new Label("Label 1"); l2=new Label("Label 2"); b1=new Button("Enter");
add(l1); add(l2); add(b1); b1.addActionListener(this); } public void
____________________________ { msg="U Have Pressed Enter Button"; repaint(); } public void
paint(Graphics g) { g.draw String(msg,100,100); } }

254 For the follow ing code select the appropriate method. import java.aw t.*; import java.aw t.event.*; import java2 N A 2 getActionCommand

For the follow ing code select the listener implemented by class import java.aw t.*; import java.aw t.event.*;
import javax.sw ing.*; /* <applet code="JRadioEvent" w idth=300 height=100>
</applet> */ public class JRadioEvent extends JApplet implements ______________ { ButtonGroup grp;
JRadioButton red,pink,green; JTextArea ta; public void init() { setLayout(new

255 Flow Layout()); ta=new JTextArea(5,10); setupButtons(); addListeners(); add(red); add(pink); add(green); add2 N A 2 ActionListener

256 For the follow ing code select the method that can be used to handle event import java.aw t.*; import 2 N A 2 adjustmentValueCh
java.aw t.event.*; import java.applet.*; /* <applet code="ScrollBbar1" w idth=300 height=200> </applet>
*/ public class ScrollBbar1 extends Applet implements AdjustmentListener { String msg = ""; Scrollbar red,
blue,green; int r,g,b; Color c; public void init() { int max=255; c = new Color(0,0,0); setBackground(c); red
= new Scrollbar(Scrollbar.HORIZONTAL,0, 1, 0, max); green = new Scrollbar(Scrollbar.HORIZONTAL,0, 1,
0, max); blue = new Scrollbar(Scrollbar.HORIZONTAL,0, 1, 0, max); add(red); add(green); add(blue); //
register to receive adjustment events red.addAdjustmentListener(this); green.addAdjustmentListener(this);
blue.addAdjustmentListener(this); } public void
_____________________________ { r=red.getValue(); g=green.getValue();
b=blue.getValue(); c = new Color(r,g,b); setBackground(c); } }

257 For the follow ing code select the method that can be used to handle event import java.aw t.*; import 2 Y1 A 2 actionPerformed(Ac
java.aw t.event.*; class AEvent extends Frame implements ActionListener{ TextField tf; AEvent(){ tf=new
TextField(); tf.setBounds(60,50,170,20); Button b=new Button("click me"); b.setBounds(100,120,80,30);
b.addActionListener(this); add(b);add(tf); setSize(300,300); setLayout(null); setVisible(true); } public void
actionPerformed(ActionEvent e){ tf.setText("W elcome"); } public static void main(String args[]){ new
AEvent(); } }
Figure:-
258 For the follow ing code select the method that can be used to handle event import java.aw t.*; import java.appl2 N A 2 itemStateChanged(

259 For the follow ing code select the method that can be used to handle event so that w e get proper output. 2 N U 2 adjustmentValueCh
import java.aw t.*; import java.aw t.event.*; import java.applet.*; public class DemoAdjustmentEvent
extends Applet implements AdjustmentListener { Scrollbar sbRed,sbGreen,sbBlue; public void init() {
sbRed=new Scrollbar(Scrollbar.VERTICAL,20,10,0,255); sbGreen=new
Scrollbar(Scrollbar.VERTICAL,20,10,0,255); sbBlue=new Scrollbar(Scrollbar.VERTICAL,20,10,0,255);
add(sbRed); add(sbGreen); add(sbBlue); sbRed.addAdjustmentListener(this);
sbGreen.addAdjustmentListener(this); sbBlue.addAdjustmentListener(this); } public
void______________________________ { int r=sbRed.getValue(); int g=sbGreen.getValue(); int
b=sbBlue.getValue(); Color c=new
Color(r,g,b); setBackground(c); } } /*<applet code="DemoAdjustmentEvent.class" w idth=300
height=300></applet>*/

260 For the follow ing code select the method that can be used to handle event, and to get the output given in the 2 Y1 U 2 keyTyped(KeyEven
figure. import java.applet.*; import java.aw t.*; import java.aw t.event.*; public class DemoKeyEvent
extends Applet { char ch; public void init() { this.addKeyListener(new KeyAdapter() { public
void______________________________ { ch=ke.getKeyChar(); repaint(); } }); } public void paint(Graphics
g) { g.draw String("Character pressed is: "+ch,100,100); } } /*<applet code="DemoKeyEvent.class" w
idth=300 height=300></applet>*/
Figure:-

261 For the follow ing code select the method that can be used to handle event. import java.aw t.*; import 2 N A 2 adjustmentValueCh
java.aw t.event.*; import java.applet.*; /* <applet code="SBDemo" w idth=300 height=200> </applet> */
public class SBDemo extends Applet implements AdjustmentListener, MouseMotionListener { String msg = "";
Scrollbar vertSB, horzSB; public void init() { int w idth = Integer.parseInt(getParameter("w idth")); int height
= Integer.parseInt(getParameter("height")); vertSB = new Scrollbar(Scrollbar.VERTICAL,0, 1, 0,
height); horzSB = new Scrollbar(Scrollbar.HORIZONTAL,0, 1, 0, w idth); add(vertSB); add(horzSB);
vertSB.addAdjustmentListener(this); horzSB.addAdjustmentListener(this); addMouseMotionListener(this); }
public void ____________________(AdjustmentEvent ae) { repaint(); } public void
mouseDragged(MouseEvent me) { int x = me.getX(); int y = me.getY(); vertSB.setValue(y);
horzSB.setValue(x); repaint(); } public void mouseMoved(MouseEvent me) {
} public void paint(Graphics g) { msg = "Vertical: " + vertSB.getValue(); msg += ", Horizontal: " +
horzSB.getValue(); g.draw String(msg, 6, 160); g.draw String("*", horzSB.getValue(), vertSB.getValue()); } }

262 For the follow ing code select the method that can be used to handle event. import java.aw t.event.*; import ja 2 N A 2 actionPerformed(Ac

263 For the follow ing code select the method that can be used to handle event. import java.applet.*; import 2 N U 2 textChanged(TextE
java.aw t.*; public class S1Q29 extends Applet implements TextListener{ Label l; TextField t1 ; String
msg=""; public void init(){ t1 =new TextField(10); l = new Label("Enter String"); add(t1);
t1.addTextListener(this); } public void ______________________________{ msg = t1.getText(); repaint();
} public void paint(Graphics g){ g.draw String(msg,100,100); } } /*
<applet code=checkbackg.class height=150 w idth=150> </applet>*/
For the follow ing code select the method that can be used to handle event. import java.aw t.*; import
java.applet.*; import java.aw t.event.*; /* <APPLET Code="ActionListenerTest" W idth=300 Height=300>
</APPLET> */ public class ActionListenerTest extends Applet
implements ActionListener { Button b1,b2,b3,b4; public void init() { Font f=new Font("New Times

264 Roman",Font.BOLD,14); b1=new Button("RED"); b2=new Button("BLUE"); b3=new Button("GREEN"); 2 N A 2 actionPerformed(Ac


b4=new Button("YELLOW "); b1.setFont(f); b2.setFont(f); b3.setFont(f); b4.setFont(f); setLayout(new
BorderLayout()); add(b1,"North"); add(b2,"South"); add(b3,"East"); add(b4,"W est");
b1.addActionListener(this); b2.addActionListener(this); b3.addActionListener(this);
b4.addActionListener(this); } public void
_____________(ActionEvent ae) { if(ae.getSource()==b1) { b1.setBackground(Color.red); }
if(ae.getSource()==b2) { b2.setBackground(Color.blue); } if(ae.getSource()==b3) {
b3.setBackground(Color.green); } if(ae.getSource()==b4) { b4.setBackground(Color.yellow ); } }
}

265 For the follow ing code select the method that can be used to handle event. import java.aw t.*; import 2 N A 2 itemStateChanged
java.applet.*; import java.aw t.event.*; /*<applet code=exp.java w idth=400 height=400> </applet>*/
public class exp extends Applet implements ItemListener { Choice c; TextField t1,t2,t3; Label l1,l2,l3; public
void init() { t1=new TextField(10); t2=new TextField(10); t3=new TextField(10); l1=new Label("Enter
num"); l2=new Label("Second num"); l3=new Label("Result"); c=new Choice(); c.add("addition");
c.add("subtraction"); add(l1); add(t1); add(l2); add(t2); add(l3); add(t3); add(c); c.addItemListener(this); }
public void
__________(ItemEvent e) { String s=c.getSelectedItem(); if(s.equals("addition")) { int
n1=Integer.parseInt(t1.getText()); int n2=Integer.parseInt(t2.getText()); int n3=n1+n2;
t3.setText(Integer.toString(n3)); } if(s.equals("subtraction")) { int n1=Integer.parseInt(t1.getText()); int
n2=Integer.parseInt(t2.getText()); int n3=n1-n2; t3.setText(Integer.toString(n3)); } } }

266 For the follow ing code select the method that can be used to handle event. import java.aw t.*; import 2 N A 2 actionPerformed(Ac
java.aw t.event.*; import java.applet.*; /* <applet code="ButtonDemo" w idth=250 height=150> </applet>
*/ public class ButtonDemo extends Applet implements ActionListener { String msg = ""; Button yes, no,
maybe; public void init() { yes = new Button("Yes"); no = new Button("No"); maybe = new
Button("Undecided"); add(yes); add(no); add(maybe); yes.addActionListener(this);
no.addActionListener(this); maybe.addActionListener(this); } public void ------------------(ActionEvent ae) {
String str = ae.getActionCommand(); if(str.equals("Yes")) { msg = "You pressed Yes."; } else
if(str.equals("No")) { msg = "You pressed No."; } else { msg = "You pressed Undecided."; } repaint(); }
public void paint(Graphics g) { g.draw String(msg, 6,
100); } }

267 For the follow ing code select the method that can be used to handle event. import java.aw t.*; import 2 N A 2 keyReleased(KeyEv
java.aw t.event.*; import java.applet.*; import javax.sw ing.*; /*<applet code="simple" w idth=300
height=100>- </applet>*/ public class simple extends JApplet implements KeyListener { String msg=" "; int
x=10,y=20; public void init() { addKeyListener(this); requestFocus(); } public void keyPressed(KeyEvent ke)
{ show Status("key dow n"); } public void
_________________(KeyEvent ke) { show Status("Key Up"); } public void keyTyped(KeyEvent ke) {
msg+=ke.getKeyChar(); repaint(); } public void paint(Graphics g) { g.draw String(msg,x,y);
}}

268 For the follow ing code select the method that can be used to handle event. importjava.aw t.event.*; import 2 N A 2 C. itemStateChange
java.aw t.*; importjava.applet.*; public class checkbackg extends Applet implements ItemListener {
Checkbox m1,m2,m3; public void init() { m1=new Checkbox("A"); m2=new Checkbox("B"); m3=new
Checkbox("C"); add(m1); add(m2); add(m3); m1.addItemListener(this); m2.addItemListener(this); } public
void __________________ { if(ie.getSource()==m1) setBackground(Color.red); if(ie.getSource()==m2)
setBackground(Color.green); } } /*<applet code=checkbackg.class height=150 w idth=150>
</applet>*/

269 For the follow ing code select the method that can be used to handle event. import java.aw t.*; import 2 N A 2 adjustmentValueCh
java.aw t.event.*; import java.applet.*; public class scrl extends Applet implements AdjustmentListener {
Scrollbar vsb,hsb; public void init() { int w idth=Integer.parseInt(getParameter("w idth")); int
height=Integer.parseInt(getParameter("height")); vsb=new Scrollbar(Scrollbar.VERTICAL,0,1,0,height);
hsb=new Scrollbar(Scrollbar.HORIZONTAL,0,1,0,w idth); add(vsb); add(hsb);
vsb.addAdjustmentListener(this); hsb.addAdjustmentListener(this); } public void -----------------(-
--------Event ae) { repaint(); } public void paint(Graphics g) { msg="Vertical: "+vsb.getValue();
msg+="Horizontal: "+hsb.getValue(); g.draw String(msg,6,160); g.draw String("*",

hsb.getValue(),vsb.getValue()); } }
270 For the follow ing code select the method that can be used to handle event. import java.aw t.*; import 2 Y1 A 2 actionPerformed(Ac
java.aw t.event.*; class AEvent extends Frame implements ActionListener{ TextField tf; AEvent(){ tf=new
TextField(); tf.setBounds(60,50,170,20); Button b=new Button("click me"); b.setBounds(100,120,80,30);
b.addActionListener(this); add(b); add(tf); setSize(300,300); setLayout(null); setVisible(true); } public void
__________________(ActionEvent e){ tf.setText("W elcome"); } public static void main(String args[]){ new
AEvent(); } }
Figure:-

271 For the follow ing code select the method that can be used to handle event. importjava.aw t.event.*; import 2 N A 2 itemStateChanged(
java.aw t.* ; import java.applet.*; public class checkbackg extends Applet implements ItemListener{
Checkbox m1,m2,m3; public void init() { m1=new Checkbox("A"); m2=new Checkbox("B"); m3=new
Checkbox("C"); add(m1); add(m2); add(m3); m1.addItemListener(this); m2.addItemListener(this); } public
void
__________________(ItemEvent ie) { if(ie.getSource()==m1) setBackground(Color.red);
if(ie.getSource()==m2) setBackground(Color.green); } } /*<applet code=

272 For the follow ing code select the method that can be used to handle event. ? import java.aw t.*; import 2 N A 2 itemStateChanged(
java.applet.*; import java.aw t.event.*; /*<applet code=ListDemo.class w idth=400
height=400></applet>*/ public class ListDemo extends Applet implements ItemListener { List l; String
msg=""; public void init() { l=new List(2,true); l.add("Day"); for(int i=1;i<=31;i++) { l.add(i+""); } add(l);
l.addItemListener(this); } public void
_______________________________ { repaint(); } public void paint(Graphics g) { int idx[];
idx=l.getSelectedIndexes(); for(int i=0;i<idx.length;i++) { msg=l.getItem(idx[i]); g.draw
String(msg,20,i*10+20); } } }

273 For the follow ing code select the method that can be used to hanle event. import java.aw t.*; import java.apple2 N A 2 adjustmentValueCh

274 For the follow ing code select the method that should fill in the blanks. import java.applet.Applet; import 2 N A 2 e.getSource()
java.aw t.*; import java.aw t.event.*; public class New Applet extends Applet implements ActionListener {
Button b1,b2,b3; public void init() { b1=new Button("1"); b2=new Button("2"); b3=new Button("3");
add(b1); add(b2); add(b3); b1.addActionListener(this); b2.addActionListener(this);
b3.addActionListener(this); } public void
actionPerformed(ActionEvent e) { if(_____________==b1) setBackground(Color.RED); else if
(__________==b2) setBackground(Color.BLUE); else setBackground(Color.GREEN); }} /*
<applet code=New Applet.class height=150 w idth=150> </applet>*/

For the follow ing code select the methods that can be used to handle event and register the event. importjava.

275 String msg = ""; intmouseX = 0, mouseY = 0 public void init() { add-------------(this); } public void 2 N A 2 addMouseMotionLis
----------------(MouseEvent me) { mouseX = me.getX(); mouseY = me.getY(); msg = "*"; show Status("
Mouse at " + mouseX + ", " + mouseY); repaint(); } public void ---------------- (MouseEvent me) { show
Status("Mouse at " + me.getX() + ", " + me.getY()); } public void paint(Graphics g) { g.draw String(msg,
mouseX, mouseY); } }

276 For the follow ing code w hich interface is use. importjava.aw t.event.*; import java.aw t.*; 2 N A 2 ItemListener
importjava.applet.*; public class checkbackg extends Applet implements __________________
{ Checkbox m1,m2,m3; public void init() { m1=new Checkbox("W indow s xp"); m2=new Checkbox("W
indow s 7"); m3=new Checkbox("W indow s vista"); add(m1); add(m2); add(m3); m1.addItemListener(this);
m2.addItemListener(this); } public void itemStateChanged(ItemEvent ie) { if(ie.getSource()==m1)
setBackground(Color.red); if(ie.getSource()==m2) setBackground(Color.green); } } /*<applet
code=checkbackg.class height=150 w idth=150>
</applet>*/
277 For the follow ing code, fill up the correct listener name and event name. import java.aw t.*; import java.aw 2 N A 2 KeyListener, KeyEv
t.event.*; import java.applet.*; /* <applet code="SimpleKeyDemo" w idth=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) { show Status("Key Dow n"); } public void
keyReleased( _________ ke) { show Status("Key Up"); } public void keyTyped(
____________ ke) { msg += ke.getKeyChar(); repaint(); } public void paint(Graphics g) {
g.draw String(msg, X, Y); } }

278 For the follow ing output complete the code given below . import java.aw t.*; import java.aw t.event.*; 2 Y1 U 2 public void actionPe
import javax.sw ing.*; /* <applet code="JRadioButtonDemo" w idth=300 height=50> </applet> */ public tf.setText(ae.getAc
class JRadioButtonDemo extends JApplet implements ActionListener { JTextField tf; public void init() {
Container contentPane = getContentPane(); contentPane.setLayout(new Flow Layout()); JRadioButton b1 =
new JRadioButton("A"); b1.addActionListener(this); contentPane.add(b1); JRadioButton b2 = new
JRadioButton("B"); b2.addActionListener(this); contentPane.add(b2); JRadioButton b3 = new
JRadioButton("C"); b3.addActionListener(this); contentPane.add(b3); tf = new JTextField(5);
contentPane.add(tf); ButtonGroup bg = new ButtonGroup(); bg.add(b1); bg.add(b2); bg.add(b3); } }
Figure:-

279 For the follow ing output w indow , w hat type of Event Listener and abstract method implementation should 2 Y1 A 2 ActionListener, acti
be done for event handling on the radiobutton?
Figure:-

280 From given list w hich is not Listener Interface? 2 N U 2 MousepressedListener

281 From given list w hich is not method of Mouse Listener? 2 N U 2 mouseDragged()

282 From the follow ing code find the correct occurence of key event. import java.aw t.*; import java.aw 2 N A 2 Key Pressed Key Ty
t.event.*; public class S1Q46 extends Frame implements KeyListener{ TextField t1; public S1Q46(){
setLayout(new Flow Layout()); t1= new TextField(10); t1.addKeyListener(this); add(t1); setVisible(true); }
public void keyTyped(KeyEvent e) { System.out.println("Key Typed");
} public void keyPressed(KeyEvent e) { System.out.println("Key Pressed"); } public void
keyReleased(KeyEvent e) { System.out.println("Key Released"); } public static void main(String arg[]){
S1Q46 s = new S1Q46(); }

283 getKeyChar() and getKeyCode() methods belongs to _____________________ 2 N A 2 KeyListener interface

284 getSource( ) method of ActionEvent retrieves: 2 N U 2 Component object w hich generate

285 How can a dialog box be closed? 2 N U 2 Using W indow Listener


286 How many Button objects are required to get the follow ing output 2 Y1 A 2 3
Figure:-

287 How many checkboxes of follow ing program are in checked state.? import java.aw t.*; import java.aw 2 N A 2 2
t.event.*; import java.applet.*; /* <applet code="CheckboxDemo" w idth=250 height=200> </applet> */
public class CheckboxDemo extends Applet implements ItemListener
{ String msg = ""; Checkbox w inXP, w inVista, solaris, mac; public void init() { w inXP = new Checkbox("W
indow s XP", null, true); w inVista = new Checkbox("W indow s Vista"); solaris = new
Checkbox("Solaris",true); mac = new Checkbox("Mac OS"); add(w inXP); add(w inVista); add(solaris);
add(mac); }}

How many component is used in follow ing program :- import java.aw t.*; import javax.sw ing.*; import java.ap

288 Button b1; Label l1,l2; TextField t1,t2; public void init() { l1=new Label("Enter the number"); l2=new Label("Sq2 N A 2 5

289 Identify correct output for follow ing program. import java.aw t.*; import java.aw t.event.*; import 2 Y2 A 2
java.applet.*; public class ListDemo extends Applet implements ActionListener { List os; String msg = "";
public void init() { os = new List(4, false); os.add("W indow s 98/XP"); os.add("W indow s NT/2000");
os.add("Solaris"); os.add("MacOS"); os.select(1); add(os); os.addActionListener(this); } public void
actionPerformed(ActionEvent ae) { repaint(); } public void paint(Graphics g) { msg = "Current OS: "; msg
+= os.getSelectedItem(); g.draw String(msg,
6, 140); } }

290 Identify the components in the given output 2 Y1 U 2 Applet,Frame,Menu


Figure:-
291 Identify the correct code for follow ing output. Figure:- 2 Y1 A 2 TextField, ComboBo

292 Identify the correct code to handle event on Scrollbar? 2 N A 2 import java.aw t.*; import java.aw t

293 Identify the correct syntax 2 N A 2 public void actionPerformed(Action

294 Identify the correct syntax of adding MouseAdapter class to program? 2 N A 2 addMouseListener(n

295 Identify the Error Statement in the Follow ing Program import java.aw t.*; import java.aw t.event.*; import 2 N U 2 All of the above.
javax.sw ing.*; class ChangeBackClr extends JFrame { ChangeBackClr()
{ final Container oPane=getContainer(); addMouseListener(new MouseAdapter() { public void
mouseClicked(MouseEvent me) { int iR=(int)(Math.random()*255); int iG=(int) (Math.random()*255); int
iB=(int)(Math.random()*255); oPane.setBackcolor(new Color(iR,iG,iB));
} }); } }

Identify the missing statement in the program? import java.aw t.*; import java.aw t.event.*;
import java.applet.*; public class eventdemo extends Applet implements ActionListener { public

296 void init() { Button b1= new Button("Click"); TextField t1=new TextField(); add(b1); add(t1); } public void acti2 N A 2 b1.addActionlistener(this) should r

297 Identify the missing statements in the follow ing code. Figure:- 2 Y1 A 2 b1.addActionListene

298 Identify type of listener public class MouseEvents extends Applet implements 2 N A 2 None of Above
_______________________ { String msg = ""; int mouseX = 0, mouseY = 0; public void init() {
add__________________(this); } public void mouseDragged(MouseEvent me) { mouseX = me.getX();
mouseY = me.getY(); msg = "*"; show Status("Dragging mouse at " + mouseX + ", " + mouseY); repaint();
} public void mouseMoved(MouseEvent me) { show Status("Moving mouse at " + me.getX() + ", " +
me.getY()); } public void paint(Graphics g) { g.draw String(msg, mouseX, mouseY); } }

299 Identify w rong method of KeyListener 2 N U 2 keyDragged(KeyEvent ke)

300 If scroll bar is manipulated …………………….event w ill be notified. 2 N U 2 AdjustmentEvent

301 If w e close an applet w indow _____ events w ill be generated 2 N U 2 W indow Event

302 import java.applet.Applet; For the follow ing code select the method that can be used to handle event import ja 2 N A 2 adjustmentValueCh

303 import java.applet.Applet; import java.aw t.*; import java.aw t.event.*; /*<applet code="mlst" w idth=300 2 N A 2 Program w ill appen
height=300></applet>*/ public class mlst extends Applet implements ActionListener double clicked
{ TextArea t1; List l1; public void init() { t1=new TextArea("
",10,20,TextArea.SCROLLBARS_VERTICAL_ONLY); l1=new List(4,true); l1.add("sangamner"); l1.add("nasik");
l1.add("pune"); l1.add("mumbai"); add(l1); add(t1); l1.addActionListener(this); } public void
actionPerformed(ActionEvent e) { if(e.getSource()==l1) for(int
i=0;i<((String)l1.getSelectedItem()).length();i++) { t1.insert((String)l1.getSelectedItem(),0); }}}
304 import java.aw t.*; import java.applet.*; public class myapplet extends Applet { public void paint(Graphics g) {2 N A 2 A Simple Applet

305 import java.aw t.*; import java.applet.* class colordemo extends Applet implements ActionListener { String str=2 Y2 A 2

306 import java.aw t.*; import java.applet.*; public class LayoutDemo5 extends Applet { public void init() { int i,j,k2 N A 2 The output is obtain
Layout

code=LayoutDemo5.class w idth=300 height=400> </applet>*/ W hat w ill be the out put of above program?

307 import java.aw t.*; import java.aw t.event.*; import java.applet.*; /* <applet code="CountVow el.class" w 2 Y1 A 2 12
idth=300 height=100> </applet> */ public class CountVow el extends Applet implements ActionListener {
TextArea txtArea; TextField text; Button btn; public void init() { txtArea = new TextArea();
txtArea.setBounds(30,30,200,200); add(txtArea); text =
new TextField(20); text.setBounds(30,240,100,30); text.setEditable(false); add(text); btn = new
Button("Calculate"); btn.setBounds(150,230,70,30); add(btn); btn.addActionListener(this); } public void
actionPerformed(ActionEvent ae) { if(ae.getSource() == btn ) { String strTemp= txtArea.getText(); int
count=0; for(int i=0;i<strTemp.length();i++) { if(strTemp.charAt(i)=='a'|| strTemp.charAt(i)=='A'||
strTemp.charAt(i)=='e'|| strTemp.charAt(i)=='E'|| strTemp.charAt(i)=='i'|| strTemp.charAt(i)=='I'||
strTemp.charAt(i)=='o'|| strTemp.charAt(i)=='O'|| strTemp.charAt(i)=='u'|| strTemp.charAt(i)=='U') {
count++; } } String str=Integer.toString(count); text.setText(str); } }
} W hat w ill be the Output? Figure:-

308 importjava.aw t.*; importjava.applet.*; public class list2 extends Applet { public void init() { List l= new List(2 2 Y2 U 2

309 In follow ing Java program fill statement show ing ***. Select any one option from given options import java.ap2 N A 2 mousePressed()

310 In follow ing Java program fill statement show ing ***.Select any one option fro given options import java.aw t.2 N A 2 ActionListener, acti

311 In follow ing Java program fill statement show ing ***.Select any one option from given options import 2 N A 2 ActionListener
java.aw t.*; import java.aw t.event.*; class AEvent extends Frame implements ********{ TextField tf;
AEvent(){ tf=new TextField(); tf.setBounds(60,50,170,20); Button b=new Button("click me");
b.setBounds(100,120,80,30); b.addActionListener(this); add(b);add(tf); setSize(300,300); setLayout(null);
setVisible(true); } public void actionPerformed(ActionEvent e)
{ tf.setText("W elcome"); } public static void main(String args[]){ new AEvent(); } }

312 In order to obtain currunt value of scrollbar at run time w hich method you w ill use 2 N A 2 getValue()

313 In the follow ing output, the frame w indow doesn't close by default. Pick up the correct code in order to close 2 Y1 A 2 W indow Listener
the frame.
Figure:-
314 In w hich places can put the event handling code 2 N U 2 All mentioned above

315 ItemListener Interface is applicable to? 2 N A 2 All of this

316 itemStateChanged() method take w hich form from the follow ing? 2 N U 2 void itemStateChanged(Item ie)

317 Java packages such as ____________ support the Event handling mechanism 2 N A 2 all of these

318 KeyListener interface is applicable to keyboard only? 2 N A 2 True

319 keyTyped(KeyEvent e) Called w hen a key on the keyboard is ________________________ 2 N U 2 pressed and then released

320 List control in AW T, generates ………………….. Event on ………………. Click. 2 N A 2 Both Options A and B correct.

321 Match The Pair ? 1) Button() a) AdjustmentListener 2) Scrollbar() b) Non Of Above 3) Checkbox() 2 N U 2 1-d 2-a 3-c 4-b
c) ItemListener 4) Label() d) ActionListener

322 MouseListener interface belongs w hich of the follow ing methods? 2 N U 2 mouseExited,mouseEntered,mous

323 Observe the Follow ing Code... import java.aw t.*; import java.aw t.event.*; class TYIFEvent extends Frame im 2 N A 2 This Program Hand

324 Observe the follow ing output and determine w hich component and listener is required? Figure:- 2 Y1 U 2 Button, frame, actio

325 Observe the follow ing program .... import java.applet.Applet; import java.aw t.Button; /* <applet code="Disab 2 N A 2 The output w ill dis
&quot;Cancle&quot
disabled

326 Observe the follow ing program .... import java.applet.Applet; import java.aw t.Button; /* <applet code="HideB2 N A 2 The Program contai
&quot;Cancle&quot
be displayed

Observe the follow ing program .... import java.aw t.*; import javax.sw ing.*; public class
327 MyFlow Layout{ JFrame f; MyFlow Layout(){ f=new JFrame(); JButton b1=new JButton("1"); JButton b2=new J 2 N A 2 The output w ill dis

328 Observe the follow ing program .... import java.aw t.Color; import javax.sw ing.*; public class TyifArea { JTextA2 N A 2 The Output w ill Co
black

329 Pick the correct abstract method w hich belongs to MouseMotionListener interface 2 N U 2 mouseDragged()

330 Pick the correct statement to register a button b for event handling 2 N U 2 b.addActionListener(this);
331 Predict the output public class R1 extends Applet implements ItemListener { TextField t1, Checkbox c1; public 2 N A 2 Hi is printed in text
void init() { c1 = new Checkbox(); add(c1); t1 = new TextField(); add(t1); } public void
itemStateChanged(ItemEvent ie) { if(ae.getItemSelectable()==c1) t1.setText("Hi"); }
}

332 public void actionPerformed(ActionEvent ae) { if(ae.getSource().equals(submit)) { 2 N A 2 ActionListener


setBackground(Color.red); } } for above code W hich event listner interface is need to import?

333 Referring to the above, w hat statement is added to itemStateChanged() so it w ill display "India" on selection 2 N U 2 msg=(String) e.get
of item? import java.applet.*; import java.aw t.*; import java.aw t.event.*; public class S1Q31 extends
Applet implements ItemListener { Choice c; String msg=""; public void init()
{ c = new Choice(); c.add("India"); c.add("Nepal"); c.add("Sri Lanka"); c.addItemListener(this); } public void
itemStateChanged(ItemEvent e) { repaint(); } public void paint(Graphics g){ g.draw String(msg,200, 200); }
} /* <applet code="combodemo" w idth=300 height=100>
</applet> */

334 Select correct Adapter class from given option for ******. import java.aw t.*; import java.aw t.event.*; import 2 N A 2 MouseAdapter

335 Select correct sequence of steps for selecting items w hich are specified in a Jtree a)The Clicked row is acquired 2 N U 2 a,c,b

336 select correct statement to get correct out? import javax.sw ing.*; import java.aw t.*; import java.aw 2 N A 2 ok.addActionListene
t.event.*; public class SimpleGUI extends JFrame { private Container contentPane; private JTextField ActionListener
textField; private JButton ok, cancel; private JLabel feedback; private JPanel panel; public static void main(
String[] args ) { SimpleGUI gui = new SimpleGUI(); gui.pack(); gui.setVisible( true ); } public SimpleGUI() {
contentPane = getContentPane(); contentPane.setLayout( new GridLayout( 3, 1 ) ); textField = new
JTextField(); textField.setColumns( 22 ); contentPane.add( textField ); panel = new JPanel( new Flow Layout()
); ok = new JButton( "OK" ); cancel = new JButton( "Cancel" ); panel.add( ok ); panel.add( cancel
); contentPane.add( panel ); feedback = new JLabel(); contentPane.add( feedback );
setDefaultCloseOperation( EXIT_ON_CLOSE ); } setDefaultCloseOperation( EXIT_ON_CLOSE ); }
}

337 Select currect sequence of current states of follow ing output 2 Y1 U 2 True,False,True,Fal
Figure:-

338 Select methods of checkBox calss. 2 N A 2 All of these

339 Select missing lines in follow ing code to get correct ouput . /*<applet code="demo2.class" w idth="310" 2 N A 2 cp.add(sp); tr.setEd
height="160"></applet>*/ import java.aw t.*; import javax.sw ing.*; import java.aw t.event.*; public class
demo2 extends JApplet implements ActionListener { public void init() { DefaultMutableTreeNode root=new
DefaultMutableTreeNode("root"); DefaultMutableTreeNode tr1=new DefaultMutableTreeNode("1");
root.add(tr1); DefaultMutableTreeNode tr11=new DefaultMutableTreeNode("1-1"); tr1.add(tr11);
DefaultMutableTreeNode tr111=new DefaultMutableTreeNode("1-1-1"); tr11.add(tr11);
DefaultMutableTreeNode tr112=new DefaultMutableTreeNode("1-1-2"); tr11.add(tr112);
DefaultMutableTreeNode tr12=new DefaultMutableTreeNode("1-2"); tr1.add(tr12); DefaultMutableTreeNode
tr2=new DefaultMutableTreeNode("2"); root.add(tr2); root.add(tr2); JTree tr=new JTree(root); JScorllPane
sp=new JScrollPane(tr); Container cp=getContentPane();
}}
340 Select missing statement in follow ing code /*<applet code="demo.class" w idth=300 height=200></applet>*/2 N A 2 setJMenuBar(mb);

341 select missing statement in follow ing code /*<applet code="demo.class" w idth="310" hieght="140"></applet 2 N U 2 cb.addActinListener

342 Select missing statement of follow ing code import java.aw t.*; import java.aw t.event.*; import java.applet.*; 2 N U 2 public void keyType
}

343 Select Proper code for given output 2 Y1 A 2 ItemListener


Figure:-

344 Select proper code for given output 2 Y1 A 2 import java.aw t.*;
Figure:- Applet { public void
con.add(&quot;Indi
con.add(&quot;Sou
code=&quot;ListDe

345 Select proper code for given output 2 Y1 A 2 importjava.aw t.*;


Figure:- Applet { public void
os.add(&quot;w nn
os.add(&quot;w nn
} /*&lt;applet code
&lt;/applet&gt;*/

346 Select Proper Command to run follow ing program import java.aw t.*; import java.aw t.event.*; class FrameDem
2 N A 2 java FrameDemo

347 Select proper sequence of follow ing classes used for w riting menudriven program 1.Menu 2. MenuBar 3. MenuI2 N A 2 2,1,3
348 Select sequence of the missing statements in the follow ing program import java.aw t.*; import java.aw 2 N U 2 ActionListener addA
t.event.*; public class MenuDemo extends Frame implements ___________________ { MenuDemo() {
MenuBar mbr = new MenuBar(); Menu filemenu = new Menu("File"); Menu editmenu = new Menu("Edit");
Menu view menu = new Menu("View "); mbr.add(filemenu); mbr.add(editmenu); MenuItem new 1 = new
MenuItem("New "); MenuItem open1 = new MenuItem("Open"); filemenu.add(new 1); filemenu.add(open1);
new 1.********; open1.**********; } public static void main(String args[]) { MenuDemo m = new
MenuDemo(); m.setSize(200,200); m.setTitle("Menu Demo Program"); m.setVisible(true); } public void
________________________ { if(new 1=ae.getsource()) { System.out.println("You Pressed New menu
Item"); } else if(ae.getSource()==open1) { System.out.println("You Pressed Open menu Item"); } } }

Select the correct code for the output show n


Figure:-

349 2 Y1 U 2 import java.aw t.*;


{ public void init()
TextArea(3,20); Ch
Checkbox c1=new
add(c); add(c1); }

350 Select the correct combination 2 N U 2 Button - ActionEvent Checkbox - It

351 Select the correct output for the follow ing program import java.aw t.*; import java.aw t.event.*; import 2 Y2 A 2 S1Q47Option i
javax.sw ing.*; import javax.sw ing.tree.*; /* <applet code="JTreeEvents" w idth=400 height=200>
</applet> */ public class JTreeEvents extends JApplet { JTree tree; JTextField jtf; public void init() { // Get
content pane Container contentPane = getContentPane(); contentPane.setLayout(new BorderLayout());
DefaultMutableTreeNode top = new DefaultMutableTreeNode("Options"); DefaultMutableTreeNode a = new
DefaultMutableTreeNode("A"); top.add(a); DefaultMutableTreeNode a1 = new DefaultMutableTreeNode("A1");
a.add(a1); DefaultMutableTreeNode a2 = new DefaultMutableTreeNode("A2"); a.add(a2);
DefaultMutableTreeNode b = new DefaultMutableTreeNode("B"); top.add(b); DefaultMutableTreeNode b1 =
new DefaultMutableTreeNode("B1"); b.add(b1); DefaultMutableTreeNode b2 = new
DefaultMutableTreeNode("B2"); b.add(b2); DefaultMutableTreeNode b3 = new
DefaultMutableTreeNode("B3"); b.add(b3); tree = new JTree(top); int v =
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED; int h =
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED; JScrollPane jsp = new JScrollPane(tree, v, h);
contentPane.add(jsp, BorderLayout.CENTER); jtf = new JTextField("", 20); contentPane.add(jtf,
BorderLayout.SOUTH); tree.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent me) { doMouseClicked(me); } }); } void doMouseClicked(MouseEvent
me) { TreePath tp = tree.getPathForLocation(me.getX(), me.getY()); if(tp != null) jtf.setText(tp.toString());
else jtf.setText(""); } }

352 Select the Listeners needed for components show n in application. Figure:- 2 Y1 U 2 actionPerformed(Ac
Select the method used for Event Handle import java.aw t.*; import java.aw t.event.*; import java.applet.*; pu

353 b1,b2,b3; public void init() { b1=new Button("Yes"); add(b1); b2=new Button("No"); add(b2); b3=new 2 N A 2 actionPerformed(Ac
Button("Exit"); add(b3); b1.addActionListener(this); b2.addActionListener(this); b3.addActionListener(this); }
public void _______________ { String str=ae.getActionCommand(); if(str.equals("Yes")) { msg="You
pressed Yes."; } else if(str.equals("No")) { msg="You pressed No."; } if(str.equals("Exit")) { msg="You
pressed Exit.";
} repaint(); } public void paint(Graphics g) { g.draw String(msg,6,100);} }

354 Select the method used to determine the event ID that represents the natures of the event 2 N U 2 public int getID()

355 Select the missing code in given statement import java.aw t.*; import java.applet.*; /* <applet code="Adapter 2 N U 2 both a &amp; b

356 Select the missing code in the program for follow ing output import java.aw t.*; import java.aw t.event.*; 2 Y1 A 2 addItemListener(th
public class MenuD extends Frame { MenuD( ) { addW indow Listener(new W indow Adapter(){ public void w
indow Closing(W indow Event w e) { System.exit(0); } }); } public static void main(String a[]) { MenuD
m=new MenuD(); CheckboxMenuItem debug,test; m.setVisible(true); MenuBar mbr=new MenuBar();
m.setMenuBar(mbr); Menu file=new Menu("File"); Menu edit= new Menu("edit"); mbr.add(file);
mbr.add(edit); MenuItem new 1=new MenuItem("New "); MenuItem open=new MenuItem("Open");
file.add(new 1); file.add(open); MenuItem copy=new MenuItem("Copy"); MenuItem paste=new
MenuItem("Paste"); copy.setEnabled(false); edit.add(copy); edit.add(paste); debug =new
CheckboxMenuItem("Debug"); test =new CheckboxMenuItem("Test"); edit.add(test); edit.add(debug); } }
Figure:-

357 Select the missing in the program import java.applet.*; import java.aw t.*; import java.aw t.event.*; public 2 Y1 A 2 Method missing for
class textfield extends Applet implements ActionListener { TextField nm,psw ; public void init() { Label
nml=new Label("username:",Label.RIGHT); Label psw l=new Label("passw ord:",Label.RIGHT); nm=new
TextField(12); psw =new TextField(8); Button b=new Button("submit"); add(nml); add(nm); add(psw );
add(b); nm.addActionListener(this); psw .addActionListener(this); b.addActionListener(this); } public void
actionPerformed(ActionEvent ae) { repaint(); } }
Figure:-
358 Select the missing statement public class A1 extends Applet { Button b1; Label l1; public void init() { 2 N A 2 b1.addActionListene
setLayout(new Flow Layout()); b1=new Button("Click"); l1=new Label(); add(l1); add(b1);
} public void actionPerformed(ActionEvent ae) { if(ae.getSource()==b1) l1.setText("Hello"); } }

359 Select the missing statement public class A1 extends Applet { Button b1; Label l1; public void init() { setLayout2 N A 2 add(l1); add(b1);

360 Select the missing statement in given code importjava.aw t.*; importjava.applet.*; /* <applet code="mouse" 2 N U 2 all of above
w idth=300 height=100> </applet> */ public class mouse extends Applet implements MouseListener,
MouseMotionListener { String msg = ""; intmouseX = 0, mouseY = 0 public void init() { } public void
mouseClicked(MouseEvent me) { mouseX = 0; mouseY = 10; msg
= "Mouse clicked."; repaint(); } public void mouseEntered(MouseEvent me) { mouseX = 0; mouseY = 10;
msg = "Mouse entered."; repaint(); } public void mouseExited(MouseEvent me) { mouseX = 0; mouseY =
10; msg = "Mouse exited."; repaint(); } public void mousePressed(MouseEvent me) { mouseX = me.getX();
mouseY = me.getY(); msg = "Dow n"; repaint(); } public void mouseReleased(MouseEvent me) { mouseX =
me.getX(); mouseY = me.getY(); msg = "Up"; repaint(); } public void mouseDragged(MouseEvent me) {
mouseX = me.getX(); mouseY = me.getY(); msg = "*"; show Status("Dragging mouse at " + mouseX + ", "
+ mouseY); repaint(); } public void mouseMoved(MouseEvent me) { show Status("Moving mouse at " +
me.getX() + ", " + me.getY()); } public void paint(Graphics g) { g.draw String(msg, mouseX, mouseY); } }

361 Select the missing statement in given code // Demonstrate the mouse event handlers. import java.aw t.*; 2 N A 2 addMouseListener(t
import java.applet.*; /* <applet code="mouse" w idth=300 height=100> </applet> java.aw t.event.*;
*/ public class mouse extends Applet implements MouseListener, MouseMotionListener { String msg = "";
intmouseX = 0, mouseY = 0; // coordinates of mouse public void init() { } // Handle mouse clicked. public
void mouseClicked(MouseEvent me) { mouseX = 0; mouseY = 10; msg = "Mouse clicked."; repaint(); } //
Handle mouse entered. public void mouseEntered(MouseEvent me) { mouseX = 0; mouseY = 10; msg =
"Mouse entered."; repaint(); } // Handle mouse exited. public void mouseExited(MouseEvent me) { mouseX
= 0; mouseY = 10; msg = "Mouse exited."; repaint(); } // Handle button pressed. public void
mousePressed(MouseEvent me) { mouseX = me.getX(); mouseY = me.getY(); msg = "Dow n"; repaint(); } //
Handle button released. public void mouseReleased(MouseEvent me) { mouseX = me.getX(); mouseY =
me.getY(); msg = "Up"; repaint(); } // Handle mouse dragged. public void mouseDragged(MouseEvent me) {
mouseX = me.getX(); mouseY = me.getY(); msg = "*"; show Status("Dragging mouse at " + mouseX + ", "
+ mouseY); repaint(); } // Handle mouse moved. public void mouseMoved(MouseEvent me) { show
Status("Moving mouse at " + me.getX() + ", " + me.getY()); } // Display msg in applet w indow at current
X,Y location. public void paint(Graphics g) { g.draw String(msg, mouseX, mouseY); } }

362 Select the missing statement in given code import java.lang.*; import java.aw t.*; import java.applet.*; ------- 2 N U 2 All of Above

public void w indow Iconified(W indow Event w e){} public void w indow Deiconified(W indow Event w e){} ----

363 Select the missing statement in given code import java.applet.*; import java.aw t.event.*; import java.aw 2 N U 2 addMouseListener(t
t.*; public class MouseClickExample extends Applet implements MouseListener { int
xpos; int ypos; int rect1xco,rect1yco,rect1w idth,rect1height; boolean mouseEntered; boolean rect1Clicked;
public void init() { rect1xco = 20; rect1yco = 20; rect1w idth = 100; rect1height =
50; } public void paint(Graphics g) { g.setColor(Color.green); g.fillRect(rect1xco,rect1yco,rect1w
idth,rect1height); g.setColor(Color.red); g.draw String(" ("+xpos+","+ypos+")",xpos,ypos); if (rect1Clicked)
g.draw String("You clicked in the Rectangle",20,120); else g.draw String("You clicked outside of the
rectangle",20,120); if (mouseEntered) g.draw String("Mouse is in the applet area",20,160); else g.draw
String("Mouse is outside the Applet area",20,160); } public void mouseClicked (MouseEvent me) { xpos =
me.getX(); ypos = me.getY(); if (xpos > rect1xco && xpos < rect1xco+rect1w idth && ypos
>rect1yco && ypos < rect1yco+rect1height) rect1Clicked = true; else rect1Clicked = false; repaint(); } public
void mousePressed (MouseEvent me) {} public void mouseReleased (MouseEvent me) {} public void
mouseEntered (MouseEvent me) { mouseEntered = true; repaint(); } public void mouseExited (MouseEvent
me) { mouseEntered = false; repaint(); } }
364 Select the missing statement in given code import javax.sw ing.*; import java.aw t.event.*; import javax.sw 2 N U 2 Both option A and B
ing.tree.*; import java.applet.*; public class exp5 extends JApplet { JTree tr; public void init() { Container
ContentPane=getContentPane(); ContentPane.setLayout(new Flow Layout()); DefaultMutableTreeNode
top=new DefaultMutableTreeNode("India"); DefaultMutableTreeNode mh=new
DefaultMutableTreeNode("Maharashtra"); DefaultMutableTreeNode mb=new
DefaultMutableTreeNode("Mumbai"); mh.add(mb); DefaultMutableTreeNode na=new
DefaultMutableTreeNode("Nashik"); mh.add(na); DefaultMutableTreeNode w b=new
DefaultMutableTreeNode("W est Bengal"); top.add(w b); DefaultMutableTreeNode ap=new
DefaultMutableTreeNode("Andra pradesh"); top.add(ap); DefaultMutableTreeNode tn=new
DefaultMutableTreeNode("TamilNadu"); top.add(tn); DefaultMutableTreeNode ch=new
DefaultMutableTreeNode("chennai"); tn.add(ch); DefaultMutableTreeNode kn=new
DefaultMutableTreeNode("Karnataka"); top.add(kn); DefaultMutableTreeNode bg=new
DefaultMutableTreeNode("Balgaum"); kn.add(bg); DefaultMutableTreeNode bl=new
DefaultMutableTreeNode("Bangalore"); kn.add(bl); tr=new JTree(top); int
v=ScrollPaneConstants.VERTICAL_SCROLLBAR_ALW AYS; int
h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALW AYS; JScrollPane jsp=new JScrollPane(tr,v,h);
ContentPane.add(jsp); tr.addMouseListener(new MouseAdapter() { public void MouseClicked(MouseEvent me)
{ doMouseClicked(me); } }); } void doMouseClicked(MouseEvent me) { TreePath
tp=tr.getPathForLocation(me.getX(),me.getY()); }
}

365 Select the missing statement in given code import java.applet.*; import java.aw t.event.*; import java.aw t.*; 2 N U 2 addW indow Listene

366 Select the missing statement in given code import java.aw t.*; import java.aw t.event.*; import java.applet.*; 2 N U 2 addKeyListener(this

367 Select the missing statement in given code import java.aw t.*; import java.applet.*; /* <APPLET Code="Action 2 N U 2 All of the above

if(ae.getSource()==b1) { b1.setBackground(Color.red); } if(ae.getSource()==b2) { b2.setBackground(Color.blu

368 Select the missing statement in given code import java.aw t.*; import java.aw t.event.*; class AEvent extends 2 N U 2 b.addActionListener

369 Select the missing statement in given code import java.aw t.*; import java.aw t.event.*; import java.applet.*; 2 N U 2 implements KeyList

370 Select the missing statement in given code import java.applet.*; import java.aw t.event.*; import java.aw t.*; 2 N U 2 actionPerformed(Ac
371 Select the missing statement in given code import java.aw t.*; import java.aw t.event.*; import 2 N U 2 os = new Choice();
java.applet.*; /* <applet code="ChoiceDemo" w idth=300 height=180> </applet> */ public class
ChoiceDemo extends Applet implements ItemListener { Choice os, brow ser; String msg = ""; public void
init() { // add items to os list os.add("W indow s 98/XP"); os.add("W indow s NT/2000"); os.add("Solaris");
os.add("MacOS"); // add items to brow ser list brow ser.add("Netscape 3.x"); brow ser.add("Netscape 4.x");
brow ser.add("Netscape 5.x"); brow ser.add("Netscape 6.x"); brow ser.add("Internet Explorer 4.0"); brow
ser.add("Internet Explorer 5.0"); brow ser.add("Internet Explorer 6.0"); brow ser.add("Lynx 2.4"); brow
ser.select("Netscape 4.x");
// add choice lists to w indow add(os); add(brow ser); // register to receive item events
os.addItemListener(this); brow ser.addItemListener(this); } public void itemStateChanged(ItemEvent ie) {
repaint(); } // Display current selections. public void paint(Graphics g) { msg = "Current OS: "; msg +=
os.getSelectedItem(); g.draw String(msg, 6,
120); msg = "Current Brow ser: "; msg += brow ser.getSelectedItem(); g.draw String(msg, 6,
140); } }

372 Select the missing statement in the follow ing code import java.aw t.*; class AppW indow extends Frame { 2 N A 2 Missing import java
AppW indow (String title) { super(title); this.addW indow Listener(new W indow Adapter() { public void w
indow Closing(W indow Event w e) { System.exit(0); } }); } public void paint(Graphics g) { g.draw
String("First Application W indow ",50,100); } public static void main(String args[]) { AppW indow app=new
AppW indow ("First W indow "); app.setSize(300,400); app.setVisible(true);
}}

373 Select the missing statement in the follow ing code import java.aw t.*; import java.aw t.event.*; import 2 N A 2 A and C are correct
java.applet.*; public class DemoChoice extends Applet { Choice ch; public void init() { ch=new Choice();
ch.add("A"); ch.add("B"); ch.add("C"); ch.addItemListener(this); } public void itemStateChanged(ItemEvent
ie) { if(ie.getSource()==ch) show Status(ch.getSelectedItem()); } }
/*<applet code="DemoChoice.class" w idth=300 height=200></applet>*/

Select the missing statement in the given code import javax.sw ing.*; import java.aw t.*; class CompDemo ext

374 label1=new Label("Name"); cpane.add(label1); JTextField jtextfield=new JTextField(15); cpane.add(jtextfield); 2 N U 2 Container cpane=jframe.getConte

375 Select the missing statement in the program import java.aw t.*; import java.aw t.event.*; public class combode2 N A 2 import javax.sw ing

376 Select the missing statement in the program import java.aw t.*; import java.aw t.event.*; import javax.sw 2 N A 2 jl = new JLabel(new
ing.*; /* <applet code="combodemo" w idth=300 height=100> </applet> */ public class combodemo
extends JApplet implementsItemListener { JLabeljl; ImageIconfrance, germany,
italy, japan; public void init() { Container contentPane = getContentPane(); contentPane.setLayout(new Flow
Layout()); JComboBoxjc = new JComboBox(); jc.addItem("France"); jc.addItem("Germany");
jc.addItem("Italy"); jc.addItem("Japan"); jc.addItemListener(this); contentPane.add(jc); contentPane.add(jl);
} public void itemStateChanged(ItemEventie) { String s = (String)ie.getItem(); jl.setIcon(new ImageIcon(s +
"star.gif")); } }

377 Select the missing statement in the program at ----------------------------- to get the follow ing output import 2 Y1 A 2 b1.addActionListene
java.aw t.*; import java.applet.*; import java.aw t.event.*; /* <APPLET Code="EventExample" W idth=200
Height=250> </APPLET> */ public class EventExample extends Applet implements ActionListener { Button
b1; TextField t1; public void init() { b1=new
Button("Message"); t1=new TextField(35); add(t1); add(b1); ---------------------------------- } public void
actionPerformed(ActionEvent ae) { if(ae.getSource()==b1) { t1.setText("Event Handling in Java"); } } }
Figure:-
378 Select the missing statement in the program at -----------------------------to get the follow ing output import 2 N A 2 b.addMouseListene
java.aw t.*; import java.aw t.event.*; import java.applet.*; public class Mouseclick extends Applet { int
fs=10; int x=10; int i=1; public void init() { Button b = new Button( "CLik"); add(b); ---------------------------
------------ } public void paint(Graphics g) { g.draw String("Hello Java",150,100+x); x=x+20; } class mouse
extends MouseAdapter { public void mouseClicked(MouseEvent me) { if(i<=10) { Font f=new Font("Times
new Roman",Font.BOLD,fs); fs=fs+2; Graphics g=getGraphics(); g.setFont(f); i++; paint(g); } } } }
/*<applet
code=Mouseclick w idth=500 height=500> </applet> */

Select the missing statement in the program for follow ing output import java.aw t.*; public class MenuDemo ex

379 Figure:- 2 Y1 A 2 mbr.add(view menu

380 Select the missing statement in the program for follow ing output import java.aw t.*; public class MenuDemo 2 Y1 A 2 mbr.add(view menu
extends Frame { public static void main(String args[]) { MenuDemo m = new MenuDemo();
m.setVisible(true); MenuBar mbr = new MenuBar(); m.setMenuBar(mbr); Menu filemenu = new Menu("File");
Menu editmenu = new Menu("Edit"); Menu view menu = new Menu("View "); mbr.add(filemenu);
mbr.add(editmenu); MenuItem new 1 = new MenuItem("New "); MenuItem open1 = new MenuItem("Open");
filemenu.add(new 1); filemenu.add(open1); } }
Figure:-
381 Select the missing statement in the program for follow ing output import java.aw t.*; public class MenuDemo 2 Y1 A 2 mbr.add(view menu
extends Frame { public static void main(String args[]) { MenuDemo m = new MenuDemo();
m.setVisible(true); MenuBar mbr = new MenuBar(); m.setMenuBar(mbr); Menu filemenu = new Menu("File");
Menu editmenu = new Menu("Edit"); Menu view menu = new Menu("View "); mbr.add(filemenu);
mbr.add(editmenu); MenuItem new 1 = new MenuItem("New "); MenuItem open1 = new MenuItem("Open");
filemenu.add(new 1); filemenu.add(open1); } }
Figure:-

382 Select the missing statement in the program for follow ing output import java.aw t.*; public class MenuDemo 2 N A 2 mbr.add(view menu
extends Frame { public static void main(String args[]) { MenuDemo m = new MenuDemo();
m.setVisible(true); MenuBar mbr = new MenuBar();
__________________________ Menu filemenu = new Menu("File"); Menu editmenu = new Menu("Edit");
Menu view menu = new Menu("View "); mbr.add(filemenu); mbr.add(editmenu); MenuItem new 1 = new
MenuItem("New "); MenuItem open1 = new MenuItem("Open"); filemenu.add(new 1); } }

383 Select the missing statement in the program for follow ing output import java.aw t.*; import java.aw 2 Y1 A 2 Both option A and B
t.event.*; class ListAction extends Frame { List list; Label label; public ListAction() { setTitle("List w ith
ItemListener Demo"); setSize(400,400); setLayout(new Flow Layout()); setLocationRelativeTo(null);
setVisible(true); list=new List(); label=new Label(); list.add("Apple"); list.add("Mango"); list.add("Guava");
list.add("Orange"); list.add("Pineapple"); list.add("Grapes"); list.addItemListener(new ItemListener() { public
void itemStateChanged(ItemEvent ie) { label.setText("You selected "+list.getSelectedItem()); } }); } public
static void main(String args[]) { new ListAction(); } }
Figure:-

384 Select the missing statement in the program for follow ing output import java.aw t.*; import java.aw 2 Y1 A 2 Both option A and B
t.event.*; class ListAction extends Frame { List list; Label label; public ListAction() { setTitle("List w ith
ItemListener Demo"); setSize(400,400); setLayout(new Flow Layout()); setLocationRelativeTo(null);
setVisible(true); list=new List(); label=new Label(); list.add("Apple"); list.add("Mango"); list.add("Guava");
list.add("Orange"); list.add("Pineapple"); list.add("Grapes"); list.addItemListener(new ItemListener() { public
void itemStateChanged(ItemEvent ie) { label.setText("You selected "+list.getSelectedItem()); } }); } public
static void main(String args[]) { new ListAction(); } }
Figure:-
385 select the missing statement in the program for the follow ing output import java.aw t.*; import java.aw 2 Y1 U 2 red.addActionListen
t.event.*; import java.applet.*; /*<applet code=ColorChange w idth=250 height=300>
</applet>*/ public class ColorChange extends Applet implements ActionListener { Button red; public void
init() { red=new Button("RED"); add(red); } public void actionPerformed(ActionEvent e) {
setBackground(Color.red); repaint(); } }
Figure:-

386 Select the missing statement in the program to get correct output. import java.aw t.*; import javax.sw ing.*; /*2 N U 2 All the above

387 Select the missing statement in the program to get the correct output import java.aw t.*; import java.applet.*; 2 N A 2 b1.addActionListene

388 Select the missing statement in the program to get the correct output import java.aw t.*; import javax.sw 2 N A 2 JScrollPane jsp=new
ing.*; public class JScrollPaneDemo extends JApplet { public void init() { 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<20;i++) { for(int j=0;j<20;j++) { jp.add(new
JButton("Button"+b)); ++b; } } int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED; int
h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED; -----------------------------------------
------------ contentPane.add(jsp,BorderLayout.CENTER); } }

Select the missing statement in the program to get the follow ing output importjava.aw t.*; importjava.aw t.eve

389 JComboBox(); jc.addItem("France"); jc.addItem("Germany"); jc.addItem("Italy"); jc.addItem("Japan"); jc.addIt2 N A 2 itemStateChanged(ItemEvent ie)


390 Select the missing statement in the program to get the follow ing output importjava.aw t.*; importjava.aw 2 Y1 A 2 itemStateChanged(
t.event.*; importjavax.sw ing.*; /* <applet code="combodemo" w idth=300 height=100> </applet> */
public class combodemo extends JApplet implementsItemListener { JLabeljl; ImageIconfrance, germany,
italy, japan; public void init() { Container contentPane = getContentPane(); contentPane.setLayout(new Flow
Layout()); JComboBoxjc = new JComboBox(); jc.addItem("France"); jc.addItem("Germany");
jc.addItem("Italy"); jc.addItem("Japan"); jc.addItemListener(this); contentPane.add(jc); contentPane.add(jl);
} public void itemStateChanged(ItemEvent ie) { String s = (String)ie.getItem(); jl = new JLabel("star.gif");
jl.setIcon(new ImageIcon(s + ".gif")); } } C. jl = new JLabel( ImageIcon("star.gif")); D. JLabel(new
ImageIcon("star.gif"));
Figure:-

391 Select the missing statement in the program. import java.aw t.event.*; import javax.sw ing.*; public class 2 N A 2 ActionListener,addA
S1Q47 extends JFrame implements ************** { JRadioButton rb1,rb2; String msg; public S1Q47() {
rb1 = new JRadioButton("Select Me") ; rb1.addActionListener(this); rb2 = new JRadioButton("Select Me") ;
rb2.*************(this); add(rb1); add(rb2); setVisible(true); setSize(200,200);
setDefaultCloseOperation(S1Q47.EXIT_ON_CLOSE); } public void **********
{ System.out.println("Radion button selected"); } public static void main(String arg[]) { S1Q47 s
= new S1Q47(); } } }

392 Select the missing statements at --------------------- for follow ing program: import java.aw t.*; import java.app2 N U 2 import java.aw t.ev
b.addActionListener

393 Select the missing statements at ---------------------in bellow program import java.aw t.*; import java.aw 2 N U 2 both A and B
t.event.*; import java.applet.*; /*<applet code=keydemo w idth=400 height=400>
</applet>*/ public class keydemo extends Applet implements KeyListener { String msg=""; int i=0; public
void init() { ------------------------------ } public void keyPressed(KeyEvent e) { ------------
---------------- msg=e.getKeyChar()+""; repaint(); sw itch(i) { case KeyEvent.VK_UP: show Status("up key
pressed"); break; case KeyEvent.VK_DOW N: show Status("Dow n key pressed"); break; case
KeyEvent.VK_ENTER: show Status("Enter key pressed"); break; case KeyEvent.VK_LEFT: show Status("left
key pressed"); break; case KeyEvent.VK_RIGHT: show Status("right key pressed"); break; default : show
Status("nothing to print"); } } public void keyReleased(KeyEvent e) { show Status("Key released"); } public
void keyTyped(KeyEvent e) { msg=e.getKeyChar()+""; repaint(); } public void paint(Graphics g) { g.draw
String(msg,100,100);
}}

Select the missing statements in given code import java.aw t.*; import java.applet.*; /* <applet code="mouse

394 implements MouseMotionListener { String msg = ""; intmouseX = 0, mouseY = 0 public void init() 2 N U 2 import java.aw t.ev
{ } public void mouseDragged(MouseEvent me) { mouseX = me.getX(); mouseY = me.getY(); msg = "*";
show Status("Dragging mouse at " + mouseX + ", " + mouseY); repaint(); } public void
mouseMoved(MouseEvent me) { show Status("Moving mouse at " + me.getX() + ", " + me.getY()); } public
void paint(Graphics g) { g.draw String(msg, mouseX, mouseY); } }

395 Select the missing statements in the follow ing code import java.aw t.*; import java.applet.*; import java.aw t. 2 N A 2 t1=new TextField()
396 Select the Missing Statment in Program import java.aw t.*; import java.aw t.event.*; import java.applet.*; /* 2 N U 2 add(yes); add(no);
<applet code="ButtonDemo" w idth=250 height=150> </applet> */ public class ButtonDemo extends Applet
implements ActionListener { String msg = ""; Button yes, no, maybe; public void init() { yes = new
Button("Yes"); no = new Button("No"); maybe = new Button("Undecided"); ----------------------- --------------
-------- ----------------------- yes.addActionListener(this); no.addActionListener(this);
maybe.addActionListener(this); } public void actionPerformed(ActionEvent ae) { String str =
ae.getActionCommand(); if(str.equals("Yes")) { msg = "You pressed Yes."; } else if(str.equals("No")) { msg
= "You
pressed No."; } else { msg = "You pressed Undecided."; repaint(); } } public void paint(Graphics g) { g.draw
String(msg, 6, 100); } }

397 Select the proper code for the problem statement given below : Problem statement: Develope a prgram to 2 N A 2 import java.aw t,*;
display a button w ith a image icon on it using sw ing.The image on the button w ill change w hen the button
is clicked.

398 Select the proper command to run the follow ing code import java.aw t.*; import java.applet.*; import 2 N A 2 java fact
java.aw t.event.*; /*<applet code=fact.java w idth=400 height=400> </applet>*/ public class fact extends
Frame implements ActionListener { TextField t1,t2; Label l1,l2; Button b1; fact(String title) { super(title);
t1=new TextField(20); t2=new TextField(20); l1=new Label("ENTER NO"); l2=new Label("output"); b1=new
Button("find factorial"); setLayout(new GridLayout(3,2)); add(l1); add(t1); add(l2); add(t2); add(b1);
b1.addActionListener(this); addW indow Listener(new W indow Adapter() { public void w indow Closing(W
indow Event e) { System.exit(0); } }); } public static void main(String args[]) { fact f=new fact("factorial
example"); f.setVisible(true); f.setSize(300,300); } public void actionPerformed(ActionEvent ae) { String s;
int n; int fact=1; String s1=ae.getActionCommand(); if(s1.equals("find factorial")) { s=t1.getText();
n=Integer.parseInt(s); for(int i=1;i<=n;i++) { fact=fact*i; s=""+fact; t2.setText(s); } } } }

399 Select the proper command to run the follow ing code import java.aw t.*; import java.aw t.event.*; import java2 N A 2 appletview er comb

400 Select the proper method at _____________________ import java.aw t.*; import java.applet.*; import 2 N U 2 getActionCommand
java.aw t.event.*; public class applet2 extends Applet implements ActionListener { public void init() { Button
r=new Button("RED"); r.addActionListener(this); Button g=new Button("GREEN"); g.addActionListener(this);
Button b=new Button("BLUE"); b.addActionListener(this); add(r); add(g); add(b); } public void
actionPerformed(ActionEvent arg)
{ String click=arg._________________________(); if(click.equals("RED"))
setBackground(Color.red); else if(click.equals("GREEN")) setBackground(Color.green); else

if(click.equals("BLUE")) setBackground(Color.blue); } }
401 Select the proper method that can be used to handle the event import javax.sw ing.*; import java.aw t.*; 2 N A 2 actionPerformed(Ac
import java.aw t.event.*; public class JRadioDemo extends JApplet implements ActionListener { JRadioButton
r1,r2,r3; Container c; public void init() { c=getContentPane(); c.setLayout(new Flow Layout()); r1=new
JRadioButton("Red"); r2=new JRadioButton("Green"); r3=new JRadioButton("Blue"); ButtonGroup b=new
ButtonGroup(); b.add(r1);b.add(r2);b.add(r3); c.add(r1);c.add(r2);c.add(r3); r1.addActionListener(this);
r2.addActionListener(this); r3.addActionListener(this); } public void
_____________________________ { if(a.getSource()==r1) c.setBackground(Color.RED); else
if(a.getSource()==r2) c.setBackground(Color.GREEN); else c.setBackground(Color.BLUE); } } /*
<applet code=JRadioDemo.class w idth=500 height=500></applet>*/

402 Select the proper method to handle event in the follow ing program. import java.aw t.*; import java.aw 2 N U 2 adjustmentValueCh
t.event.AdjustmentEvent; import java.aw t.event.AdjustmentListener; import java.aw t.event.W indow
Adapter; import java.aw t.event.W indow Event; public class AdjustmentEventExample { public static void
main(String[] args) { Frame frame = new Frame("AdjustmentEventExample"); Label label = new Label("W
elcome To Java Programing"); Scrollbar h = new Scrollbar(Scrollbar.HORIZONTAL, 30, 20, 0, 300); Scrollbar v
= new Scrollbar(Scrollbar.VERTICAL, 30, 40, 0, 300); frame.setLayout(new BorderLayout()); frame.add(h,
BorderLayout.SOUTH); frame.add(v, BorderLayout.EAST); frame.add(label, BorderLayout.CENTER);
AdjustmentListener ad = new MyAdjustmentListener(); h.addAdjustmentListener(ad);
v.addAdjustmentListener(ad); frame.setSize(400, 400); frame.setVisible(true); frame.addW indow
Listener(new W indow Adapter() { public void w indow Closing(W indow Event e) { System.exit(0); } }); } }
class MyAdjustmentListener implements AdjustmentListener { public void
_____________________________________________ { System.out.println(ae.getValue()); }
}

403 select the proper methods of mouse motion listener 2 N U 2 void mouseMoved(MouseEvent me
404 Select the proper output for follow ing code import java.aw t.BorderLayout; import java.aw t.event.ActionEvent;2 Y2 A 2

405 Select the proper output for follow ing code import java.applet.Applet; import java.aw t.*; import java.applet.*;2 Y2 U 2 A

406 Select the proper output for follow ing code import java.aw t.*; import java.applet.*; public class S1Q31 extend2 Y2 U 2

407 Select the proper output for follow ing code import java.aw t.*; import java.aw t.event.*; import 2 Y2 A 2 S1Q47O1
java.applet.*; public class Demo extends Applet implements ItemListener { Checkbox cb1,cb2,cb3; public
void init() { cb1=new Checkbox("Red"); cb2=new Checkbox("Green"); cb3=new Checkbox("Blue"); add(cb1);
add(cb2); add(cb3); cb1.addItemListener(this); cb2.addItemListener(this); cb3.addItemListener(this); }
public void itemStateChanged(ItemEvent ie) { if(ie.getSource()==cb1) setBackground(Color.RED); else
if(ie.getSource()==cb2) setBackground(Color.YELLOW ); else setBackground(Color.BLUE); } } /*
<applet code="Demo.class" w idth=300 height=200></applet>*/

408 Select the proper output for follow ing code import java.aw t.*; import java.util.*; import javax.sw ing.tree.*; 2 Y2 U 2
class JMyTree extends JFrame { Container con; JTree jt1; Vector v; JMyTree()
{ con=this.getContentPane(); con.setLayout(new Flow Layout());
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); v=new Vector(); v.addElement("My Computer");
v.addElement("D Drive"); v.addElement("E Drive"); jt1=new JTree(v); con.add(jt1);
} public static void main(String a[]) { JMyTree jf=new JMyTree(); jf.setSize(300,400);
jf.setVisible(true); } }

409 Select the proper output for follow ing code importjava.aw t.*; importjava.applet.*; public class list2 extends Ap2 Y2 A 2

410 select the proper output for the follow ing code import java.aw t.event.*; public class eh extends Applet implem2 Y2 A 2

411 Some of the event listener interfaces are_____________ 2 N A 2 All of these

412 State listener w ith its method used in follow ing program import java.aw t.*; import java.aw t.event.*; 2 N A 2 ActionListener,actio
import java.applet.*; /* <applet code=exp2.class w idth=200 height=200 >
</applet>*/ public class exp2 extends Applet implements ActionListener { TextField t1,t2; Button b1; Label
l1,l2; public void init() { t1=new TextField(5); t2=new TextField(5); b1=new Button("Factorial"); l1=new
Label("Enter no"); l2=new Label("Factorial is :"); add(l1); add(t1); add(b1); add(l2); add(t2);
b1.addActionListener(this); } public void actionPerformed(ActionEvent ae) { if(ae.getSource()==b1) { int
n1=Integer.parseInt(t1.getText()); int fact=1,i; for(i=1;i<=n1;i++) { fact=fact*i; }
t2.setText(Integer.toString(fact)); } } }
413 State the missing statement in the program for follow ing output import javax.sw ing.*; public class MyMenu 2 Y1 A 2 all of the above
{ public static void main(String args[]) { JFrame frame; JMenuBar mb; frame=new JFrame("Frame w ith a
Menu"); mb=new JMenuBar(); frame.setJMenuBar(mb); JMenu mFile,mEdit; mFile=new JMenu("File");
mEdit=new JMenu("Edit"); JMenuItem mNew ,mClose,mCopy,mPaste; mNew =new JMenu("New ");
mClose=new JMenu("Close"); mCopy=new JMenu("Copy"); mPaste=new JMenu("Paste"); mFile.add("mNew
"); mFile.add("mclose"); mEdit.add("mCopy"); mEdit.add("mPaste"); JCheckBoxMenuItem mPrint;
mPrint=new JCheckBoxMenuItem("Print"); mFile.addSeparator(); JMenu mFont; mFont=new JMenu("Font");
mFile.add(mFont); mFont.add("Arial"); mFont.add("Times New Roman"); frame.setSize(400,400);
frame.setVisible(true); } }
Figure:-

414 state the output in follow ing code import java.aw t.*; import java.applet.*; import java.aw t.event.*; public 2 N A 2 sb1 Scrollbar is disp
class Scrollbarapp extends Applet implements AdjustmentListener { Scrollbar sb1,sb2; @Override public void
init() { // TODO Auto-generated method stub sb1=new Scrollbar(); sb2=new
Scrollbar(Scrollbar.HORIZONTAL, 200,0, 0, 500); add(sb1); add(sb2); sb2.addAdjustmentListener(this); }
@Override public void adjustmentValueChanged(AdjustmentEvent e) { // TODO Auto-generated method stub
repaint();
} @Override public void paint(Graphics g) { // TODO Auto-generated method stub

g.draw String("Value = "+sb2.getValue(), 100, 200); } }


415 Suppose A is an inner class in Test. A is compiled into a file named _________. 2 N A 2 Test.class

416 The AW T container is an instance of the ___________ class w hich holds various components and other contain2 N U 2 Container

417 The constructor that is defined by the Text Event class is: 2 N U 2 TextEvent(Obect source,int event_

418 The focusEvent can be recognized by tw o integer constant. 2 N U 2 Focus_Gained and Focus_Lost

419 The follow ing program contains some errors. Select the correct option to indicate them. import java.aw t.*; imp2 N A 2 Incorrect Listener m

420 The follow ing program w ill increase the font size of a given string by 2 point w ith every mouse click(max 10 2 N A 2 addMouseListener(t
clicks). Select the missing statement and indicate w here the statement should be added. import java.aw t.*;
import java.applet.*; import java.aw t.event.*; public class sample4 extends Applet implements
MouseListener { Font f; int i=0,c=14; public void init() { f=new Font("Times New Roman",Font.BOLD,c);
setFont(f); } public void mousePressed(MouseEvent me)
{ if(i<10) { c=c+2; f=new Font("Times New Roman",Font.BOLD,c); setFont(f); } i=i+1; } public void
mouseClicked(MouseEvent me) {} public void mouseReleased(MouseEvent me) {} public void
mouseEntered(MouseEvent me) {} public void mouseExited(MouseEvent me) {} public void paint(Graphics g)
{ g.draw String("Java prog",50,50); } }

421 The follow ing steps are required to perofrm 1) implement the Listener interface and overrides its methods 2) R 2 N U 2 Event Handling

422 The follow ing w indow Event defined by W indow Event Class. 2 N U 2 W indow _Activated,W indow _ICONI

423 The given code produces w hich event : import java.aw t.*; import java.applet.*; import java.aw t.event.*; 2 N A 2 Action Listner
/*<applet code=Fact height=150 w idth=200> </applet>*/ public class Fact extends Applet implements
ActionListener { int fact,n; TextField t1,t2; Button b1; Label l1,l2; public void init() { t1= new TextField(5);
t2= new TextField(5); l1= new Label("Enter number"); l2= new Label("Factorial is:"); b1=new Button("Find
Factorial"); b1.addActionListener(this);
//GridLayout g= new GridLayout(5,2); //setLayout(g); add(l1); add(t1); add(l2); add(t2); add(b1); } public
void actionPerformed(ActionEvent e) { if(e.getSource()==b1) { n= Integer.parseInt(t1.getText()); fact=1;
for(int i=1; i<=n; i++) { fact=fact*i; } t2.setText(Integer.toString(fact)); } repaint(); } }

424 The signature for the registration method for an ActionEvent should be __________. 2 N A 2 public void addActionListener(Actio
425 The value typed in TextArea is notified by________________Listener. 2 N A 2 TextListener

426 The _________ interface handles list event? 2 N U 2 ItemListener

427 The ______________ class has tw o methods, mouseDragged() and mouseMoved() 2 N U 2 MouseMotionListener

428 To register a checkbox to event class follow ing statement must be get included in your program 2 N A 2 Both A &amp; B

To get the follow ing output complete the code given below . import java.aw t.*; import javax.sw ing.*; /* JPaneljp = new JPa
<applet code="jscroll" w idth=300 height=250> </applet> */ public class jscroll extends JApplet { public
void init() { Container contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); } } int
v = ScrollPaneConstants.VERTICAL_SCROLLBAR_ALW AYS; int h =
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED; JScrollPanejsp = new
JScrollPane(jp, v, h); contentPane.add(jsp, BorderLayout.CENTER); } } Figure:-

429 2 Y1 U 2 for(int i = 0; i &lt;3


JButton(&quot;Butt

430 To get the follow ing output complete the code given below . import java.aw t.*; import java.aw t.event.*; 2 Y1 U 2 table = new JTable
import javax.sw ing.*; class SimpleTableExample extends JFrame { private JPanel topPanel; private JTable JScrollPane( table )
table; private JScrollPane scrollPane; public SimpleTableExample() { setTitle( "Simple Table Application" );
setSize( 300, 200 ); setBackground( Color.gray ); topPanel = new JPanel(); topPanel.setLayout( new
BorderLayout()
); getContentPane().add( topPanel ); String columnNames[] = { "Column 1", "Column 2", "Column 3" };
String dataValues[][] = { { "12", "234", "67" }, { "-123", "43", "853" }, { "93", "89.2", "109" }, { "279",
"9033", "3092" } }; topPanel.add( scrollPane, BorderLayout.CENTER );
} public static void main( String args[] ) { SimpleTableExample mainFrame = new
SimpleTableExample(); mainFrame.setVisible( true ); } } Figure:-

431 To get the proper output complete the code given below . import java.aw t.*; import java.aw t.event.*; 2 N U 2 All of the above
import java.applet.*; public class DemoKeyEvent extends Applet implements KeyListener { public void init() {
this.addKeyListener(this); } public void keyTyped(KeyEvent ke)
{ show Status("Key Typed"); } } /*<applet code="DemoKeyEvent.class" w idth=300 height=300>
</applet>*/

432 To handle JRadiobutton w hich Listener and Event Class is Required? Figure:- 2 Y1 U 2 ActionListener and
433 To have the follow ing output Inser proper commands in the given code at*__________________ import 2 Y2 A 2 JApplet implements
java.aw t.*; import java.aw t.event.*; import java.applet.*; import javax.sw ing.*; /*<applet
code="SimpleKey1.class" w idth=400 height=400></applet>*/ public class SimpleKey1 extends
*_________________________________________________
{ String msg=""; int x=10,y=20; public void init() { addKeyListener(this); requestFocus(); } public void
*___________________________________ { show Status("Key Dow n"); } public void
keyReleased(KeyEvent ke) { show Status("Key Up"); } public void keyTyped(KeyEvent ke) { msg
+=ke.getKeyChar(); repaint(); } public void paint(Graphics g) { g.draw String(msg,40,80); }
}

434 To use the ActionListener interface it must be implemented by class there are several w ays to do that find in th2 N U 2 D. All mentioned ab

435 User clicks a button, presses Return w hile typing in a text field, or chooses a menu item w ill use the follow ing2 N A 2 ActionListener

436 W hat type of eventlisteners can be added to the follow ing code import java.aw t. Container; import java.aw t. 2 N A 2 C. both A and B

437 w hat are the content are show n by follow ing code import java.aw t.*; import javax.sw ing.*; public class 2 N A 2 The output contains
JTabbedPaneDemo extends JApplet { public void init() { JTabbedPane jtp = new JTabbedPane(); ith JPanel
jtp.addTab("Cities", new ButtonPanel()); jtp.addTab("Table", new TablePanel()); jtp.addTab("flavours", new
flavoursPanel()); jtp.addTab("colours", new ColorsPanel());
Container contentPane = getContentPane(); contentPane.add(jtp); } } class ButtonPanel extends JPanel {
public ButtonPanel() { JButton b1 = new JButton("Parbhani"); JButton b2 = new JButton("Pune"); JButton b3
= new JButton("Mumbai"); JButton b4 = new JButton("Aurangabad"); JButton b5 = new JButton("Nanded");
add(b1); add(b2); add(b3); add(b4); add(b5); } } class ColorsPanel extends JPanel { public ColorsPanel() {
JCheckBox cb1=new JCheckBox("Red"); add(cb1); JCheckBox cb2=new JCheckBox("Green"); add(cb2);
JCheckBox cb3=new JCheckBox("Blue"); add(cb3); } } class TablePanel extends JPanel { public TablePanel()
{ String colHead[] = {"Event Source", "Event Type", "Event Listener"}; Object data[][] = { {"Button",
"ActionEvent", "ActionListener"}, {"ScrollBar", "AdjustmentEvent", "AdjustmentListener"}, {"Choice",
"ItemEvent", "ItemListener"}, {"TextField", "TextEvent", "TextListener"} }; JTable table = new JTable(data,
colHead); int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED; int h =
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED; JScrollPane jsp = new JScrollPane(table, v, h);
setLayout(new BorderLayout()); add(jsp, BorderLayout.CENTER); } } class flavoursPanel extends JPanel {
public flavoursPanel() { JComboBox jc=new JComboBox();
jc.addItem("vannila"); jc.addItem("Chocolate"); jc.addItem("strabary"); add(jc); } } W hat w ill be the output
of the above program?

W hat are the minimum pakages required for executing the bellow program? class MyDemo extends Frame { Bu

438 Button("OK"); add(b); b.addActionListener(this); setLayout(new Flow Layout()); } public void actionPerformed( 2 N U 2 java.aw t.* and java.aw t.event.*

439 W hat error w ill occur w hile running given applet? import java.aw t.*; import java.aw t.event.*; import java.ap2 N A 2 NullPointerExceptio
440 W hat is error in follow ing program? import java.aw t.*; import java.aw t.event.*; import java.applet.*; /* <ap2 N A 2 ScrollDemo is not a
adjustmentValueCh
ScrollDemo extends

441 W hat is missing in follow ing code ? import java.aw t.*; import java.applet.*; /*<applet code=FontExample.cla2 N A 2 setFont(f)

442 W hat is missing in the follow ing program code? import java.aw t.*; ------------------------- public class DemoF 2 N U 2 All of the mentione

443 W hat is missing statement here ------------------ import java.aw t.*; import javax.sw ing.*; import java.aw 2 N A 2 All of the above
t.event.*; public class Radiodemo extends JFrame implements ActionListener { Container cp; JRadioButton
jb1,jb2,jb3; Radiodemo(String str) { super(str); cp=getContentPane(); cp.setLayout(new Flow Layout());
jb1=new JRadioButton("Red"); jb2=new
JRadioButton("Green"); jb3=new JRadioButton("Blue"); ButtonGroup bg=new ButtonGroup(); bg.add(jb1);
bg.add(jb2); bg.add(jb3); cp.add(jb1); cp.add(jb2); cp.add(jb3); } public void actionPerformed(ActionEvent
ae) { if(ae.getSource()==jb1) { cp.setBackground(Color.red); } if(ae.getSource()==jb2) {
cp.setBackground(Color.green); } if(ae.getSource()==jb3) { cp.setBackground(Color.blue); } } public static
void main(String args[]) { Radiodemo r=new Radiodemo("Changing Color"); r.setVisible(true);
r.setSize(500,400); } }

444 W hat is output of follw ong program ? import java.aw t.*; import java.aw t.event.*; public class MyW c extends2 N A 2 Error at compile tim

445 W hat is output of follow ing code. import java.aw t.*; import java.aw t.event.*; import java.applet.*; /* 2 Y2 A 2
<applet code="SimpleKey" w idth=300 height=100> </applet> */ public class KeyEventDemo extends
Applet implements KeyListener { String msg = ""; int X = 10, Y = 20; public void init() {
addKeyListener(this); requestFocus(); } public void keyPressed(KeyEvent ke)
{ show Status("Key Dow n"); } public void keyReleased(KeyEvent ke) { show Status("Key Up"); } public void
keyTyped(KeyEvent ke) { msg += ke.getKeyChar(); repaint(); } // Display keystrokes. public void
paint(Graphics g) { g.draw String(msg, X, Y); } }

W hat is output of follow ing program? import java.applet.Applet; import java.aw t.Graphics; import java.aw t.B

446 </applet> */ public class DetermineIfButtonEnabled extends Applet{ boolean isButton1Enabled; boolean 2 Y1 U 2 Is Button 1 enabled
isButton2Enabled; public void init(){ //create Buttons Button Button1 = new Button("Ok"); Button Button2 =
new Button("Cancel"); //add Buttons add(Button1); add(Button2); Button1.setEnabled(false);
isButton1Enabled = Button1.isEnabled(); isButton2Enabled = Button2.isEnabled(); } public void
paint(Graphics g){ g.draw String("Is
Button 1 enabled? " + isButton1Enabled, 10,50); g.draw String("Is Button 2 enabled? " +
isButton2Enabled, 10,70); } } Figure:-

447 W hat is the correct code to create Button w ith caption Ok? 2 N A 2 None of above
448 W hat is the correct syntax of method required in the given program given below . import java.aw t.*; import 2 N A 2 public void itemSta
java.aw t.event.*; import java.applet.*; public class eventdemo extends Applet implements ItemEvent {
public void init() { Choice c= new Choice(); TextField t1=new TextField(); add(c); c.addItemListener(this);
add(t1); } public void
_______________________(___________) { { t1.setText(c.getSelectedIteml()); } } }

449 W hat is the highest-level event class of the event-delegation model? 2 N U 2 java.util.eventObject

450 W hat is the missing Exception in follow ing program /* <applet code="TestMouse.class" w idth=300 2 N A 2 both A &amp; B
height=100> </applet> */ importjava.aw t.*; importjava.aw t.event.*; importjava.applet.*; public class
TestMouse extends Applet implements_____________________ { String msg = ""; intmouseX = 0, mouseY
= 0 public void init() { addMouseListener(this); addMouseMotionListener(this); } public void
mouseClicked(MouseEvent me) { mouseX = 0; mouseY = 10; msg = "Mouse clicked."; repaint();
} public void mouseEntered(MouseEvent me) { mouseX = 0; mouseY = 10; msg = "Mouse entered.";
repaint(); } public void mouseExited(MouseEvent me) { mouseX = 0; mouseY = 10; msg = "Mouse exited.";
repaint(); } public void mousePressed(MouseEvent me) { mouseX = me.getX(); mouseY = me.getY(); msg =
"Dow n"; repaint(); } public void mouseReleased(MouseEvent me) { mouseX = me.getX(); mouseY =
me.getY(); msg = "Up"; repaint(); } public void mouseDragged(MouseEvent me) { mouseX = me.getX();
mouseY = me.getY(); msg = "*"; show Status("Dragging mouse at " + mouseX + ", " + mouseY); repaint();
} public void mouseMoved(MouseEvent me) { show Status("Moving mouse at " + me.getX() + ", "
+ me.getY()); } public void paint(Graphics g) { g.draw String(msg, mouseX, mouseY); } }

451 W hat is the missing in follow ing block of code? Public class JTextField extends JApplet { JTextField jtf; Public v2 N A 2 semicolon missing

452 W hat is the output of follow ing program : import java.aw t.*; import java.aw t.event.*; import java.applet.*; /2 N A 2 Key Up

453 w hat is the output of this program import java.aw t.*; import java.aw t.event.*; public class CloseDemo3 { pub2 N A 2 W indow is closed

454 W hat is the output of this program? Figure:- 2 Y1 A 2 W ill not show any

455 W hat is the output of this program? import java.aw t.*; import java.applet.*; import java.aw t.event.*; /*<app2 Y2 A 2

456 W hat is the preferred w ay to handle an object's events in java? 2 N A 2 Add one or more event listener to

457 W hat is the return type of the method getSource() defined in EventObject class. Select the one correct answ er 2 N U 2 object
458 W hat is use of of using action listeners in the follow ing program? import java.applet.*; import java.aw 2 N A 2 To handle the even
t.event.*; import java.aw t.*; public class EventListeners extends Applet implements ActionListener{
TextArea txtArea; String Add, Subtract,Multiply,Divide; int i = 10, j = 20, sum
=0,Sub=0,Mul = 0,Div = 0; public void init(){ txtArea = new TextArea(10,20); txtArea.setEditable(false);
add(txtArea,"center"); Button b = new Button("Add"); Button c = new Button("Subtract"); Button d = new
Button("Multiply"); Button e = new Button("Divide"); b.addActionListener(this); c.addActionListener(this);
d.addActionListener(this); e.addActionListener(this); add(b); add(c); add(d); add(e); } public void
actionPerformed(ActionEvent e){ sum = i + j; txtArea.setText(""); txtArea.append("i = "+ i + "\t"
+ "j = " + j + "\n"); Button source = (Button)e.getSource(); if(source.getLabel() == "Add"){
txtArea.append("Sum : " + sum + "\n"); } if(i >j){ Sub = i - j; } else{ Sub = j - i; } if(source.getLabel() ==
"Subtract"){ txtArea.append("Sub : " + Sub + "\n"); } Mul = i*j; if(source.getLabel() == "Multiply"){
txtArea.append("Mul = " + Mul + "\n"); } if(i > j){ Div = i / j; } else{ Div = j / i; } if(source.getLabel() ==
"Divide"){ txtArea.append("Divide = " + Div); } } }
Here is the HTML code of the program : <HTML> <BODY> <APPLET CODE ="EventListeners" W IDTH="800"
HEIGHT="500"></APPLET> </BODY> </HTML>

459 W hat is w rong in below program import java.aw t.*; import java.aw t.event.*; import java.applet.*; /*<apple 2 N A 2 The keydemo class

460 W hat method is used to handle item events from menus, checkboxes, and radio buttons? 2 N U 2 itemStateChanged()

W hat should be added so that w e can get follow ing output ? import java.aw t.*; import java.aw t.event.*; imp

461 Figure:- 2 Y1 A 2 cbg should be adde

462 W hat should be w ritten for ****** in follow ing code ? import java.aw t.*; import java.aw t.event.*; import 2 N A 2 AdjustmentValueCh
java.applet.*; /*<applet code=ScrollDemo.class height=400 w idth=600></applet>*/ public class
ScrollDemo extends Applet implements AdjustmentListener
{ Scrollbar v; public void init() { v=new Scrollbar(); add(v); v.addAdjustmentListener(this); }
public void *****************(AdjustmentEvent ae) { } }

463 W hat w ill be correct code for given output 2 Y1 A 2 import java.aw t.*;
Figure:- class assign extend
ButtonGroup bg; pu
ContentPane=getCo
Layout()); JRadioBu

464 W hat w ill be output for follow ing program: import java.aw t.*; import java.applet.*; import java.aw t.event.* 2 Y2 A 2 Compile time error

465 W hat w ill be output if user select second item from choice component in follow ing program: import java.aw t. 2 Y2 A 2 S1Q50O2
466 W hat w ill be output of follow ing code import javax.sw ing.*; import javax.aw t.*; public class Test extends JF 2 N A 2 Four buttons are di

467 W hat w ill be output of follow ing program import java.aw t.*; import java.applet.*; import java.aw t.event.*; 2 N U 2 One Button w ill be

468 W hat w ill be output of program w hen "Ok" button is pressed? import java.applet.Applet; import java.aw 2 Y2 U 2 OK button pressed
t.Button; import java.aw t.Graphics; import java.aw t.event.ActionEvent; import java.aw
t.event.ActionListener; /* <applet code="HandleActionEventExample" w idth=200 height=200> </applet> */
public class HandleActionEventExample extends Applet implements ActionListener{ String actionMessage="";
public void init(){ Button Button1 = new Button("Ok"); Button Button2 = new Button("Cancel");
add(Button1); add(Button2); Button1.addActionListener(this); Button2.addActionListener(this); } public void
paint(Graphics g)
{ g.draw String(actionMessage,10,50); } public void actionPerformed(ActionEvent ae){ String action =
ae.getActionCommand(); if(action.equals("Ok")) actionMessage = "Ok Button Pressed"; else
if(action.equals("Cancel")) actionMessage = "Cancel Button Pressed"; repaint(); } }

469 W hat w ill be the output of follow ing code? import java.applet.*; import java.aw t.event.*; /* 2 Y2 A 2 S15004
<applet code="InnerClassDemo" w idth=200 height=100> </applet> */ public class InnerClassDemo extends
Applet { public void init() { addMouseListener(new MyMouseAdapter()); } class MyMouseAdapter extends
MouseAdapter { public void mousePressed(MouseEvent me) { show Status("Mouse Pressed"); } } }

470 W hat w ill be the output of follow ing code? import java.aw t.*; import java.aw t.event.*; import java.applet.*;2 Y2 A 2 S14802

471 W hat w ill be the output of follow ing code? import java.aw t.*; import java.applet.*; import java.aw 2 Y2 A 2 46o1
t.event.*; public class ButtonDemo1 extends Applet implements ActionListener { String msg=" "; Button
b1,b2,b3; public void init() { b1=new Button("Red"); b2=new Button("Green"); b3=new Button("Blue");
add(b1); add(b2); add(b3); b1.addActionListener(this); b2.addActionListener(this);
b3.addActionListener(this); } public void actionPerformed(ActionEvent ae) { String
str=ae.getActionCommand(); if (str.equals("Red")) {
setBackground(Color.red); } else if (str.equals("Green")) { setBackground(Color.green); } else if
(str.equals("Blue")) { setBackground(Color.blue); } repaint(); } public void paint(Graphics g) { g.draw
String(msg,0,100); } } /*<applet code="ButtonDemo1.class" w idth=200 height=400>
</applet>*/

472 W hat w ill be the output of follow ing prgram? import java.aw t.*; import java.aw t.event.*; class Sample exten2 N A 2 A frame w indow w

473 W hat w ill be the output of given code import java.aw t.*; import java.aw t.event.*; import javax.sw ing.*; 2 Y2 A 2 A and B
import java.applet.*; public class expt4 extends JApplet implements ActionListener { JComboBox cb; public
void init() { Container co=getContentPane(); co.setLayout(new Flow Layout()); JComboBoxcb=new
JComboBox(); cb.addItem("Cricket"); cb.addItem("Football"); cb.addItem("Hockey");
cb.addActionListener(this); co.add(cb); } public void actionPerformed(ActionEvent AE) {
cb=(JComboBox)AE.getSource(); if("Cricket"==cb.getSelectedItem()) {
getContentPane().setBackground(Color.RED); } if("Football"==cb.getSelectedItem()) {
getContentPane().setBackground(Color.GREEN); }
if("Hockey"==cb.getSelectedItem()) { getContentPane().setBackground(Color.BLUE); } repaint();
} } /*<APPLET CODE="expt4.class" HEIGHT=200 W IDTH=200></APPLET>*/

474 W hat w ill be the output of the above program: import java.applet.*; import java.aw t.*; import java.aw 2 N A 2 W elcome to java p
t.event.*; /* <appet code=”fontdemo” w idth=200 height=100> </applet> */ public class fontdemo extends
Applet { int next=0; Font f; String msg; public void init() { setBackground(Color.yellow );
setForeground(Color.magnenta); f=new Font(“Times New Roman”, Font.ITALIC,18); msg=”W elcome to java
Programming”; setFont(); } Public void paint(Graphics g)
{ g.draw String(msg,100,50); }
475 W hat w ill be the output of the program given below import java.aw t.*; import java.applet.*; import java.aw t2 N U 2 The output w ill dis
Programming&quot
increase by tw o po

476 W hat w ill be the output of the program? Figure:- 2 Y1 A 2 Compilation error

477 W hat w ill be the output of the program? Figure:- 2 Y1 A 2 W ill produce label

478 w hat w ill be the result of follow ing code if value of no1=no2=no3=2 and Button pressed="ok"; import java.aw2 N A 2 6

t4.setText(Integer.toString(n)); } else if(ae.getSource()==b2) { msg="Result is not correct"; }


repaint(); } public void paint(Graphics g) { g.draw String(msg, 2, 200); } }
479 W hat w ill happen w hen any item from list is selected import java.applet.Applet; import java.aw t.*; import ja 2 N A 2 Selected item w ill
480 W hat w ill happen w hen Button w ith caption "<" is clicked import java.aw t.*; import java.applet.*; import 2 N A 2 “&lt;” is pressed ite
java.aw t.event.*; /*<applet code=llist2.java w idth=300 height=300>
</applet>*/ public class llist2 extends Applet implements ActionListener { List l1,l2; TextField tdata; Button
badd1,badd2,b1,b2,b3,b4; public void init() { l1=new List(5,true); l2=new List(5,true); tdata=new
TextField(10); badd1=new Button("Add1"); badd2=new Button("Add2"); b1=new Button("<"); b2=new
Button(">"); b3=new Button("<<"); b4=new Button(">>"); add(l1); add(b1); add(b2); add(b3); add(b4);
add(badd1); add(tdata); add(badd2); add(l2); badd1.addActionListener(this); badd2.addActionListener(this);
b1.addActionListener(this); b2.addActionListener(this); b3.addActionListener(this);
b4.addActionListener(this); } public void actionPerformed(ActionEvent ae) { int n; String
s=ae.getActionCommand(); if(s=="Add1") l1.addItem(tdata.getText()); if(s=="Add2") {
l2.addItem(tdata.getText()); } if(s=="<") { n=l1.getSelectedIndex(); if(n!=-1)
l2.addItem(l1.getSelectedItem()); } if(s!=">") { n=l2.getSelectedIndex(); if(n!=-1)
l1.addItem(l2.getSelectedItem()); } if(s=="<<") { n=l1.countItems(); for(int i=0;i<n;i++) { l1.select(i);
l2.addItem(l1.getSelectedItem()); }} if(s==">>") { n=l2.countItems(); for(int i=0;i<n;i++) { l2.select(i);
l1.addItem(l2.getSelectedItem()); }}}}

481 W hat w ill happen w hen you attempt to compile and run the follow ing code? import java.aw t.*; import java.a2 N A 2 Compile time error

482 W hen a program class implements an interface, it must provide behavior for 2 N U 2 all methods defined in that interfa

483 W hen ContainerEvent is generated, follow ing action is done- 2 N U 2 Component is added or removed

484 W hen the event source generates an event the event source notifies to .............. that the event has occurred. 2 N U 2 all the listener obje

485 W hen the given output is generated ? Figure:- 2 Y1 U 2 W hen Alphabet key

486 W hen tw o or more object are added as listeners for the same events ,ehich listener is first invoked to handle t 2 N U 2 The last object that

487 W hen tw o or more objects are added as listeners for the same event, w hich listener is first invoked to handle 2 N A 2 There is no w ay to

488 W hen tw o or more objects are added as listeners for the same event, w hich listener is first invoked to handle 2 N U 2 The last object that

489 W hen tw o or more objects are added as listeners for the same events,w hich listener is first invoked to handled2 N U 2 There is no w ay to

490 W hen user change text present In text field then that event listen by 2 N U 2 TextListener

491 W hen you run the follow ing applet from a brow ser, w hat is displayed: import javax.sw ing.*; public class Tes2 N U 2 Default constructor
492 W hether the given code is correct to generate the given output import java.applet.*; import java.aw t.*; 2 Y1 A 2 No
public class MyControl5 extends Applet implements ActionListener { List l; TextField t; Button b; public void
init() { b=new Button("Add"); l=new List(); t=new TextField(); add(b); add(l); add(t);
b.addActionListener(this); } public void actionPerformed(ActionEvent ae) { l.add(t.getText()); } }
Figure:-

493 W hich of these events w ill be generated if w e close an applet's w indow ? 2 N A 2 W indow Event

494 W hich among the follow ing is true about the event? 2 N U 2 all of these

495 W hich are passive controls that do not support any interaction w ith the user? 2 N U 2 Labels

496 W hich are the methods of MouseMotionListener 2 N U 2 void mouseMoved(MouseEvent e)

497 W hich AW T control is required for geting follow ing output 2 Y1 A 2 Label
Figure:-

498 W hich class header w ould be used to create an applet that accepts a click on a button? 2 N U 2 public class MyApplet extends Japp

499 W hich class is used for this Processing Method processActionEvent( )? 2 N A 2 Button,List,MenuItem

500 W hich controls are used to get the follow ing output 2 Y1 A 2 TextField, TextArea
Figure:-

501 W hich Event is /are handdled on List Component 2 N A 2 Any of one depends on single click

502 W hich Event is generated w hen a component is added to or removed from a container 2 N U 2 ContainerEvent

503 W hich Event is generated w hen applet w indow is closed by user? 2 N U 2 W indow Event

504 W hich event is generated w hen the position of scrollbar is changed.Select the correct answ er. 2 N A 2 AdjustmentEvent

505 w hich Event is required in to minimize and close the object draw n by the follow ing code import java.aw t. *; i 2 N A 2 C. W indow listener
506 W hich import statement is used for follow ing program. /* <applet code=exp1.class w idth=200 height=200> <2 N A 2 import java.aw t.ev

507 W hich is mssing statement in the follow ing code import java.aw t.*; import java.aw t.event.*; 2 N A 2 g1.addActionListene
import javax.sw ing.*; import java.applet.*; /*<applet code="JRadio1" w idth=300 height=100>
</applet>*/ public class JRadio1 extends JApplet implements ActionListener { Container
ContentPane=getContentPane(); JTextField tf; public void init() { ContentPane.setLayout(new Flow Layout());
JRadioButton r1=new JRadioButton("Red"); r1.addActionListener(this); ContentPane.add(r1); JRadioButton
g1=new JRadioButton("Green"); ContentPane.add(g1); JRadioButton b1=new JRadioButton("Blue");
b1.addActionListener(this); ContentPane.add(b1); ButtonGroup bg=new ButtonGroup(); bg.add(r1);
bg.add(g1); bg.add(b1); tf=new JTextField(5); ContentPane.add(tf); } public void
actionPerformed(ActionEvent ae) { String s; s=ae.getActionCommand(); if(s=="Red")
ContentPane.setBackground(Color.red); else if(s=="Green") ContentPane.setBackground(Color.green); else
if(s=="Blue") ContentPane.setBackground(Color.blue); } }

508 W hich is the mehtod of keyListener Interface? 2 N U 2 All of above

509 W hich line of code is missing in follow ing code import java.aw t.*; import java.aw t.event.*; import 2 N A 2 public void keyRele
java.applet.*; /*<applet code="KeyEventDemo.class" w idth=400 height=400> </applet>*/ }
public class KeyEventDemo extends Applet implements KeyListener { String msg=""; public void init() {
addKeyListener(this); } public void keyPressed(KeyEvent e) { show Status("Key Dow n"); int
key=e.getKeyCode(); repaint(); } public void keyTyped(KeyEvent e) { msg+=e.getKeyChar(); repaint(); }
public void paint(Graphics g) { g.draw String(msg,10,20); } }

510 W hich line of code is missing in follow ing code and error statement code line import java.aw t.*; import 2 N A 2 KeyListener public
java.aw t.event.*; import java.applet.*; /*<applet code="KeyEventDemo.class" w idth=400 height=400> show Status(&quot;
</applet>*/ public class KeyEventDemo extends Applet implements
_____________ { String msg=""; public void init() { addKeyListener(this); } public void
keyPressed(KeyEvent e) { show Status("Key Dow n"); int key=e.getKeyCode(); repaint(); } public void
keyTyped(KeyEvent e) { msg+=e.getKeyChar(); repaint(); } public void paint(Graphics g) { g.draw
String(msg,10,20); } }

w hich listener is missing in follow ing code.? import java.aw t.*; import java.aw t.event.*; import

511 java.applet.*; public class TextField_Demo extends Applet implements ¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬ { Label l1,l2; 2 N A 2 ActionListener

512 W hich Listener is required here to handle current event 2 Y1 A 2 itemListener


Figure:-

513 W hich Listener is required to handle event 2 Y1 A 2 ActionListener


Figure:-
514 w hich Listeners are required for follow ing output. Figure:- 2 Y1 A 2 MouseListener, Mou

515 W hich method is missing in the code given below :import java. Aw t. *; import java.aw t.event.*; class Aevent 2 N A 2 b.addActionListener

(100,120,80,30); add ( b);add(tf); setSize(3600,300); setLayout(null); setVisible (true); } public void actionPe

516 W hich method ******** is missing in follow ing program. import java.aw t.*; import java.aw t.event.*; 2 N A 2 w indow Closing()
class FrameDemo extends Frame { FrameDemo() { addW indow Listener(new MyW indow Adapter()); } public
static void main(String args[]) { FrameDemo f=new FrameDemo(); f.setSize(100,200); f.setTitle("Frame w
indow "); f.setVisible(true); } public void paint(Graphics g)
{ g.draw String("this is a frame",100,200); } class MyW indow Adapter extends W indow Adapter {
public void ********* (W indow Event w e) { System.exit(0); } } }

517 W hich method identifies the type of an event generated. Select the one correct answ er. 2 N U 2 getID()

518 W hich method is Applcable for ItemListener interface ? 2 N R 2 itemStatechanged(ItemEvent e)

519 W hich method is missing in follow ing program. import java.aw t.*; import java.aw t.event.*; import java.apple2 N A 2 mouseMoved()

520 W hich method is missing in follow ing program. import java.aw t.*; import java.aw t.event.*; import java.apple2 N A 2 mouseReleased()

521 w hich method is required to register mouse listener to aw t components 2 N A 2 addMouseListener


522 w hich method is requried to handle the button event as show n in follow ing image ? //Experiment no.05 2 N A 2 D. public void actio
//Porgam for Handling Events import java.aw t. * ; import java.applet.*; import java.aw t. Event.*; public
class DemoEvent extends Applet implements ActionListener { TextField t1,t2,t3; Label l1,l2,l3; Button
b1,b2,b3,b4; public void init() // Applet Initilized { t1 = new TextField(5); t2
= new TextField(5); t3= new TextField(5) l1 = new Label ("First N0"); l2 = new Label ("Second No") l3 =
new Label ("Add/Sub/Div/Mul is :"); b1.addActionListener(this); b2.addActionListener(this) b3.addAction
Listener; b4.addAction Listener; GridLayout g= new GridLayout(5,2); Set Layout (g); add
(l1)add(t1);add(l2);add(t2); add (l3)add(t3);add(b1);add(b2); add(b3); add(b4); {
____________________________________________________________________//expected here { if
(e.getSourc() ==b1) int n1=Integer.parseInt(t1.getText()); int n2=Integer.parseInt(t2.getText()); int n3
=n1+n2; l3.setText("Additionis:"); t3.setText(Integer.toString(n3)); } if (e.getSourc() ==b2) int
n1=Integer.parseInt(t1.getText()); int n2=Integer.parseInt(t2.getText()); int n3 =n1-n2;
l3.setText("Subtraction is:"); t3.setText(Integer.toString(n3)); } if (e.getSourc() ==b3) int
n1=Integer.parseInt(t1.getText()); int n2=Integer.parseInt(t2.getText()); int n3 =n1*n2;
l3.setText("Multiplication is:"); t3.setText(Integer.toString(n3)); } if (e.getSourc() ==b4) int
n1=Integer.parseInt(t1.getText()); int n2=Integer.parseInt(t2.getText()); int n3 =n1/n2; l3.setText("Division
is:"); t3.setText(Integer.toString(n3)); } } } /* <Applet code ="DesmoEvent.class" height="150"
w idth ="250"> */

523 W hich method is used to display icon on a component? 2 N U 2 setIcon(ImageIcon i)

524 W hich of the follow ing are valid return types, for listener methods ? 2 N A 2 void

525 W hich of the constant(s) from follow ing constants is defined in W indow Event class? 2 N U 2 ALL ABOVE

526 W hich of the follow ing are true? 2 N U 2 A and C


527 W hich of the follow ing are true? 2 N U 2 Button object may generate an Ac

528 W hich of the follow ing code is required to display output in table format. 2 N U 2 Container c1=getContentPane(); c

529 w hich of the follow ing components generate item event 2 N A 2 Button

530 W hich of the follow ing does NOT generate GUI events? 2 N U 2 Displaying the text in a label.

531 W hich of the follow ing does not have it default Layout as BorderLayout 2 N U 2 Panel

532 W hich of the follow ing event of KeyEvent class is generated w hen a character is pressed? 2 N U 2 All of above

533 W hich of the follow ing geenerate action event? 2 N U 2 Button

534 W hich of the follow ing handles event in Event Delegation Model? 2 N U 2 Listener

535 W hich of the follow ing integer constants are defined by AdjustmentEvent class that can be used to identify adj 2 N A 2 All are defined

536 w hich of the follow ing is not type of keyEvent class 2 N U 2 KEY_DOW N

537 W hich of the follow ing is the highest class in the event delegation class hierarchy? Figure:- 2 N U 2 java.util.EventObje

538 W hich of the follow ing methods of ItemListener must be overriden in order to handle ItemEvent? 2 N U 2 public void itemStateChanged(Ite

539 W hich of the follow ing MouseMotionListener interface methods? 2 N U 2 mouseDragged(MouseEvent me),

540 W hich of the follow ing statements are true? A. All events w ill be processed in the order, the listener w ere add2 N U 2 C and D

541 W hich of the follow ing statements are true? 2 N A 2 JButton has a const

542 W hich of the follow ing statements is true about MouseMotionListener? 2 N U 2 All of the mentioned

543 W hich of the follow ing statements registers a panel object p as a listener for a button variable jbt? 2 N U 2 jbt.addActionListen
544 W hich of the follw ing component cannot be registared w ith actionPerformed() method of 2 N U 2 CheckBox
ActionListener?

545 W hich of these are constants defined in W indow Event class? 2 N U 2 All of the mentioned

546 W hich of these are integer constants defined in ActionEvent class? 2 N A 2 ALL of the mentioned

547 W hich of these are integer constants of TextEvent class? 2 N U 2 TEXT_VALUE_CHANGED

548 W hich of these are integer constants of ComponentEvent class? 2 N A 2 All of the mentioned

549 W hich of these constant value w ill change w hen the button at the end of scroll bar w as clicked to increase its2 N U 2 UNIT_INCREMENT

550 W hich of these event w ill be generated if w e close an applet w indow ? 2 N U 2 W indow Event

551 W hich of these events are notifide by List? 2 N U 2 both a and b

552 W hich of these events is generated w hen a button is pressed ? 2 N U 2 ActionEvent

553 W hich of these events is generated w hen the component is added or removed? 2 N U 2 ContainerEvent

554 w hich of these events w ill be generated if w e close an applet's w indow ? 2 N A 2 W indow Event

555 W hich of these Events w ill be notified if scroll bar is manipulated 2 N U 2 AdjustmentEvent

556 w hich of these Integer Constant Are defined in ActionEventClass 2 N A 2 all of the these

557 w hich of these interfaces define a method actionPerformed()? 2 N U 2 ActionListener

558 W hich of these interfaces handles the event w hen a component is added to a container? 2 N U 2 ContainerListener

559 W hich of these is superclass of W indow Event class? 2 N U 2 ComponentEvent

560 W hich of these methods are used to register a keyboard event listener? 2 N U 2 addKeyListener()

561 w hich of these methods are used to register a mouse motion listener? 2 N A 2 addMouseMotionListener()

562 W hich of these methods can be used to obtain the coordinates of a mouse? 2 N U 2 getPoint()

563 W hich of these methods can be used to obtain the reference to the container that generated a 2 N U 2 getContainerEvent(
ContainerEvent?

564 W hich of these methods is defined in MouseMotionAdapter class? 2 N A 2 A. mouseDragged()

565 W hich of these methods is defined in MouseMotionAdapter class? 2 N A 2 mouseMoved()

566 W hich of these methods w ill respond w hen you click any button of mouse? 2 N U 2 all of this

567 W hich package contains all classes & methods required for Event Handling in Java? 2 N U 2 java.aw t.event

568 W hich package should be added in the follow ing program to get the proper output: public class JCheckBoxDem2 N A 2 All of these

569 W hich program segment w ill generate the follow ing output. Figure:- 2 Y1 A 2 W hich program seg
javax.sw ing.*; imp
DemoFrame extend
Container c; public
570 W hich statement allow s the button named click to react to a mouse click? 2 N U 2 click.addActionListener(this)

571 W hich statement among the follow ing is not true releated to Event? 2 N U 2 A component may o

572 w hich statement is correct? 1)MouseClicked() is defined in MouseMotionListener 2 N A 2 3,4


2)MouseEntered() is defined in MouseMotionListener 3)MouseMoved() is defined in
MouseMotionListener 4)MouseReleased() is defined in MouseListener

573 W hich statement is incorrect or missing in the follow ing code import java.aw t.*; import java.aw t.event*; 2 N A 2 Both A and B
import javax.sw ing.*; public class radio extends JApplet implements
_____________ { pulic void init() { c.setLayout(new Flow Layout()); JRadioButton b1=new
JRadioButton("Red"); b1.addActionListener(this); c.add(b1); JRadioButton b2=new JRadioButton("Green");
b2.addActionListener(this); c.add(b2); JRadioButton b3=new JRadioButton("Blue");
b3.addActionListener(this); c.add(b3); ButtonGroup bg=______________; bg.add(b1); bg.add(b2);
bg.add(b3); } public voidactionPerformed(ActionEvent e){ setBackground(e.getActionCommand()); } }

574 W hich statement is missing in follow ing code : import java.aw t.*; import javax.sw ing.*; import 2 N A 2 b1.addActionListene
java.applet.*; import java.aw t.event.*; /* <applet code="Square" w idth=300 height=300>
</applet> */ public class Square extends Applet implements ActionListener { Button b1; Label l1,l2;
TextField t1,t2; public void init() { l1=new Label("Enter the number"); l2=new Label("Square of number");
t1=new TextField(); t2=new TextField(); b1=new Button("Square"); setLayout(new GridLayout(3,2));
add(l1); add(t1); add(l2); add(t2); add(b1); } public void actionPerformed(ActionEvent ae) {
if(ae.getSource()==b1) { float a=Float.parseFloat(t1.getText()); float c=a*a; t2.setText(Float.toString(c)); }
}}

575 W hich statement is true about the code fragment listed below ? class MyListener extends MouseAdapter implem2 N A 2 The code compiles
mouse listener.

576 W hich Statement w ith respect to inner class is true A)It is a w ay of logically grouping classes that are only us 2 N U 2 All A , B C are True

577 W hich statements are missing in follow ing program /*<applet code=ScrollRGB w idth=300 height=300> </ap 2 N A 2 add(blue); red.addA

578 W hich statements should w e add inorder to follow ing code to handle events for MenuItems import java.aw 2 N A 2 ActionListener, add
t.*; import java.aw t.event.*; public class MenuDemo extends Frame implements
___________________ { Label l; MenuDemo() { MenuBar mbr = new MenuBar(); setMenuBar(mbr);
Menu filemenu = new Menu("File"); mbr.add(filemenu); MenuItem new 1 = new MenuItem("New ");
filemenu.add(new 1); new 1.__________________ l=new Label(); add(l); } public static void main(String
args[]) {MenuDemo m = new MenuDemo(); m.setSize(200,200); m.setLocation(10,10); m.setVisible(true); }
public void
______________________ { l.setText("New Clicked"); } }

W hich sw ing control is used for follow ing output? Figure:-

579 2 Y1 U 2 JButton,JscrollPane
580 W hich type of the follow ing program : import java.aw t.event.ActionEvent; import java.aw t.event.ActionListen2 N U 2 Anonymous Inner c

581 W hich values are defined in InputEvent class to represent modifiers? 2 N U 2 All the above

582 W hich w ill be the correct code for the follow ing output 2 Y1 A 2 import java.aw t.*;
Figure:- class EventDemo ex
void init() { ad
mouseClicked(Mous

583 W hich w ill be the layout of the output w indow 2 Y1 A 2 GridBagLayout


Figure:-

584 W indow is type of 2 N U 2 All of this

W rite the missing statement import java.applet.Applet; import java.aw t.Checkbox; import java.aw
t.Graphics; import java.aw t.event.ItemEvent; ------------------------------------------------------
/* <applet code="HandleCheckboxEvent" w idth=200 height=200> </applet> */ public class
HandleCheckboxEvent extends Applet implements ItemListener{ Checkbox java = null;
Checkbox vb = null; Checkbox c = null; public void init(){ java = new Checkbox("Java"); vb = new

585 Checkbox("Visual Basic"); c = new Checkbox("C"); add(java); add(vb); add(c); java.addItemListener(this); 2 Y1 A 2 import java.aw t.ev
vb.addItemListener(this); c.addItemListener(this); } public void paint(Graphics g){ g.draw String("Java: " +
java.getState(),10,80); g.draw String("VB: " + vb.getState(), 10, 100); g.draw String("C: " + c.getState(),
10, 120); } public void itemStateChanged(ItemEvent ie) { repaint(); } }
Figure:-

586 You have created a simple Frame and overridden the paint method as follow s public void paint(Graphics g) { g.2 N A 2 The low er part of t
the top hidden
587 ______________is used to obtained the object that generate W indow event 2 N A 2 getW indow ()

588 _______________ method can be used to know the degree of adjustment made by user w ith 2 N U 2 getValue()
ScrollBar?

589 _______________method can be used to change location of event 2 N A 2 TranslatePoint()

590 ……………method can be used to obtain refrence to the container that generate ContainerEvent. 2 N A 2 getContainerEvent()

C opyright © 2014 - 2015. All rights reserved.

Maharashtra State Board of Technical Education

(A utonomous) (ISO 9001:2008) (ISO/IEC 27001:2005)

Welcome M3001 [117.239.186.68]


My Home Log Out

e-Exam Manage Questions for Advanced Java Programming (17625) for topic 3 Go Back to Subjects

Q No Question To pi Fig urQ Type Mar ksAnswer

1 Calling ServerSocket() constructor w ith port value 'zero' means_________________3 N U 1 use a port number that

2 TCP/IP reserves the ____________ ports for specific protocols 3 N R 1 low er 1024

3 W hich of these package contains classes and interfaces for netw orking? 3 N R 1 java.net

4 A ServerSocket can connect to ________ clients. 3 N R 1 multiple

5 A set of rules that governs data communication. 3 N R 1 protocol

6 A socket identifies __________ in netw ork. 3 N R 1 a communication end point

7 A socket is combination of 3 N R 1 Both A and B

8 A socket is __________________ of a tw o-w ay communication link betw een tw o p3 N R 1 one end-point

9 Access control does not deals w ith 3 N R 1 Authenication

10 A_______ is responsible for determining w hether code executing in the Java runtime3 N R 1 policy object

11 byte[] getData() method of DatagramPacket class returns______________________3 N R 1 Byte array of data conta

12 Class URL represents __________________________________, a pointer to a "reso3 N R 1 Uniform Resource Locato

13 Communication using TCP protocol is __________and _________ 3 N R 1 connection-oriented, concurrent

14 Connection oriented communication is possible using 3 N R 1 Socket and ServerSocke


___________________classes of Java.

15 How many bits are in a single IPv4 address? 3 N R 1 32

16 How many bytes are required to represent an IPv4 address? 3 N R 1 4

17 In InetAddress class w hich method returns the host name of the IP Address? 3 N R 1 public String getHostNam

18 In the format for defining the URL w hat is the last part? 3 N R 1 File path

19 In the URL, http://w w w .osborne.com:80/index.htm, 80 represents 3 N R 1 Port number


20 In UDP send() and receive() methods belong to w hich class? 3 N R 1 DatagramSocket
21 In w hich class the constructors are not visible 3 N R 1 Inetaddress class

22 Inet Address class encapsulates__________________ 3 N R 1 Both A and B

23 IP Stands for ________ 3 N R 1 Internet Protocol

24 Java.net package include follow ing classes. 3 N R 1 URLConnection, Socket, InetAddress

25 Name the class w hich is used to create a port w here the server w ill listen? 3 N R 1 ServerSocket

26 Permission class of java.security package is _______ class 3 N R 1 abstract

27 Permission class belongs to w hich package? 3 N R 1 java.security

28 Port Number for FTP is 3 N R 1 21

29 Port number of Email is ____________. 3 N R 1 25

30 Pretty Good Privacy (PGP) is used in security of 3 N R 1 Email

31 Reserved port no of HTTP 3 N R 1 80

32 Resolver in DNS sysytem maps 3 N R 1 Domain name to ip address

33 Select the proper constructor of ServerSocket class 3 N R 1 All of above

34 Select the proper constructor of URL class 3 N R 1 All of the above

35 TCP is W hich Type of Protocol ? 3 N R 1 Connection oriented protocol

36 TCP is _________oriented protocol 3 N R 1 stream

37 TCP Stands for ________ 3 N R 1 Transmission Control Protocol

38 TCP/IP sockets are used to impelement __________ connections. 3 N R 1 All of the above

39 The class w hich encapsulates both the numerical IP address and the domain name fo3 N R 1 InetAddress

40 The constructor w hich is used in ServerSocket may be______________. 3 N R 1 ServerSocket (int port).

41 The constructor w hich is used to create client socket is ____________. 3 N R 1 Socket(InetAddress IPAddress, int port).

42 The factory method for retrieving objects of InetAddress is 3 N R 1 All of the mentioned
___________________.

43 The factory method w hich returns an array of InetAddresses that represent all of the3 N R 1 getAllByName( )

44 The java.net.InetAddress class provides methods to get the____________________ 3 N R 1 IP of any host name

45 The method int getPort( ) of Socket class returns____________ 3 N R 1 remote port to w hich this Socket object i

46 The number 80 in follow ing URL specifies? 3 N R 1 Port number

http://w w w .rediff.com:80/index.htm/
47 The openConnection() is the method of w hich Class? 3 N R 1 URLConnection

48 The openConnection() method of URL class return 3 N R 1 URLConnection


_____________Object.

49 The return type of getHostAddress() method is_____________ 3 N R 1 string

50 The server listens for a connection request from a client using the follow ing statemen3 N R 1 Socket s = ServerSocke

51 The valid sequence for URL format is ___________________ 3 N R 1 protocol, Hostname, portnumber, filepath

52 The ____________method in the InetAddress class returns the IP 3 N R 1 getHostAddress()


address.

53 The ______________class is used to create TCP server. 3 N R 1 ServerSocket


54 To create an InputStream on a Socket s, you use __________. 3 N R 1 InputStream in = s.getInputStream();

55 To obtain an ObjectOutputStream from a socket,use__________ 3 N R 1 new ObjectOutputStream(socket.getOutp

56 To return an instance of InetAddress class you have to use 3 N R 1 Factory Methods of InetAddress class

57 To return the currently intalled policy object______________method is used. 3 N R 1 public static Policy getPo

58 UDP is not __________oriented protocol. 3 N R 1 Connection

59 UDP Packets are know n as ___________________ 3 N R 1 Datagram

60 UDP Protocol uses follow ing classes for communication 3 N R 1 DatagramPacket and DatagramSocket

61 UDP Stands for ________ 3 N R 1 User Datagram Protocol

62 URL class has several constructors; each can throw a 3 N R 1 MalformedURLException


_____________________.

63 W hat does the openConnection() method of java.net.* return? 3 N R 1 Object of URLConnection class

64 W hat does URL stands for? 3 N R 1 Uniform Resource Locator

65 W hat is return type of getAddress() method of InetAddress class? 3 N R 1 byte[]

66 W hat is Second part of URL address 3 N R 1 Hostname

67 W hat is Socket? 3 N R 1 All of these

68 W hat is the first part of URL address? 3 N R 1 Protocol

69 W hat is the optional part of URL Address 3 N R 1 Port Number

70 W hat is the return type of the method getAllByName( ) of InetAddress class? 3 N R 1 InetAddress[ ]

71 W hat w ill be displayed in the output? import java.net.*; class myAddress { public st 3 N R 1 The internet address of

this computer's address."); } } }


72 W hen a socket object is created __________ 3 N R 1 It implicitly establishes a

73 W hen a URL object is created __________ 3 N R 1 a connection is automatically established

74 W hich class defines follow ing methods. 1. int getContent Length() 2. long getDate() 3 N R 1 URLConnection

75 W hich class is used to access actual bits or content information of a 3 N R 1 URLConnection


URL?

76 W hich class is used to create client in TCP/IP? 3 N R 1 Socket

77 W hich class is used to designed to be a "listener" w hich w aits for client to connect b3 N R 1 ServerSocket

78 W hich class is used to implement datagrams w ith UDP protocol. 3 N R 1 DatagramSocket

79 W hich class of java.net package can be used to find the host name and IP address of3 N R 1 The InetAddress class

80 W hich classes are used for connection-oriented socket programming 3 N R 1 Both A and B

81 W hich constructor of DatagramSocket class is used to create a datagram socket and 3 N R 1 DatagramSocket(int por

82 W hich datagram method returns the byte array of data contained in the datagram? 3 N R 1 byte[] getData()

83 W hich exception indicate that the IP address of a host could not be determined 3 N R 1 Unknow nHostException

84 W hich is connection less protocol 3 N R 1 UDP


85 W hich is not a method of URL Connection? 3 N R 1 Date getLastModified( )

86 W hich is not valid method of URL class? 3 N R 1 getUrl()

87 W hich is the correct syntax from given? 3 N R 1 byte[] getAddress()

88 W hich is the reliable protocol of netw orking ? 3 N R 1 TCP

89 W hich method is used to know the full URL of an URL object? 3 N R 1 toExternalForm()

90 W hich method is used to retrieve the host name associated w ith URL 3 N R 1 getHost()

91 W hich method is used to return the IPAddress of local machine 3 N R 1 static InetAddress getLocalHost( )

92 W hich method of ServerSocket w ill w ait for a client to initiate communications and t3 N R 1 accept()

93 W hich method of URL class is used to create object of URLConnection? 3 N R 1 openConnection

94 W hich of the follow ing are Factory Methods of InetAddress class 3 N R 1 All the Above

95 W hich of the follow ing class defines accept() method? 3 N R 1 ServerSocket

96 W hich of the follow ing constructor of InetAddress is generally used? 3 N R 1 InetAddress class does not contain any vi

97 W hich of the follow ing is a connection oriented protocol? 3 N R 1 TCP


98 W hich of the follow ing is mediator betw een real w eb server and client application 3 N R 1 Proxy

99 W hich of the follow ing is not a constructor of DatagramSocket 3 N R 1 DatagramSocket(InetAddress address)

100 W hich of the follow ing is not a Factory method of an InetAddress 3 N R 1 Sting getHostAddress()
Class?

101 W hich of the follow ing is not true about TCP Socket? 3 N R 1 Socket is not used to cre

102 W hich of the follow ing is true about UDP? 3 N R 1 No retransmission of lost packets.

103 W hich of the follow ing is true for TCP ? 3 N R 1 TCP is realiable and connection oriented

104 W hich of the follow ing is true for UDP ? 3 N R 1 UDP is unrealiable and connection less

105 W hich of the follow ing method is used to obtain remote port to w hich 3 N R 1 getPort()
Socket object is connected.

106 W hich of the follow ing methods of InetAddress class returs the IP Address? 3 N R 1 getHostAddress()

107 W hich of the ServerSocket method listen client request for connection? 3 N R 1 accept()

108 W hich of these class is necessary to implement datagrams? 3 N R 1 Both of these

109 W hich of these class is used to create servers that listen for either local or remote cli 3 N R 1 ServerSockets

110 W hich of these class is used to encapsulate IP address and DNS? 3 N R 1 InetAddress

111 w hich of these class must be used to send a datagram packets over a connection? 3 N R 1 All of the mentioned

112 W hich of these is a bundle of information passed betw een machines? 3 N R 1 Datagram

113 W hich of these is a factory methods 3 N R 1 getLocalHost()

114 W hich of these is a not a factory method of InetAddress class? 3 N R 1 static InetAddress getAllName(String host

115 W hich of these is a protocol for breaking and sending packets to an address across a 3 N R 1 TCP/IP

116 W hich of these is a return type of getAddress method of 3 N R 1 InetAddress


DatagramPacket class?
117 W hich of these is a return type of getData() method of 3 N R 1 byte
DatagramPacket class

118 W hich of these method does not belongs to DatagramPacket class 3 N R 1 getAddress()

119 w hich of these method of DatagramPacket is used to find the length of byte Array 3 N R 1 getLength()

120 W hich of these method of DatagramPacket is used to find the port number? 3 N R 1 getPort()

121 W hich of these method of DatagramPacket is used to obtain the byte array of data co3 N R 1 getData()

122 W hich of these methods is used to know the full URL of an URL object? 3 N R 1 toExternalForm()

123 W hich of these methods is used to know the type of content used in the URL? 3 N R 1 getContentType()

124 W hich of these methods is used to know w hen w as the URL last modified? 3 N R 1 getLastModified()

125 W hich package is used for handling security related issue? 3 N R 1 java.security

126 W hich socket class can send packets unreliably? 3 N R 1 java.net.DatagramSocket()

127 W hich type of exception is throw by InetAddress class Factory methods? 3 N R 1 Unknow nHostException

128 You can invoke ______________ on a Socket object, say socket, to obtain an InetAd3 N R 1 socket.getInetAddress()

129 You can obtain the server's hostname by invoking 3 N R 1 getCodeBase().getHost(


__________________on an applet.

130 ______is netw orking protocol for hypermedia, collaborative & 3 N R 1 HTTP
distributed information system.

131 ________ is a low level routing protocol that breaks data into smaller packets. 3 N R 1 Internet protocol.

132 __________ class is used for accessing the attribute of a remote resource. 3 N R 1 URLConnection Class

133 __________ is a factory method w hich returns an array of addresses. 3 N R 1 getAllByName.

134 __________ is used to implement reliable, bidirectional, persistent point to point stre3 N R 1 TCP/IP client and server

135 __________method is used to examine the address and port information by the sock3 N R 1 getInetAddress()

136 __________method of URL class is used to obtained file path from given URL. 3 N R 1 getFile()

137 ____________ acts as a mediator betw een a client program and an external servers3 N R 1 Proxy server

138 ____________port number is reserved for Http protocol. 3 N R 1 80

139 _____________ protocol supports fast point to point datagram oriented model. 3 N R 1 UDP

140 ______________class is used to access the attributes of a remote host. 3 N R 1 URLConnection

141 ________________ is abstract class for representing access to a system resource. 3 N R 1 Permission

142 ___________________ method of DatagramSocket class is used to receive Datagram


3 N R 1 receive(DatagramPacket
143 A ___________is responsible for determining w hether code executing in the java run3 N U 2 Policy Object

144 Arrange the follow ing code segment in proper order that represent TCP server a) 3 N U 2 a,c,b
creating serverSocket object. server=new ServerSocket(4000, 2);
System.out.println("Socket open"); b) //receive inputs from client receive=new
DataInputStream(client.getInputStream()); String data=null; w hile(true) {
data=receive.readUTF(); System.out.println(data); } c)
//accept() method listens for a connection to be made to this socket and accepts it.
client=server.accept(); System.out.println("Client connected");

145 Choose the class name to be used instead of A_Class to get correct output. import ja 3 N A 2 InetAdress

146 Choose the correct output import java.net.*; class myURL2 { public static void main( 3 N A 2 a) Protocol=http Host Na
File Name=

147 Choose the correct output import java.net.*; class netw orking { public static void 3 N A 2 true
main(String args[])throw s Unknow nHostException { InetAddress obj1
=InetAddress.getByName("msbte.com");
InetAddress obj2 =InetAddress.getByName("msbte.com"); boolean x =
obj1.equals(obj2); System.out.print(x); } }

148 Consider the follow ing programe w hat w ill happen after execution. import java.net. 3 N A 2 84

149 Find Error in follow ing program. import java.aw t.*; class URLDemo { public static 3 N A 2 both a and b
void main(String args[]) throw s urlexception { URL hp = new URL("http://w w w
.Abc.com/dow nloads"); System.out.println("Protocol: " + hp.getProtocol());
System.out.println("Port: " + hp.getPort()); System.out.println("Host: "
+ hp.getHost()); } }

For the follow ing client side code of TCP implementation of sockets, w hat should be import java.io.IOExcepti
{ public static void main

150 java.net.*; public class Client { public static void main(String[] args) throw s Unknow3 N A 2 ServerSocket ss=new S

151 From given list w hich address is called as loopback address ? 3 N U 2 127.0.0.0

152 getByname() method returns 3 N U 2 host name

153 getLocalHost() method is present in w hich package 3 N U 2 java.net

154 getPort() method of socket class return 3 N A 2 Returns the port number on w hich the so
155 Give line numbers containing errors in follow ing program: import java.Net.*; 3 N A 2 Line No.: 1,7,8,10,12,14
import java.io.*; import java.util.*; public class HeaderView er {public static void
main(String args[]) {try {URL u = new URL("http://w w w
.rediffmail.com/index.html"); URLconnection uc = u.openconnection( );
System.out.println("Content-type: "
+uc.getContentType( )); System.out.println("Content-encoding: "+
uC.getContentEncoding( )); System.out.println("Date: " + new Date(uc.getDate(
))); System.out.println("Last modified: "+ new Date(uC.getLastModified( )));
System.out.println("Expiration date: "+ new Date(uc.getExpiration( )));
System.out.println("Content-length: "
+uC.getContentLength( )); } catch (MalformedURLException ex)
{System.out.println("I can't understand this URL..."); } } }

156 Given Statement may throw s w hich exception? InetAddress address 3 N U 2 Unknow nHostException
=InetAddress.getByName("w w w .xyz.com");

157 Given the follow ing lines from a Java program segment: byte[] dataOut 3 N A 2 DatagramPacket packet
= new byte [512]; String userInput = "Java Programming"; dataOut = userInput.length, InetAd
userInput.getBytes(); W hich of the follow ing lines of code could be used to create
a new UDP datagram packet to send the data that w as provided by the user to a
host identified by the InetAddress object IPAddress?

158 Http is w hich type of Protocol 3 N U 2 Stateless

159 Identify the valid method of URL class. 3 N U 2 All of the mentioned

160 Identify the valid ServerSocket constructor. 3 N U 2 public ServerSocket(int portno)

161 If port number is not specified in the URL, getPort() method returns 3 N U 2 -1
_______

162 If w e create the datagram packet w it follow ing constructor: DatagramPacket(byte d3 N U 2 size of the packet

163 If you use either Telnet or FTP, w hich is the highest layer you are using to transmit d3 N U 2 Application

164 import java.net.*; public class URLDemo{ public static void main(String args[])throw 3 N U 2 Protocal:http Port:-1 Ho
w w .javajazzup.com

hp.getFile()); System.out.println("Ext:" + hp.toExternalForm()); } } W hat w ill be th

165 import java.io.*; import java.net.*; class exp7_1{ public static void main(String 3 N A 2 -1
args[]) throw s MalformedURLException{ URL a=new URL("http://w w w
.msbte.com:/index.html"); System.out.println("port
:"+a.getPort()); } }

166 import java.io.*; import java.net.*; class Pw dClient { public static void main(String a3 N U 2 client side

167 import java.net.*; class netw orking { public static void main(String[] args) throw s M3 N U 2 http://w w w .sanfoundr
168 import java.net.*; class netw orking { public static void main(String[] args) throw s E3 N U 2 text/html

169 import java.net.*; class netw orking1 { public static void main(String[] args) throw s 3 N A 2 true

170 import java.net.*; class myAddress { public static void main (String args[]) { try { In3 N U 2 The internet address of

171 In follow ing java program fill statement show ing *****. Select any one option 3 N A 2 getByName(&quot;w w
from given options. import java.net.*; public class InetDemo { public static void
main(String[] args) { try { InetAddress ip=InetAddress.****************
System.out.println("Host Name: "+ip.getHostName()); System.out.println("IP
Address: "+ip.getHostAddress()); } catch(Exception e) { System.out.println(e); }
}}

172 In how many w ays w e can create URL A)URL url = new URL("http://hostname:80/in3 N U 2 A &amp; B both

173 In InetAddress class w hich method it returns the host name of the IP Address? 3 N U 2 public static InetAddress

174 In order to receive message from client w hich thing is missing in given server side pr3 N A 2 OutputStream class

175 In the follow ing code, w hat type of protocol is Socket object "skt" 3 N U 2 TCP
uses? import java.io.*; import java.net.*; public class NetClient { public static void
main(String args[]) throw s Exception { Socket skt = new Socket("host",88); } }

176 In the follow ing program choose the correct strings from given options to pass in 3 N A 2 All
URL constructor to get an output w ithout any exception. import java.net.*; class
URLDemo { public static void main(String args[]) throw s MalformedURLException {
URL hp = new URL("__________"); System.out.println("Protocol: " +
hp.getProtocol()); System.out.println("Port: " + hp.getPort());
System.out.println("Host: " + hp.getHost()); System.out.println("File: "
+ hp.getFile()); } } A. http://w w w .msbte.com/mainsite/index.php B. http://w w
w .msbte.com:80/mainsite/index.php C. w w w .msbte.com/ D. w w w
.msbte.com/mainsite/index.php

177 In this construtor ServerSocket(int port, int maxQueue) w hat is the default value for3 N U 2 50

178 InetAddress is used to encapsulate 3 N U 2 both a and b

179 InputStream class is used in TCP Client-server program to 3 N U 2 Send/receive message from client to serv

180 IPv6 uses ---------------------- 3 N U 2 Eight groups of four hexadecimal digits ea

181 Java.net package consist of interface_____________ 3 N U 2 All of above


182 Match the follow ing a) Datagram Socket i) UDP connection b) URL ii) provides necess3 N A 2 a-i, b-iv, c-iii, d-ii

183 Name the components of the URL in order of their appearance 3 N U 2 Protocol,Hostname,Port Number, File Nam

184 openConnection() method returns 3 N U 2 a) Returns a URLConnection object

185 Permission class is a part of w hich packets? 3 N U 2 java.security.Permission

186 port number of Telnet is________ 3 N U 2 23

187 returns the socket and establish a connection betw een server and client. 3 N U 2 public Socket accept()

188 Select correct constructors of DatagramPacket class? 3 N U 2 DatagramPacket(byte da

select correct the code for the display given output

189 Figure:- 3 Y1 A 2 import java.io.*; import


static void main(String[]
URL(&quot;http://w w w
URLConnection huc=(UR

190 Select pacakge used for handling security related issues in a program 3 N U 2 java.security

191 Select proper method used to create the instance InetAddress class. 3 N U 2 getLocalHost(),getByName(),getAllByNam

192 Select th proper interface of java.net package 3 N U 2 ContentHandlerFactory

193 Select the appropriate method for retrieving address of remote machine 3 N U 2 public Address getRemo

194 Select the fullform of DNS 3 N U 2 Domain Name System

195 Select the method of DatagramPacket used to find the port number 3 N U 2 getPort()

196 Select the method used to create a URL Connection 3 N U 2 openConnection

197 Select the method w hich throw s UnKnow nHostException 3 N U 2 All of the above

198 select the proper class for creating servers that listen for either local or remote client 3 N U 2 ServerSockets

199 Select the proper constructor of ServerSocket 3 N U 2 ServerSocket(int port, int maxQueue)

200 Select the proper constructor of the Socket class 3 N U 2 Socket(String hostName, int port)

201 Select the proper constructor of URL class 3 N U 2 All of above

202 Select the proper InetAddress factory method. 3 N U 2 static InetAddress getLocalHost()

203 Select the proper method of URL class to create the object of 3 N U 2 openConnection()
URLConnection.

204 Select the proper method to know the type of content used in the URL. 3 N U 2 getContentType()

205 Select the proper method to retrieve the host name & IP address of remote machine 3 N U 2 static InetAddress getBy
Unknow nHostException

206 Select the proper method to retrieve the host name and IP Address of local machine 3 N U 2 static InetAddress getLo
Unknow nHostException
207 Select the proper method to retrieve the host name of local machine 3 N U 2 static InetAddress.getLo
Unknow nHostException

208 select the proper method to retrive the data from DatagramPacket 3 N U 2 getData()

Select the proper output for follow ing code import java.net.*; class

209 DemoURL { public static void main(String args[])throw s MalformedURLException { U3 N A 2 Port: -1 File: /dow nload

210 ServerSocket has a method called __________, w hich is a blocking call that w ill w a3 N U 2 accept()

211 Socket connection = server.accept( ); In the above statement, server is an object 3 N U 2 ServerSocket, IOExcept
of ___________class and accept() method throw s
________exception.

212 TCP and UDPs 3 N A 2 protocol

213 TCP does not supports Multicasting and Broadcasting because: 3 N U 2 It is connection oriented protocol.

214 The URL connection classes are good enough for simple programs that w ant to conne3 N U 2 HTTP

215 The -------------- method in the InetAddress class returns the IP 3 N U 2 getHostAddress()
address.

216 The client request a connection to a server using the follow ing statement. 3 N A 2 Socket s=new Socket(S

217 The connection establishment in TCP is called 3 N U 2 three- w ay handshaking

218 The Constructor of URL can throw s an Exception called 3 N U 2 MalFormedURLException

219 The follow ing code can be used to produce a permisson to read the file named "abc "3 N U 2 perm=new java.io.FilePe

220 The follow ing program is w ritten for ____________________ import java.net.*; im 3 N A 2 TCPIP server

221 The follow ing program w ill display _____________________ import java.net.*; pub3 N A 2 All IP addresses of w w w

222 The follow ing Server program _____________________ import java.net.*; import j 3 N A 2 w aits for client request
message to all clients
223 The purpose of URL is 3 N U 2 a and b

224 The server listens for a connection request from a client using the follow ing statemen3 N U 2 Socket s = serverSocket

225 The Socket class has how many constructors that a client uses to connect to a server 3 N A 2 2

226 The User Datagram Protocol (UDP) is 3 N U 2 All of them

227 The ____________________models an IP address,w hich can be used to find the ho 3 N U 2 InetAddress class

228 The _____________________________ w hich contains a set of pre- w ritten netw o3 N U 2 java.net package

229 This program is w ritten for ___________ side import java.net.*; import java.io.*; pu3 N U 2 client

230 To Get All addresses by name of a URL - "w w w .google.com" follow ing command is 3 N U 2 InetAddress[] addresses

231 To access the URLConnection Class object w hich of the transfer protocol is used? 3 N U 2 http

232 To connect to a serevr running on the same machine w ith client, w hich of the follow 3 N U 2 All of the above

233 To create Socket "S" by IP address "127.0.0.1" and port number 3 N U 2 A


"12345" Identify the command A) Socket s = new Socket("127.0.0.1",
12345); B) ServerSocket s = new Socket("127.0.0.1", 12345); C) Socket s = new
Socket("localhost", 12345);

234 To create a server socket on the specified port w ith a maximum queue length of max3 N U 2 b and c

235 to create an InputStream on a socket s, you use ________ 3 N U 2 InputStream in = s.getInputStream();


236 to get the follow ing output select the proper code Protocol: http Port: 3 N A 2 import java.net.*; class
-1 Host: w w w .msbte.com File: /dow nloads

237 To return the currently installed policy object ____________ method is used. 3 N U 2 public static Policy getPo

238 URL Connection is class used for_____________________. 3 N U 2 Accessing the attributes of a remote resou

239 URL string encompasses four parts in sequence 3 N U 2 1. Netw ork Protocol 2.H

240 URLConnection object is retrived using follow ing method? 3 N U 2 openConnection()


241 W hat correction should be done in the program to get correct output? import 3 N A 2 Use of created object no
java.net.*; import java.io.*; public class URLTest { public static void main(String
args[]) throw s MalformedURLException { URL url = new URL("http://w w w
.msbte.com/dow nload"); System.out.println("Protocol:"+ url1.getProtocol());
System.out.println("Port:"+ url1.getPort()); System.out.println("Host:"+
url1.getHost()); System.out.println("File:"+ url1.getFile()); } }

242 W hat correction should be done in the program to get correct output? import 3 N A 2 Use of created object no
java.net.*; import java.io.*; public class URLTest { public static void main(String
args[]) throw s MalformedURLException { URL url = new URL("http://w w w
.msbte.com/dow nload"); System.out.println("Protocol:"+ url1.getProtocol());
System.out.println("Port:"+ url1.getPort()); System.out.println("Host:"+
url1.getHost()); System.out.println("File:"+ url1.getFile()); } }

243 W hat correction should be done in the program to get corrected output import 3 N A 2 Missing package stateme
java.net.*; import java.io.*; class UrlDemo1 { public static void main(String a[])
throw s Exception { URL ur= new URL("http://w w w .msbte.com/mainsite/");
URLConnection con=ur.openConnection(); System.out.println("Date : "+new
Date(con.getDate())); System.out.println("Content type :
"+con.getContentType()); System.out.println("Expires : "
+con.getExpiration()); System.out.println("Last Modified : "+new
Date(con.getLastModified())); int len=con.getContentLength();
System.out.println("content length : "+len); } }

244 W hat correction should be done in the program to get the correct output import java3 N A 2 }

245 W hat is the proper constructor of serversocket 3 N U 2 All The Above


246 w hat is use of this method? public ServerSocket(int port) throw s 3 N U 2 Attempts to create a ser
IOException

247 W hat is 1432 in follow ing program. import java.net.*; import java.io.*; public class 3 N A 2 port number

248 W hat is correct code for the given problem statement: Develop a program to send a 3 N A 2 both a&amp; b

249 W hat is correct code to get ip address of host machine ? 3 N A 2 import java.net.*; class

250 W hat is missing in the follow ing program code? import java.io.*; class Sender { pub3 N U 2 All of the mentioned
251 W hat is out put of follow ing Program import java.net.*; class netw orking { public st3 N U 2 text/html

252 W hat is output of follow ing program import java.net.*; public class InetAddressExam3 N A 2 Gives default IP address

253 What is proper method to retrieve the host name of local machine 3 N U 2 static InetAddressgetLocalHost( )throw s
254 W hat is the default length of the queue in follow ing constructor of 3 N U 2 50
Serversocket? ServerSocket(int portno)

255 W hat is the error in given code? import java.net.*; public class Hostname{ public 3 N A 2 System.out.println (&qu
static void main(String args[]){ try{ InetAddress local= local.getLocalHostName(
InetAddress.getLocalHost(); System.out.println ("Local hostname is: " +
local.getLocalHostName()); } catch
(Unknow nHostException e){ System.err.println ("Can't detect localhost
: " + e); } } }

256 w hat is the function of method int getPort()? 3 N U 2 Both a &amp; b


257 W hat is the meaning of follow ing code segment? BufferedReader inFromServer = ne3 N A 2 new inFromServer objec
of clientSocket

258 W hat is the missing statement in the output of the follow ing code: 3 N A 2 Content-Type: text/htm
import java.net.*; import java.io.*; import java.util.Date; class UCDemo
{ public static void main(String args[]) throw s Exception { int c; URL hp
= new URL("http://w w w .internic.net"); URLConnection hpCon =
hp.openConnection(); long d = hpCon.getDate(); if(d==0) System.out.println("No
date information."); else System.out.println("Date: " + new Date(d));
System.out.println("Content-Type: " + hpCon.getContentType()); d =
hpCon.getExpiration(); if(d==0) System.out.println("No expiration information.");
else System.out.println("Expires: " + new Date(d)); d = hpCon.getLastModified();
if(d==0) System.out.println("No last-modified information."); else
System.out.println("Last-Modified: " + new Date(d)); int len =
hpCon.getContentLength(); if(len == -1) System.out.println("Content length
unavailable."); else
System.out.println("Content-Length: " + len); }} Output: Date: Sat Apr
27 12:17:32 CDT 2002 No expiration information. Last-Modified: Tue
Mar 19 17:52:42 CST 2002 Content-Length: 5299

259 W hat is the ouput of follow ing code? import java.net.InetAddress; import java.net.U3 N A 2 local m/c Address

260 w hat is the out of follow ing code if Host URL w as last modified on july 3 N A 2 Tue Jun 18 2013
18 tuesday 2013 . mport java.net.*; class netw orking { public static void
main(String[] args) throw s Exception { URL obj = new URL("http://w w w
.sanfoundry.com/javamcq"); URLConnection obj1 = obj.openConnection();
System.out.print(obj1.getLastModified); } }
261 W hat is the output of this program? Figure:- 3 Y1 A 2 cisco.com

262 W hat is the output of this program? import java.net.*; class netw orking { public sta3 N A 2 msbte.com

InetAddress.getByName("msbte.com"); System.out.print(obj1.getHostName()); } }

263 W hat is the output of this program? import java. Net.*; class netw orking { public st 3 N A 2 http

264 W hat is the purpose of InetAddress class? 3 N U 2 To retrieve IP address of the specified hos

265 W hat is the return type of getAddress() method of DatagramPacket class? 3 N U 2 InetAddress

266 W hat is the use of bind() method 3 N U 2 bind a socket to a local IP address and po

267 W hat is the use of w riteUTF( ) method? 3 N U 2 This method w rites a string into underlyin

268 W hat method is used to establish a port w here a server w aits for requests? 3 N U 2 ServerSocket()
269 W hat statement is needed to get the output as show n in fig. in bellow program 3 Y1 A 2 c=new urlconn(); in mai
import java.net.*; import java.io.*; import java.aw t.event.*; import javax.sw
ing.*; import java.aw t.*; class urlconn extends JFrame implements ActionListener
{JTextField f=new JTextField(); JTextArea a=new JTextArea(); String s=""; public
urlconn() { getContentPane().add(f,BorderLayout.NORTH);
getContentPane().add(a,BorderLayout.CENTER); f.addActionListener(this);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(400,400);
} public void actionPerformed(ActionEvent e) { if(e.getSource()==f) { try { URL
u=new URL(f.getText()); URLConnection con=u.openConnection(); BufferedReader
br=new BufferedReader(new InputStreamReader(con.getInputStream())); int
len=con.getContentLength(); if(len!=0) { w hile((s=br.readLine())!=null)
a.append("\n"+s); br.close(); } else a.append("\n"+"content unavailable");
}catch(Exception ae){} } } public static void main(String ar[])throw s Exception {
urlconn c; c.setVisible(true); } }
Figure:-

270 W hat the method getDate() of URLConnection class returns? 3 N U 2 returns time and date of response in term

W hat the index.html specifies in follow ing URL?


271 Http://w w w /rediff.com:80/index.html 3 N U 2 File name

272 W hat type of exception might be throw n by Socket class. 3 N U 2 Unknow nHostException

273 W hat w ill be displayed in the output import java.net.*; class InetAddressTest { publ3 N U 2 The array of internet ad

274 W hat w ill be displayed in the output? import java.net.*; classmyAddress { public sta3 N U 2 The internet address of

275 W hen client and server is communicating using TCP protocol then communication is _3 N U 2 connection-oriented, con

276 w hen creating a client on a server port that is alerady in use 3 N U 2 client can connect to the
________________

277 W hen Unknow nHostException is throw n, that indicates 3 N U 2 The IP address of a host could not be dete

278 W hich datagram method returns the byte array of data contained in the datagram? 3 N U 2 byte[] getData ()
279 W hich is correct client code for follow ing server code? import java.net.*; import java3 N A 2 import java.net.*; impo
void main(String args[])
BufferedReader b=null;
Socket(InetAddress.getL
BufferedReader(new Inp
catch(Unknow nHostExc
know host&quot;); Syst
hile((inp=b.readLine())!
b.close(); s.close(); } }

280 W hich Statement is missing in follow ing code import java.net.*; public class InetAdd3 N A 2 InetAddress ad=InetAdd

281 W hich class can be used to create a server socket. This object is used to establish co3 N U 2 Both A &amp; B

282 W hich code segment listens for a socket connection? 3 N U 2 Socket socket = HttpURLConnection.open

283 W hich constructor is used to create ServerSocket connected to port no 3 N U 2 ServerSocket(1254)

1254 and maxq length as 50.


284 W hich constructors of DatagramPacket class are used for receiving purpose? 3 N U 2 All

285 W hich Exception is throw n by DatagramSocket class constructor 3 N U 2 SocketException

286 W hich five parameters uniquely identify a Connection ? 3 N U 2 Local IP, Remote IP, Loc

287 W hich ip address is multicast ip address 3 N U 2 235.55.45.2

288 W hich is correct sequence of steps for establishing TCP Connection betw een client a 3 N U 2 a,c,b,d

289 W hich is Factoty method? 3 N U 2 All of above

290 w hich is not the constructor of URL? 1) public URL()throw s MalformedURLException 3 N U 2 1

291 w hich is not the method of security class? 1) SocketPermission() 2) FilePermission() 3 N U 2 3

292 W hich is reserved port of HTTP & FTP 3 N U 2 80 &amp; 21

293 W hich is responsible for determining w hether code executing in Java runtime enviro 3 N U 2 security class

294 W hich is the class present in java.net package used to create packet from byte array3 N U 2 DatagramPacket

295 W hich method is used to obtain the Portno of client in Client Program 3 N U 2 getLocalPort()

296 W hich method Returns the output stream of the URL connection ? 3 N U 2 getOutputStream()
297 W hich methods are commonly used in ServerScocket class ? 3 N U 2 public Socket accept()

298 W hich minimum package statements are missing? class InetDemo { public static 3 N U 2 import java.net.*; impo
void main(String args[]) { try { Socket s=new Socket("127.0.0.1",1234);
InputStream ip=s.getInputStream(); OutputStream op=s.getOutputStream();
Date d=new Date(); String datemsg=String.valueOf(d); op.w
rite(datemsg.getBytes()); op.close();
} catch(Exception e) { System.out.println(e); } } }

299 W hich of the follow ing is not a factory method of InetAddress class 3 N U 2 static InetAddress getAl
Unknow nHostException

W hich of the follow ing statement is missing in follow ing code: import java.io.*; imp

300 ServerSocket(8); DataInputStream in = new DataInputStream(so.getInputStream())3 N U 2 Socket so = ss.accept();

301 W hich of these are correct constructor/s of URL class? 3 N U 2 All of above

302 W hich of these class is used to encapsulate IP address and DNS? 3 N U 2 InetAddress

303 W hich of these methods is used to know host of an URL? 3 N U 2 getHost()

304 w hich of this class is not related to input and output stream in terms of functioning? 3 N A 2 Reader

305 W hich protocol w ill be used/printed in the follow ing example import java.net.*; 3 N A 2 HTTP
public class URLDemo { public static void main(String args[]) throw s
MalformedURLException { URL hp = new URL("http://w w w .msbte.com/dow
nloads"); System.out.println("Protocol: " + hp.getProtocol());
System.out.println("Port: " + hp.getPort()); System.out.println("Host: "
+ hp.getHost()); System.out.println("File: " + hp.getFile());
System.out.println("Ext:" + hp.toExternalForm()); } }

306 W hich Statement gives an error import java.net.*; import java.io.*; public class URL3 N A 2 C.Both A and B

307 W hich statement is missing from the code import java.net.*; import java. io.*; class 3 N A 2 getProtocol()

308 W rite a syntax to prepare DatagramPacket Object as sendPacket by using other para3 N A 2 DatagramPacket sendPa
sendData.length, IPAddr

309 You can invoke ______________ on a Socket object, say socket, to obtain an InetAd3 N A 2 socket.getInetAddress()

310 You can obtain the server's hostname by invoking _________ on an applet. 3 N U 2 getCodeBase().getHost(

311 _______ method is used to examine the address and port information by the socket. 3 N U 2 getInetAddress().
312 _________ is a protocol for breaking and sending packets to an address across a net 3 N U 2 TCP/IP

313 __________are used to implement reliable, bidirectional, persistent point to point str 3 N U 2 TCP/IP

314 ___________ is a bundle of information passed betw een machines. 3 N U 2 Datagram

315 ___________ is a general-purpose class for accessing the attributes of a remote 3 N U 2 URLConnection

316 ___________ server can process multiple request at a time 3 N U 2 a concurrent

317 ___________is a factory method of InetAddress class w hich returns an array of Inet3 N U 2 getAllByName()

318 _____________ class is necessory to implements Datagram 3 N U 2 both a and b

319 ________________ is a mediator used in betw een W eb Server and 3 N U 2 Proxy


Client

320 ________________________ are the instance methods of 3 N U 2 All


InetAddress class.

321 …………….. method is used for testing w hether the specified element is a file or not. 3 N A 2 isFile()

322 …………….method is used to find thehost URL? 3 N U 2 getHost()

323 …………………throw n to indiacate that IP address of Host could not be 3 N U 2 UNknw onHostExecption
Determined

324 ……………………….method of datagram packet is used to find the port number. 3 N U 2 getPort()

325 A technique that creates a subletting effect; one server answ ers ARP 3 N U 2 Proxy Server
requests for multiple hosts?

326 W hich client accesses the W eb server by using a GET MESSAGE? 3 N U 2 HTTP

327 W hich of these is a protocol for breaking and sending packets to an address across a 3 N U 2 TCIP/IP

C opyright © 2014 - 2015. All rights reserved.

Maharashtra State Board of Technical Education


(A utonomous) (ISO 9001:2008) (ISO/IEC 27001:2005)

Welcome M4001 [117.239.186.68]

My Home Log Out

e-Exam Manage Questions for Advanced Java Programming (17625) for topic 4 Go Back to Subjects

Q No Question To pi Fig urQ Type Mar ks

1 A Java program cannot directly communicate w ith an ODBC driver because 4 N R 1 ODBC w ritten in C language

2 A JDBC technology -based driver ("JDBC driver") makes it possible to do ? 4 N R 1 All mentioned above

3 Abbreviate the term DSN 4 N R 1 Data Source Name

4 An API can be created for 4 N R 1 All of these

5 API stands for 4 N R 1 application program interface

6 API w hich controls access to the row result of a given Statement and holds data retrieved from a database af4 N R 1 java.sql.ResultSet

7 Application Server used in ____________________ 4 N R 1 Three-Tier Mode

8 Backbone of JDBC Architecture is ________________ 4 N R 1 Driver Manager

9 boolean isLast() method defines _______ 4 N R 1 Determines w hether the ResultSet c


10 Callable Staement used to -------- 4 N R 1 calling procedure

11 Callable statement object in JDBC is used to execute a call to 4 N R 1 stored procedure

12 CallableStatement is used to execute_________________ 4 N R 1 Stored Procedures

13 Choose the correct syntax for getConnection() method 4 N R 1 public static Connecti
SQLException

14 Class.forName("_________________________") 4 N R 1 sun.jdbc.odbc.JdbcOdbcDriver

15 class.forName() method throw s 4 N R 1 ClassNotFoundException

16 Connection object can be initialized using the _______ method of the DriverManager Class. 4 N R 1 getConnection()
17 createStatement() method w ithout any parameter is used to create a statement w ith 4 N R 1 a forw ard only and re
__________

18 Database meta data are retrieved through ________. 4 N R 1 a PreparedStatement object

19 DELETE statement of an SQL is executed by ______________. 4 N R 1 executeUpdate()

20 DriverManager.getConnection(_______ , ______ , ______) W hat are the tw o parameters that are included ?4 N R 1 URL or machine name

21 DSN stands for 4 N R 1 Data Source Name

22 Every driver must provide a class that should implement the __________________ 4 N R 1 Driver interface

23 execution of delete SQL query in JDBC, ............. method must be used. 4 N R 1 executeUpdate()

24 Follow ing is return type of executeUpdate( ): 4 N R 1 int

25 For execution of INSERT SQL query in JDBC, ............. method must be used. 4 N R 1 executeUpdate()

26 For execution of SELECT SQL query in JDBC, ___________________ method must be used. 4 N R 1 executeQuery()

27 forName is a_______________________type method 4 N R 1 static


28 getConnection() method of w hich class 4 N R 1 DriverManager

29 getUserName() method is used to_______ 4 N R 1 retrieve name of user

30 How can you execute DML statements (i.e. insert, delete, update) in the database? 4 N R 1 By invoking the executeUpdate(...) m

31 How can you retrieve information from a ResultSet? 4 N R 1 By invoking the speci

32 How many JDBC driver types are available by sun Microsystem? 4 N R 1 Four

33 How many steps are used to connect any java application w ith the database using JDBC? 4 N R 1 5

34 How many transaction isolation levels are defined in java.sql.Connection interface 4 N R 1 5

35 If a PreparedStatement is a SQL SELECT statement, you execute the statement using 4 N R 1 PreparedStatement.ex
________.

36 If you need to use a stored procedure w ith output parameters, w hich of the follow ing statement type should4 N R 1 CallableStatement

37 In 2-tier architecture , the first tier is generally_________________________ 4 N R 1 GUI

38 In JDBC _________imports all java classes concerned w ith database connectivity. 4 N R 1 java.sql.*

39 In the follow ing JDBC drivers w hich is know n as partly java driver? 4 N R 1 Native-API driver

40 In the three tier model the middle tier of the services acts as a mediator betw een 4 N R 1 Java application and d
________________________ and _________________.

41 In w hich model java application or applet supports for database access? 4 N R 1 both a and b

42 In w hich type of driver must Odbc drivers be loaded on client machine? 4 N R 1 Type 1

43 Invoking Class.forName() method may throw ___________. 4 N R 1 ClassNotFoundException

44 JDBC is a --------------------- interface, w hich means that it is used to invoke SQL commands directly. 4 N R 1 low level

45 JDBC Stands for 4 N R 1 Java Datbase Connectivity

46 JDBC stands for: 4 N R 1 Java Database Connectivity

47 JDBC-ODBC bridge product provide _________ access via ____________. 4 N R 1 JDBC driver, ODBC drivers

48 Methods of ResultSet() throw s ____________ 4 N R 1 SQLException

49 Microsoft access stores data in a _______________file format 4 N R 1 .MDB

50 Name the type number belongs to JDBC ODBC Bridge driver? 4 N R 1 Type 1
51 Native API converts __________________into the _______________________ used by 4 N R 1 JDBC API, Native API
DBMS.

52 Native – protocol pure Java converts ……….. in to the ………… used by DBMSs directly. 4 N R 1 JDBC calls, netw ork protocol

53 ODBC Drivers are platform _______________ 4 N R 1 Dependent

54 ODBC is not appropriate for direct use from java because it uses a .............. 4 N R 1 C interface

55 ODBC minimum SQL grammar contains 4 N R 1 INSERT, UPDATE ,DELETE ONLY

56 ODBC requires configuring _______ w hich represents the target database. 4 N R 1 Data Source Name

57 ODBC stands for 4 N R 1 open database connectivity

58 Prepared statement object in JDBC is used to execute______________Queries 4 N R 1 parameterized

59 PreparedStatements are used for calling_____________ 4 N R 1 precompile Statement


60 prepareStatement method is from w hich class 4 N R 1 Connection Class

61 return type of execute() method is 4 N R 1 boolean

62 SQL stands for ________ . 4 N R 1 Structured Query Language

63 Statement is__________. 4 N R 1 interface

64 The JDBC –ODBC Bridge is________ 4 N R 1 Multitreaded

65 The -----------------method executes a simple query and returns a single Result Set object 4 N R 1 executeQuery()

66 The .................. object provides you w ith methods to access data from the table. 4 N R 1 ResultSet

67 The ...................... method sets the query parameters of the PreparedStatement Object. 4 N R 1 setString()

68 The ........................ object allow s you to execute parameterized queries. 4 N R 1 PreparedStatement

69 The ......................... method executes an SQL statement that may return multiple results. 4 N R 1 execute()

70 The ............................. package contains classes that help in connecting to a database, sending SQL statem4 N R 1 java.sql

71 The command to remove all the row s from a table 'CUSTOMER' is: 4 N R 1 DELETE FROM CUSTOMER

72 The correct string for loading Jdbc-Odbc bridge driver using Class.forName() method is: 4 N R 1 sun.jdbc.odbc.JdbcOdbcDriver

73 The First task in JDBC is _________________ . 4 N R 1 register a driver

74 The interface used to execute SQL stored procedures 4 N R 1 CallableStatement

75 The JDBC API is an application interface of java for connection java as 4 N R 1 Middle

76 The JDBC API is application interface connecting java as ____ 4 N R 1 Front End

77 The parameters of the PreparedStatement object are ...................... w hen the user clicks on the Query butto4 N R 1 initialized

78 The PreparedStatement__________symbol is placeholder that is replaced by the input parameter at seen tim4 N R 1 ?

79 The ResultSet __________________provides methods for retrieving and manipulating the results of executed4 N R 1 interface

80 The Type 3 architecture is _______________________ 4 N R 1 JDBC-Net pure Java

81 The valid constant to represent ResultSet type is ___________________ 4 N R 1 All of the mentioned

82 The _____ object provides you w ith methods to access data from the table. 4 N R 1 ResultSet

83 The _____ package contains classes that help in connecting to a database, sending SQL 4 N R 1 java.sql.*
statements to the database and processing the query results.

84 The ___________ interface Provides various methods for getting information about Database. 4 N R 1 DatabaseMetaData

85 The ______________driver resolves JDBC call and makes equivalent ODBC Call 4 N R 1 JDBC-ODBC bridge

86 The_____________________ is the language for interacting w ith Database. 4 N R 1 Structured Query Language(SQL)

87 To execute SQL query w hich method is used. 4 N R 1 All of these

88 To retrieve a Connection object,…………………. Method is used. 4 N R 1 getConnection( )

89 Type 1 driver is also know n as 4 N R 1 JDBC-ODBC Bridge Driver

90 Type 3 driver is also know n as_________________ 4 N R 1 JDBC-net Pure Java

91 Type II JDBC driver is also know n as __________________ 4 N R 1 Native API partly Java driver
92 Type IV JDBC driver is also know n as __________________ 4 N R 1 Native Protocol Pure-Java Driver
93 Type4 driver is also know n as: 4 N R 1 100% Pure Java

94 W hat is JDBC 4 N R 1 Java API w ith databases

95 W hat maintains a cursor pointing to a particular row of data initially, cursor points to before the first row ? 4 N R 1 ResultSet interface

96 W here the object of ResultSet maintains a cursor? 4 N R 1 First Row

97 W hich among the below is not an interface of java.sql Package 4 N R 1 ResultSetStatement

98 W hich are the JDBC components? 4 N R 1 All of the above

99 W hich class is used to connect java application to JDBC driver 4 N R 1 DriverManager

100 W hich class/ interface is used for an SQL statement that is executed frequently? 4 N R 1 PreparedStatement

101 W hich driver provides JDBC API access via one or more ODBC drivers 4 N R 1 JDBC-ODBC bridge driver

102 W hich driver is called as a thin driver in JDBC? 4 N R 1 Type-4 Driver

103 W hich driver is efficient and alw ays preferable for using JDBC applications? 4 N R 1 Type-4

104 W hich driver is needed to connect to Microsoft database? 4 N R 1 JDBC-ODBC Bridge Driver

105 W hich driver type use middlew are server(Application Server)? 4 N R 1 Type 3

106 w hich from the below use "middle-tier" 4 N R 1 All of above

107 W hich interface is important from java.sql package in JDBC? 4 N R 1 Connection

108 W hich Interface is used to execute dynamic SQL statements? 4 N R 1 PreparedStatement

109 W hich interface provides methods to execute queries w ith the database? 4 N R 1 Statement interface

110 W hich is default ResultSet type 4 N R 1 TYPE_FORW ARD_ONLY

111 W hich is not a type of JDBC driver 4 N R 1 JDBC-Native pure java

112 W hich is the correct syntax of next( ) method of ResultSet? 4 N R 1 boolean next( )

113 W hich JDBC driver Type (s) can be used in either applet or servelt code? 4 N R 1 Both Type 3 and Type 4

114 W hich JDBC driver Type(s) can you use in a three-tier architecture and if the W eb server and the DBMS are 4 N R 1 Both Type 3 and 4

115 W hich JDBC driver Types are used for over communications netw orks? 4 N R 1 Both Type 3 and Type 4

116 W hich kind of driver convert JDBC calls into calls on the client API for Oracle, Sybase, Informix, IBM DB@ , o4 N R 1 Native-API partly-Java

117 W hich method is used to obtain count of total row s of ResultSet 4 N R 1 getRow

118 W hich method is used to perform DML statements in JDBC? 4 N R 1 executeUpdate()

119 W hich method is used to send CREATE TABLE queries to database using JDBC? 4 N R 1 executeUpdate()

120 W hich method must be used to execute INSERT, UPDATE, or DELETE statement . 4 N R 1 executeUpdate()

121 W hich method of class is used to register & dynamically load the driver class? 4 N R 1 forName()

122 W hich of the follow ing describes the correct sequence of the steps involved in making a connection w ith a d4 N R 1 1,3,4,2

123 w hich of the follow ing function is used to find the column count of the particular ResultSet ? 4 N R 1 getColumnCount()

124 W hich of the follow ing invokes functions in sql ? 4 N R 1 Callable statements

125 W hich of the follow ing is interfaces? 4 N R 1 Statement


126 W hich of the follow ing is not valid method of DriverManager class? 4 N R 1 createStatement()

127 W hich of the follow ing is the correct order of keyw ords for SQL SELECT statements? 4 N R 1 SELECT, FROM, W HERE

128 W hich of the follow ing is used for sending SQL statements? 4 N R 1 Statement

129 W hich of the follow ing method is method is used to load and register driver ? 4 N R 1 Class.forName(&quot;sun.jdbc.odbc.

130 W hich of the follow ing methods are needed for loading a database driver in JDBC? 4 N R 1 Both A and B

131 W hich of the follow ing model is java applet or application directly communicates w ith data source? 4 N R 1 Tw o tier

132 W hich of the follow ing model is know n as client/server configuration. 4 N R 1 Tw o-tier

133 W hich of the follow ing package contains all JDBC API’s those are required to make connection w ith databas 4 N R 1 java.sql.*
134 W hich of the follow ing statement is a prepared statements ? 4 N R 1 Insert into department values(?,?,?)

135 W hich of the follow ing statements loads the JDBC-ODBC driver? 4 N R 1 Class.forName(&quot;sun.jdbc.odbc.

136 W hich of the follow ing translates the socket information in call format required by the DBMS. 4 N R 1 Middlew are Application Server

137 W hich of the follw ing statement is false as far as different type of statements is concern in 4 N R 1 Interim statement
JDBC?

138 W hich of these API represents that softw are programs can follow to communicate w ith each other? 4 N R 1 Both A &amp; B

139 W hich one of the follow ing w ill not get the data from the first column of ResultSet rs, returned from executi4 N R 1 rs.getString(0)

140 W hich package is necessary to import all java classes concerned w ith database connectivity? 4 N R 1 java.sql.*

141 W hich package need to be imported for establishing connection w ith database 4 N R 1 java.sql

142 W hich statement is static and synchronized in JDBC. 4 N R 1 getConnection()

143 W hich statements about JDBC are true? 4 N R 1 Both II and III

144 W hich type of driver provides JDBC access one or more ODBC drivers? 4 N R 1 Type 1 driver

145 W hich type of driver converts JDBC calls into the netw ork protocol used by the database management syste 4 N R 1 Type 4 Driver

146 W hich type of driver is unqiue in JDBC? 4 N R 1 JDBC-Native API

147 W hich w as first most w idely used programming interface for accessing relational databases on almost all pl 4 N R 1 ODBC API

148 W hy do w e need the JDBC API? 4 N R 1 All of the above

149 You can add a row using SQL in a database w ith w hich of the follow ing? 4 N R 1 INSERT

150 _______ calls get converted into native C or C++ API calls. 4 N R 1 JDBC Native API

151 ________ is an interface by w hich application programs can access and process SQL 4 N R 1 ODBC
databases in a DBMS-independent manner.

152 __________ Interface is important from java.sql package in JDBC 4 N R 1 Connection

153 __________ interface is used to know the capabilities or information about a database 4 N R 1 Database Metadata
Management system DBMS w ith JDBC Driver.

154 __________ method of Connection interface is used to create statement 4 N R 1 createStatement()

155 __________ method of DriverManager class is used to create connection w ith database. 4 N R 1 getConnection()

156 ___________ interface allow s storing results of query? 4 N R 1 ResultSet


157 ________________ is a table of data w hich represents a data from database 4 N R 1 ResultSet

158 ___________________ interface represents the comprehensive information about the database package. 4 N R 1 DatabaseMetaData

159 W hat is data in follow ing program: import java.sql.*; public class Selectdbase { public static void main(Strin4 N A 2 data source name

160 '?' symbol is used for ________ 4 N U 2 parameter in prepared statement

161 .Find out error from follow ing code. import java.sql.*; public class Updatedbase { public static void 4 N A 2 ; missing
main(String args[]) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection
con=DriverManager.getConnection("jdbc:odbc:data2"); Statement st=con.createStatement(); resultSet
rs=st.executeQuery("select * from college"); w hile(rs.next()) { System.out.println("id:"+rs.getInt("id"))
System.out.println("name1:"+rs.getString("name1"));
} con.close(); } catch(SQLException e) {} catch(Exception e) { } }}

162 1. Choose the correct option to establish a connection to database named student and display its contents. 4 N A 2 import java.sql.*; cla
try{ Class.forName(&
con=DriverManager.g
&quot;jdbc:oracle:thi
Statement stmt=con.
from student&quot;);
&quot;+rs.getString(2
System.out.println(e)

163 A benefit of the three-tier architecture is w hich of the follow ing? 4 N U 2 New modules can be built to support
164 afterLast() method returns……………………. 4 N U 2 Moves cursor to the end of resultset

165 All raw data types including binary documents or images should be read and uploaded to the database as an a4 N U 2 byte

166 Analyse the follow ing code and fill the appropriate statement in the blanks import java.sql.*; class DB { publ4 N A 2 executeQuery()

167 Analyse the follow ing code and find errors. import java.sql.*; class DisplayRecord { public static void main(S4 N A 2 Error is in query exec

168 Analyse the follow ing code and find out errors import java.sql.*; class Record { public static void main(String4 N A 2 Error is in statement

169 Analyse the follow ing code and find out missing statement. import java.sql.*; class Record { public static voi4 N A 2 Missing driver registra

ResultSet rs=stmt.executeQuery("select * from emp w here id=101"); System.out.println("EmpName\tDesign

170 Analyze the follow ing code: ResultSet resultSet = statement.executeQuery ("select firstName, mi, lastName 4 N U 2 The program w ill hav

171 Analyze the follow ing code: ResultSet resultSet = statement.executeQuery ("select firstName, mi, lastName 4 N A 2 II, III

172 API is w hich of the follow ing 4 N U 2 Middlew are that provide access to d

173 Are Resultsets Updateable? 4 N A 2 yes,but if the resultse

174 boolean execute() method returns 4 N U 2 Multiple results

175 By using w hich interface one can store images in the database in java ? 4 N U 2 PreparedStatement interface

176 Choose missing statements in follow ing code from given options. import java.sql.*; class DBTest { public sta4 N A 2 } missing

177 Choose missing statements in follow ing code from given options. Import java.sql.*; Class conn 4 N A 2 Class.forName(“sun.jd
{ Public static void main(String args[]) { try { System.out.println(“Drivers are properly loaded”); String
url=”jdbc:odbc:abc”; Connection con=DriveManager.getConnection(url); System.out.println(“Connection
Established”); con.close(); } catch(SQLExcption e) { System.out.println(“SQL Error has occurred ”);
catch(Exception e) { System.out.println(“Error! Connection not established”); } } }

178 Choose missing statements in follow ing code from given options. import java.sql.*; class DemoFetch { public4 N A 2 stmt.executeQuery(qr
179 Choose missing statements in follow ing code from given options. import java.sql.*; class DemoFetch1 { 4 N A 2 pstmt.executeQuery(q
public static void main(String args[]) { Connection con; PreparedStatement pstmt; ResultSet rs; String
qry,url; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); url="Jdbc:Odbc:studdsn";
con=DriverManager.getConnection(url,"",""); qry="select * from stud"; pstmt=con.prepareStatement(qry);
rs=___________________; System.out.println("Roll No\tName\tPercentage"); w hile(rs.next()) { int
rno=rs.getInt("roll"); String nm=rs.getString("sname"); double per=rs.getDouble("per");
System.out.println(rno+"\t"+nm+"\t"+per); } con.close(); }catch(Exception e)
{System.out.println(e.toString());} } }

180 Choose missing statements in follow ing code from given options. import java.sql.*; import java.io.*; class D 4 N A 2 &quot;insert into stud

}catch(Exception e){} } }
181 Choose the correct alternative to update employee table 4 N A 2 PreparedStatement ps
W HERE id = ? &quot;
… } finally { pstmt. C

182 Choose the correct output for the given code: import java.sql.*; class Mydatabase1 { public static void main( 4 Y2 A 2 S1Q54O1

183 Choose the correct syntax of creating query to read records w ith salary > 10000 4 N A 2 select * from employee w here salary

184 class Ddemo1 { public static void main(String args[]) throw s Exception { 4 N A 2 Missing package state
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection
c=DriverManager.getConnection("jdbc:odbc:ODSN"," "," "); Statement s=c.createStatement(); ResultSet
rs=s.executeQuery("select *from StudTable"); System .out.println("Name" + " \t " + "Roll_No" + " \t " +
"Avg"); w hile(rs.next()) 26 { System.out.println(rs.getString(1)+" \t "+rs.getInt(2)+" \t
\t"+rs.getDouble(3)); } s.close(); c.close(); } class Ddemo1 { public static void main(String args[]) throw
s Exception { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection
c=DriverManager.getConnection("jdbc:odbc:ODSN"," "," "); Statement s=c.createStatement(); ResultSet
rs=s.executeQuery("select *from StudTable"); System
.out.println("Name" + " \t " + "Roll_No" + " \t " + "Avg"); w hile(rs.next()) {
System.out.println(rs.getString(1)+" \t "+rs.getInt(2)+" \t \t"+rs.getDouble(3)); } s.close(); c.close(); }

185 Connection con = DriverManager.getConnection ("jdbc:odbc:w ombat", "login", "passw ord"); Statement stmt4 N A 2 Retrieval of the fields

186 Connection con=DriverManager.getConnection(url); this command w ill create the follow ing 4 N A 2 new con object of connection class in

187 Connection object can be initialized using the ............................ method of the Driver Manager class. 4 N R 2 getConnection()

188 Consider follow ing code and state missing code ? import java.sql.*; class exp2 { public static void main(Strin4 N A 2 sun.jdbc.odbc.JdbcOd

189 Consider follow ing code and state w hich statement is missing in follow ing code ? import java.sql.*; class 4 N A 2 Statement s=c.create
JDBCDEMO { { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection
c=DriverManager.getConnection("jdbc:odbc:ODSN"," "," "); ResultSet rs=s.executeQuery("select *from
StudTable"); System .out.println("Name" + " \t " + "Roll_No"
+ " \t " + "Avg"); w hile(rs.next()) { System.out.println(rs.getString(1)+" \t "+rs.getInt(2)+" \t
\t"+rs.getDouble(3)); } s.close(); c.close(); } }
190 Consider Follow ing Code. Select the statement that should be added to the program to get correct output. im4 N A 2 Connection conn=Driv

System.out.println("Record Deleted"); stmt.close(); conn.close(); br.close(); }


catch(ClassNotFoundException ce){} catch(SQLException se){} catch(IOException ie){} } }
191 consider follow ing code. w hat is an ouput of given code? import java.sql.*; class Rsmd{ public static void 4 N A 2 Total columns: 2 Colu
main(String args[]){ try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = INTEGER
DriverManager.getConnection("jdbc:odbc:mydsn"); PreparedStatement ps=con.prepareStatement("select *
from employee"); ResultSet rs=ps.executeQuery(); ResultSetMetaData rsmd=rs.getMetaData();
System.out.println("Total columns: "+rsmd.getColumnCount()); System.out.println("Column Name of 1st
column: "+rsmd.getColumnName(1)); System.out.println("Column Type Name of 1st column:
"+rsmd.getColumnTypeName(1)); con.close(); }catch(Exception e){ System.out.println(e);} }
}

192 Consider follow ing program w hat should be the correction done in the program to get correct output? Class d4 N A 2 Both B and C option

193 Consider follow ing program.W hat should be the output. import java.sql.*; public class Select_Demo { public4 N A 2 Output display numbe

194 Consider given database and Select correct output for follow ing code: import java.sql.*; class StudentData 4 Y1 U 2 Students having mark
{ public static void main(String args[]) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection
con
=DriverManager.getConnection("jdbc:odbc:stud"); PreparedStatement ps
=con.prepareStatement("select * from Student w here Marks > ?"); ps.setInt(1,70); //set question marks
place holder ResultSet rs = ps.executeQuery(); //execute System.out.println("Students having marks > 70
are:"); w hile(rs.next()) System.out.println(rs.getString(2)); con.close(); }catch(Exception e){ } } }
Figure:-

195 Consider the follow ing code. Fill the proper method in the blank space . import java.sql.*; import java.io.*; p4 N A 2 executeUpdate()

catch(SQLException se){} catch(IOException ie){} } }


196 Consider the follow ing code, Find the missing statement to get correct output. public class DeleteRecords { p4 N A 2 All the above
197 Consider the follow ing code, W hat should be the correction done in the program to get correct output. impor4 N A 2 Missing }

198 Consider the follow ing code. PreparedStatement stmt=con.prepareStatement("select * from emp"); 4 N A 2 retrieve the record
ResultSet rs=stmt.executeQuery(); w hile(rs.next()){ System.out.println(rs.getInt(1)+" "+rs.getString(2));
} This is an example of prepared statement interface that w ill
_______________?

199 Consider the follow ing code.find error statement to execute the code import java.sql.*; public class 4 N A 2 Both option i and ii
JDBCExample { static final String JDBC_DRIVER = "com.mysql.jdbc.Driver" static final String DB_URL =
"jdbc:mysql://localhost/STUDENTS"; static final String USER = "username"; static final String PASS =
"passw ord"; public static void main(String[] args) { Connection conn
= null; try{ Class.forName("com.mysql.jdbc.Driver"); System.out.println("Connecting to a selected
database..."); conn = DriverManager.getConnection(DB_URL, USER, PASS); System.out.println("Connected
database successfully..."); }catch(SQLException se) { se.printStackTrace(); } catch(Exception e) {
e.printStackTrace(); } finally{ try{ if(conn!=null) conn.close(); }catch(SQLException se){
se.printStackTrace(); } } System.out.println("Goodbye!"); }

200 Consider the follow ing code.find missing statement in code so that get desired output import java.sql.*; 4 N A 2 String s= (&quot;jdbc
public class mytabledelete { public static void main(String[] args) throw s Exception
{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection(s);
System.out.println("Connection Established"); PreparedStatement studste = con.prepareStatement("delete
from student w here rno=3"); studste.executeUpdate(); Statement s1 = con.createStatement(); String
studqry = "select * from student"; ResultSet Rset = s1.executeQuery(studqry); w hile (Rset.next()) { int
studid = Rset.getInt("rno"); String studname = Rset.getString("name"); System.out.println(studid + " "
+ studname); } } }

201 Consider the follow ing code.W hat should be the correction done in the code to get correct output? import jav4 N A 2 Both option i and ii

202 Consider the follow ing code.W hat w ill be student table data after executing this code as table w as 4 N A 2 only one record in tab
empty. import java.sql.*; public class mytableins { public static void main(String[] args) throw s Exception
{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String s = ("jdbc:odbc:mystudtable"); Connection
con=DriverManager.getConnection(s); System.out.println("Connection Established"); PreparedStatement
studste = con.prepareStatement("insert into student values(2,'Rani')"); studste .executeUpdate();
Statement s1 = con.createStatement(); ResultSet Rset = s1.executeQuery( "select * from student");
System.out.println("Roll No ....Name"); w hile (Rset.next()) { int studid = Rset.getInt("rno"); String
studname = Rset.getString("name"); System.out.println(studid + " "
+studname); } } }

Consider the follow ing code.W hich statement need to update student table data by this code?

203 import java.sql.*; public class mytableupdate { public static void main(String[] args) throw s Exception { Cla 4 N A 2 studste.executeUpdat

204 Consider the follow ing database: ID name Salary 1 ramesh 1200 2 ganesh 1111 6 sanjay 4 N A 2 Driver Loaded Connec
9500 W hat w ill be the correct output for follow ing code: import java.sql.*; class SelectDemo { public name : ganesh Salary
static void main(String a[]) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Driver Loaded"); String url="jdbc:odbc:mydsn"; Connection
con=DriverManager.getConnection(url); System.out.println(" Connection to DataBase created"); Statement
stmt=con.createStatement(); String query="select * from emp"; ResultSet rs=stmt.executeQuery(query);
w hile(rs.next()) { System.out.println(" ID : "+ rs.getInt(1)); System.out.println(" name : "+
rs.getString(2)); System.out.println(" Salary : "+ rs.getInt(3)); System.out.println(); } }
catch(ClassNotFoundException e) { e.printStackTrace();
} catch(SQLException e) { e.printStackTrace(); } } }
205 Consider the follow ing program Select the statement that should be added to the program to get correct 4 N A 2 st.executeQuery()
output. import java.sql.*; public class JdbcOdbc { public static void main(String args[]) { try { Connection
con; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con =
DriverManager.getConnection("jdbc:odbc:datastud"); try { System.out.println("Getting All
Row s from a table!"); Statement st = con.createStatement(); ResultSet res =----------------------
-----("SELECT * FROM college"); System.out.println("student_code: " + "\t" + "student_name: "); w hile
(res.next()) { int i = res.getInt("stud_code"); String s = res.getString("stud_name"); System.out.println(i
+ "\t\t" + s); } con.close(); } catch (SQLException s) { System.out.println("SQL code does not execute.");
} } catch (Exception e) { System.out.println("Error:connection not created"); } } }

206 Consider the follow ing program Select the statement that should be added to the program to get correct 4 N A 2 Use satement Class.fo
output. import java.sql.*; public class db15 { public static void main(String args[])throw s Exception {
Connection c
=DriverManager.getConnection("jdbc:odbc:MyDSN","",""); PreparedStatement s=c.prepareStatement(
"update db3 set Name=? w here Roll_no=?"); Statement s=c.createStatement( ); s.setString(1,args[0]);
s.setString(2,args[1]); s.setString(3,args[2]); s.executeUpdate(); ResultSet rs=s.executeQuery("select*
from db3"); System.out.println("Name"+"\t"+"Roll no"+"\t"+"Avg"); w hile(rs.next()) {
System.out.println(rs.getString(1)+"\t"+rs.getInt(2)+"\t"+rs.getDouble(3)); } s.close(); c.close(); } }

207 Consider the follow ing program Select the statement that should be added to the program to get correct outp4 N A 2 ps1.executeUpdate();

208 Consider the follow ing program Select the statement that should be added to the program to get correct outp4 N A 2 PreparedStatement st
&quot;);

Consider the follow ing program W hat correction should be done in the program to get correct output? import

209 { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = 4 N A 2 Missing }


DriverManager.getConnection("jdbc:odbc:oraodbc","scott","tiger"); Statement stmt =
con.createStatement(); stmt.executeUpdate("create table customers(CUST_NUM int, COMPANYchar(20),
CUST_REP int, CREDIT_LIMIT number(7,2))"); stmt.close(); con.close(); System.out.println("Table
Successfully created"); } catch(Exception e) { e.printStackTrace(); }
}

210 Consider the follow ing program W hat w ill be displayed in the output? import java.sql.*; class ConnectionTe 4 N A 2 Driver loaded Connec

211 Consider the follow ing program W hat w ill be the output of follow ing Code? import java.sql.*; public class 4 N A 2 Empty Table
db15 { public static void main(String args[])throw s Exception {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection c
=DriverManager.getConnection("jdbc:odbc:DSN2","",""); Statement s=c.createStatement( ); int
n=s.executeUpdtae("delete from db3"); ResultSet rs=s.executeQuery("select* from db3");
System.out.println("Name"+"\t"+"Roll no"+"\t"+"Avg"); w hile(rs.next()) {
System.out.println(rs.getString(1)+"\t"+rs.getInt(2)+"\t"+rs.getDouble(3)); } s.close(); c.close(); } }

212 Consider the follow ing program W hich package should be added to the program to get corret code?. public 4 N A 2 java.sql.*
class db15 { public static void main(String args[])throw s Exception {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection c
=DriverManager.getConnection("jdbc:odbc:Mybm","",""); PreparedStatement s=c.prepareStatement(
"update db3 set Name=? w here Roll_no=?"); Statement s=c.createStatement( ); ResultSet
rs=s.executeQuery("select* from db3"); System.out.println("Name"+"\t"+"Roll no"+"\t"+"Avg"); w
hile(rs.next()) { System.out.println(rs.getString(1)+"\t"+rs.getInt(2)+"\t"+rs.getDouble(3)); } s.close();
c.close(); } }
213 Consider the follow ing program ,w hat should be the correction done in the program to get the correct output4 N A 2 missing }

214 Consider the follow ing program . Select the statement that should be added to the program to get correct 4 N A 2 All the above
output. import java.sql.*; class PreparedInsert { public static void main(String a[])
{ Try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection
con=DriverManager.getConnection("jdbc:odbc:javadb"); System.out.println(" Connection to DataBase
created"); String a1 = "Insert into employee(id,name,salary) values(?,?,?)"; PreparedStatement ps =
con.prepareStatement(a1); ps.execute(a1); System.out.println("Record Inserted"); String querySel =
"Select * from employee"; ResultSet rs = ps.executeQuery(querySel); System.out.println("After
Insertion"); w hile(rs.next()) { System.out.println(" ID : "+ rs.getInt(1)); System.out.println(" Name : "+
rs.getString(2)); System.out.println(" Salary : "+ rs.getInt(3)); System.out.println(); } con.close(); }
catch(SQLException e) { System.out.println(“SQL Error”); } catch(Exception e) {
System.out.println(“Error”); } } }

215 Consider the follow ing program and identify the missing statement. import java.sql.*; class ps_isert { public 4 N A 2 missing catch block

String str="Insert into if6g values(?,?)"; PreparedStatement ps=con.prepareStatement(str); ps.setInt(1,r1); p

216 Consider the follow ing program and identify the missing statement. class Type4_simple { public static void 4 N A 2 Missing semicolon &a
main(String[] args) {try { Class.forName("oracle.jdbc.driver.OracleDriver"); String
url="jdbc:oracle:thin:@pearl:1521:oracle10g"; Connection conn =
DriverManager.getConnection(url,"java","java"); System.out.println("successfully connected");
} catch(Exception e){e.printStackTrace()} } }

217 Consider the follow ing program and identify the missing statement. public class SimpleDemo { public 4 N A 2 All of the above
static void main(String[] args) { Connection con=null; Statement stmt=null; ResultSet rs=null; try {
String jdbcurl="jdbc:mysql://localhost:3306/test"; con=DriverManager.getConnection(jdbcurl, "root",
"root"); System.out.println("Connection established"); stmt=con.createStatement();
rs=stmt.executeQuery("select * from emp"); System.out.println("Empid \t Emap name \t City \t Salary");
w hile(rs.next()) { System.out.print(rs.getInt(1)+"\t"); System.out.print(rs.getString(2)+"\t");
System.out.print(rs.getString(3)+"\t"); System.out.print(rs.getFloat(4)); System.out.println(); }
} catch(ClassNotFoundException e) { e.printStackTrace();} catch(SQLException e)
{e.printStackTrace()} finally {try { rs.close(); stmt.close(); con.close(); } catch(Exception e){}
}} }

218 Consider the follow ing program W hat should be the correction done in the program to get the correct output4 N U 2 missing semicolon

219 Consider the follow ing program, it has 10 Records in the Table. W hat w ill be the output of follow ing 4 N A 2 Ramesh name w ill be
Code? import java.sql.*; public class db15 { public static void main(String args[])throw s Exception {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection c
=DriverManager.getConnection("jdbc:odbc:DSN2","",""); Statement s=c.createStatement( ); int
n=s.executeUpdate("update table set name='Ramesh'"); ResultSet rs=s.executeQuery("select* from db3");
System.out.println("Name"+"\t"+"Roll no"+"\t"+"Avg"); w hile(rs.next()) {
System.out.println(rs.getString(1)+"\t"+rs.getInt(2)+"\t"+rs.getDouble(3)); } s.close(); c.close(); } }
220 Consider the follow ing program,Select the statement that should be added to the program to get correct 4 N A 2 use ? in PreparedStat
output. import java.sql.*; public class db15 { public static void main(String args[])throw s Exception {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection c
=DriverManager.getConnection("jdbc:odbc:MyDSN","",""); PreparedStatement s=c.prepareStatement(
"update db3 set Name=# w here Roll_no=#"); Statement s=c.createStatement( ); s.setString(1,args[0]);
s.setString(2,args[1]); s.setString(3,args[2]); s.executeUpdate(); ResultSet rs=s.executeQuery("select*
from db3"); System.out.println("Name"+"\t"+"Roll no"+"\t"+"Avg"); w hile(rs.next()) {
System.out.println(rs.getString(1)+"\t"+rs.getInt(2)+"\t"+rs.getDouble(3)); } s.close(); c.close(); } }

221 Consider the follow ing program,Select the statement that should be added to the program to get correct 4 N A 2 Connection con =s.cre
output. import java.sql.*; public class db15 { public static void main(String args[])throw s Exception {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection c
=DriverManager.getConnection("jdbc:odbc:MyDSN","",""); PreparedStatement s=c.prepareStatement(
"update db3 set Name=? w here Roll_no=?"); Connection con
=s.createStatement(); s.setString(1,args[0]); s.setString(2,args[1]); s.setString(3,args[2]); ResultSet
rs=s.executeQuery("select* from db3"); System.out.println("Name"+"\t"+"Roll no"+"\t"+"Avg"); w
hile(rs.next()) {

System.out.println(rs.getString(1)+"\t"+rs.getInt(2)+"\t"+rs.getDouble(3)); } s.close();
c.close(); } }
222 Consider the follow ing program,Select the statement that should be added to the program to get correct 4 N A 2 s.executeUpdate()
output. import java.sql.*; public class db15 { public static void main(String args[])throw s Exception {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection c
=DriverManager.getConnection("jdbc:odbc:MyDSN","",""); PreparedStatement s=c.prepareStatement(
"update db3 set Name=? w here Roll_no=?"); Statement s=c.createStatement( ); s.setString(1,args[0]);
s.setString(2,args[1]); s.setString(3,args[2]); ResultSet rs=s.executeQuery("select* from db3");
System.out.println("Name"+"\t"+"Roll no"+"\t"+"Avg"); w hile(rs.next()) {
System.out.println(rs.getString(1)+"\t"+rs.getInt(2)+"\t"+rs.getDouble(3)); } s.close(); c.close(); } }

223 Consider the follow ing program. Select the statement that should be added to the program to get correct out4 N A 2 Statement st=conn.cr

224 Consider the follow ing program. W hat should be added in the program to get correct output? import java.sql4 N A 2 ResultSet rs=s.execut

225 Consider the follow ing program. W hat should be the ******* value in the program to get correct output? 4 N A 2 setString,setInt
public class MyPreparedStatement { public static void main(String a[]){ Connection con = null;
PreparedStatement prSt = null; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection
con=DriverManager.getConnection("jdbc:odbc:MyDSN"); String query = "insert into emp(name,salary)
values(?,?)"; prSt = con.prepareStatement(query); prSt.******(1, "John"); prSt.*****(2, 10000); int
count = prSt.executeUpdate(); } catch (ClassNotFoundException e)
{ e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } finally{ try{ if(prSt !=
null) prSt.close(); if(con != null) con.close(); } catch(Exception ex){} } } }

226 Consider the follow ing program. W hat should be the correction done in the program to get correct output? cl4 N A 2 Missing package

227 Consider the follow ing program. W hat should be the correction done in the program to get correct output? im4 N A 2 Missing }
228 Consider the follow ing program. W hat should be the correction done in the program to get correct output? im4 N A 2 PreparedStatement ps
values(?,?)&quot;); p

i=ps.executeUpdate(); if(i==1) System.out.println("row inserted"); else


System.out.println("operation failed"); ps.close(); con.close(); } catch(Exception e) {} } }
229 Consider the follow ing program. W hat should be the correction done in the program to get correct output? cl4 N A 2 import java.sql.*;

230 Consider the follow ing program. W hat should be the correction done in the program to get correct output? cl4 N A 2 Missing Package state

231 Consider the follow ing program. W hat should be the correction done in the program to get correct output? im4 N A 2 Missing semicolon

232 Consider the follow ing program. W hat should be the correction done in the program to get correct output? im4 N A 2 s.executeUpdate(s1)

233 Consider the follow ing program. W hat should be the correction done in the program to get correct output? im4 N A 2 mssing try and catch

234 Consider the follow ing program. W hat should be the correction done in the program to get correct output? im4 N A 2 Missing semicolon

235 Consider the follow ing program. W hat should be the correction done in the program to get correct output? im4 N A 2 Missing }

Consider the follow ing program. W hat should be the correction done in the program to get correct output?
import java.sql.*; public class JdbcTest { public static void main(String a[]){ try
{ Class.forName("Sun.jdbc.odbc.JdbcOdbcDriver"); Connection con =

236 DriverManager.getConnection("jdbc:odbc:xyz"); Statement stmt = con.getStatement(); 4 N A 2 Error in creation of Statement object


stmt.executeUpdate(“delete from student”); con.close(); } catch (ClassNotFoundException e)
{ System.out.println(e); } catch (SQLException e) { System.out.println(e); } } }
237 Consider the follow ing program. W hat should be the correction done in the program to get correct output? 4 N A 2 con.createStatement(
import java.sql.*; public class JdbcTest { public static void main(String a[]){ try
{ Class.forName("Sun.jdbc.odbc.JdbcOdbcDriver"); Connection con =
DriverManager.getConnection("jdbc:odbc:xyz"); stmt.executeUpdate(“Update Employee set Basic=
Basic+(Basic*0.10)”); ResultSet rs=stmt.executeQuery(“Select * from Employee”); w hile(rs.next()) {
System.out.println(rs.getInt(1)+” “+rs.getString(2)+” “+rs.getString(3)+” “+rs.getString(4)+”
“+rs.getFloat(5)); } con.close(); stmt.close(); } catch (ClassNotFoundException e) { System.out.println(e);
} catch (SQLException e) { System.out.println(e); } } }

238 Consider the follow ing program. W hat should be the correction done in the program to get correct output? im4 N A 2 replace executeUpdat

239 Consider the follow ing program. W hat should be the correction done in the program to get correct output? im4 N A 2 Missing }

240 Consider the follow ing program. W hat should be the correction done in the program to get correct output? im4 N A 2 add try and catch bloc

241 Consider the follow ing program. W hat should be the correction done in the program to get correct output? 4 N A 2 W rite executeQuery
import java.sql.*; class Ddemo1 { public static void main(String args[]) throw s Exception {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection
c=DriverManager.getConnection("jdbc:odbc:ODSN"," "," "); Statement s=c.createStatement(); ResultSet
rs=s.("select *from StudTable"); System .out.println("Name" + " \t " + "Roll_No" + "
\t " + "Avg"); w hile(rs.next()) { System.out.println(rs.getString(1)+" \t "+rs.getInt(2)+" \t
\t"+rs.getDouble(3)); } s.close(); c.close(); } }

242 Consider the follow ing program. W hat should be the correction done in the program to get correct output? im4 N A 2 Error in main()

243 Consider the follow ing program. W hat should be the correction done in the program to get correct output? im4 N A 2 Missing }

"+rs.getInt(2)+" \t \t"+rs.getDouble(3)); s.close(); c.close(); } }


244 Consider the follow ing program. W hat should be the correction done in the program to get correct output? 4 N A 2 DriverManager.getCon
import java.sql.*; class Ddemo1 { public static void main(String args[]) throw s Exception {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection c=DriverManager.getConnection(); Statement
s=c.createStatement(); ResultSet rs=s.executeQuery("select *from StudTable"); System
.out.println("Name" + " \t " + "Roll_No"
+ " \t " + "Avg"); w hile(rs.next()) { System.out.println(rs.getString(1)+" \t "+rs.getInt(2)+" \t
\t"+rs.getDouble(3)); } s.close(); c.close(); } }

245 Consider the follow ing program. W hat should be the correction done in the program to get correct output? 4 N A 2 SQL Error has Occure
import java.sql.*; class Ddemo1 { public static void main(String args[]) throw s Exception {try{
Class.forName("sun.jdbc.odbc.JdbcodbcDriver");System .out.println("Driver Loaded Succsessfuly");}
catch(SQLException) { System .out.println("SQL Error has Occured");
}}}
246 Consider the follow ing program. W hat should be the correction done in the program to get correct output? im4 N A 2 Missing try and catch

247 Consider the follow ing program. W hat should be the correction done in the program to get correct output? im4 N A 2 Missing main()

248 4
Consider the follow ing program. W hat should be the correction done in the program to get correct output? Im N A 2 Connection con=Drive

249 Consider the follow ing program. W hat should be the correction done in the program to get correct output? 4 N A 2 Missing } and Incomp
import java.sql.*; class Testdemo { public static void main(String srgs[]) { try {
Class.forname("sun.jdbc.odbc.JdbcOdbcDriver"); System.out.println("Driver loaded"); String
url="jdbc:odbc:info"; Connection con=DriverManager.getConnection(str); System.out.println("connection to
database created"); Statement smt=con.createStatement(); System.out.println("Statement object
created"); String sql="Select Name,Age from Amol"; ResultSet result=smt._______________________
String text=""; w hile(result.next()) { text
+result.getString(1)+""+results.getInt(2)+'\n'; } System.out.println(text); } catch(sQLException e) {
System.out.pritln("SQL error"); } catch(Exceptionn e) { System.out.println("error"); }

250 Consider the follow ing program. W hat should be the correction done in the program to get correct output? 4 N A 2 Missing close stateme
import java.sql.*; import java.io.*; class Deleterecord { public static void main(String[] args) { ResultSet
rs; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con =
DriverManager.getConnection("jdbc:odbc:oraodbc","scott","tiger"); Statement stmt =
con.createStatement(); stmt.executeUpdate("delete from CUSTOMERS w here CUST_NUM = 101"); rs =
stmt.executeQuery("select * from customers"); System.out.println("CUST_NUM" + "\tCOMPANY" +
"\t\tCUST_REP" + "\tCREDIT_LIMIT"); w hile(rs.next()) { int no=rs.getInt(1); String
company=rs.getString(2); int rep=rs.getInt(3); double credit=rs.getDouble(4); System.out.println( no +
"\t\t"+company + "\t" + rep + "\t\t" + credit); } stmt.close(); System.out.println("Record Successfully
deleted"); }catch(Exception e)
{ e.printStackTrace(); } } }

Consider the follow ing program. W hat should be the correction done in the program to get correct output? im

251 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc:odbc:4 N A 2 Missing main()

252 Consider the follow ing program. W hat should be the correction done in the program to get correct output? im4 N A 2 Missing connection
253 Consider the follow ing program. W hat should be the correction done in the program to get correct output? 4 N A 2 All the Above
import java.sql.*; class StudentData { public static void main(String args[]) { {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver") Connection con =
DriverManager.getConnection("jdbc:odbc:stud"); Statement st = con.createStatement(); ResultSet rs =
st.executeQuery("select * from Student"); System.out.println("The Database
is:-"); System.out.println("Roll\tName\t\tMarks Pass Birth-Date");
System.out.println("====================================="); w hile(rs.next()) int roll
= rs.getInt(1); String name = rs.getString(2); int marks = rs.getInt("Marks"); boolean pass
= rs.getBoolean(4); Date d = rs.getDate(5); System.out.printf("%-5d",roll); System.out.printf("%-
10s",name); System.out.printf("%-6d",marks); if(pass) System.out.printf("Yes "); else
System.out.printf("No ");
System.out.printf("%-15s\n",d.toString()); con.close(); } (Exception e){ } } }

254 Consider the follow ing program. W hat should be the correction done in the program to get correct output? cl4 N A 2 missing package state

255 Consider the follow ing program. W hat should be the correction done in the program to get correct output? im4 N A 2 missing c.close();

Consider the follow ing program. W hat should be the correction done in the program to get correct output? i

256 System.out.println("Connection error"); } try { String str="jdbc.odbc:dsn1"; con=DriverManager(str,"",""); S 4 N A 2 all of the above

257 Consider the follow ing program. W hat should be the correction done in the program to get correct output? 4 N A 2 error in createStatem
import java.sql.*; class login1 { public static void main(String args[]) { try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn=
DriverManager.getConnection("jdbc:odbc:mcm"); Statement stmt = conn.createStatement() ResultSet rs=
stmt.executeQuery("select passw ord from login w here login='"+args[0]+"'"); if(rs.next()) {
if(args[1].equals(rs.getString(1))) System.out.println("Login succesfully"); else System.out.println("W rong
Passw ord"); } else System.out.println("Login Name Not Found"); rs.close(); stmt.close(); conn.close(); }
catch(ClassNotFoundException ce)
{System.out.println("1");} catch(SQLException se){} } }

258 Consider the follow ing program. W hat should be the correction done in the program to get correct output? 4 N A 2 missing database nam
import java.sql.*; import java.io.*; public class InsertRecord2 { public static void main(String args[]) { try
{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection
conn=DriverManager.getConnection("jdbc:odbc:"); Statement stmt=conn.createStatement();
BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.println("\nEnter
userid:"); String uid=br.readLine(); System.out.println("\nEnter passw ord:"); String ps=br.readLine();
stmt.executeUpdate("insert into login values(' "+uid+"
',' "+ps+" ')"); System.out.println("Record Inserted.........."); stmt.close(); conn.close(); br.close(); }
catch(ClassNotFoundException ce){} catch(SQLException se){} catch(IOException ie){} } }
259 Consider the follow ing program. W hat should be the correction done in the program to get correct output? 4 N A 2 Error in main()
import java.sql.*; class StudentData { public static void main(String args[]) ; { try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con =
DriverManager.getConnection("jdbc:odbc:stud"); Statement st = con.createStatement(); ResultSet rs =
st.executeQuery("select * from Student"); System.out.println("The Database
is:-"); System.out.println("Roll\tName\t\tMarks Pass Birth-Date");
System.out.println("====================================="); w hile(rs.next()) { int
roll = rs.getInt(1); String name = rs.getString(2); int marks = rs.getInt("Marks"); boolean pass =
rs.getBoolean(4); Date d = rs.getDate(5); System.out.printf("%-5d",roll); System.out.printf("%-
10s",name); System.out.printf("%-6d",marks); if(pass) System.out.printf("Yes "); else
System.out.printf("No ");
System.out.printf("%-15s\n",d.toString()); } con.close(); } catch(Exception e){ } } }

260 Consider the follow ing program. W hat should be the correction done in the program to get correct output?im4 N A 2 Error in main()

261 Consider the follow ing program. W hat should be the method used in follow ing program to get correct 4 N A 2 Connection()
output? import java.sql.*; class Ddemo1 { public static void main(String args[]) throw s Exception {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection
c=DriverManager.get***********("jdbc:odbc:ODSN"," "," "); Statement s=c.createStatement(); ResultSet
rs=s.executeQuery("select *from StudTable"); System
.out.println("Name" + " \t " + "Roll_No" + " \t " + "Avg"); w hile(rs.next()) {
System.out.println(rs.getString(1)+" \t "+rs.getInt(2)+" \t \t"+rs.getDouble(3)); s.close(); c.close(); } } }

Consider the follow ing program. W hat w ill be the output? import java.sql.*; class Ddemo1 { public static vo

262 c=DriverManager.getConnection("jdbc:odbc:ODSN"," "," "); Statement s=c.createStatement(); ResultSet rs= 4 N A 2 Display All the Records of StudTable

263 Consider the follow ing program. W hich statement is missing to get correct output? import java.sql.*; class 4 N A 2 Connection c not close
Ddemo1 { public static void main(String args[]) throw s Exception {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection
c=DriverManager.getConnection("jdbc:odbc:ODSN"," "," "); Statement s=c.createStatement(); ResultSet
rs=s.("select *from StudTable"); System .out.println("Name" + " \t " + "Roll_No" + "
\t " + "Avg"); w hile(rs.next()) { System.out.println(rs.getString(1)+" \t "+rs.getInt(2)+" \t
\t"+rs.getDouble(3)); } s.close(); } }

264 Consider the follow ing program. W hat should be the correction done in the program to get correct output? im4 N A 2 Missing Semicolon

265 Consider the follow ing program. W hat should be the correction done in the program to get correct output? 4 N A 2 Missing semicolon and
import java.sql.*; import javax.sw ing.*; import java.io.*; class datadd { public static void main(String
a[]) { try { Driver d= new sun.jdbc.odbc.JdbcOdbcDriver(); DriverManager.registerDriver(d); Connection
con
=DriverManager.getConnection("Jdbc:Odbc:xxx"); Statement s=con.createStatement(); ResultSet
rs=s.executeQuery("Select * from Table1 ") w hile(rs.next()) { String n=rs.getString("name");
System.out.println("name:"+n); String n1=rs.getString("rollnu"); System.out.println("rollnumber:"+n1); }
con.close(); } catch(Exception e) { System.out.println("not Deleted"+e); } }

266 Consider the follow ing program. In w hich statement there is an error? import java.sql.*; class DBEx { 4 N A 2 Error in Connection st
public static void main(String args[]) { try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection c
= DriverManager.openConnection("jdbc:odbc:mydsn","",""); Statement s=c.createStatement(); ResultSet
rs = s.executeQuery("select * from StudTable"); w hile(rs.next()) { System.out.println("Roll No.:
"+rs.getInt(1)); System.out.println("Name : "+rs.getString(2)); System.out.println("Branch :
"+rs.getString("Branch")+"\n"); } s.close(); c.close();
}catch(Exception e) { System.out.println("Caught: "+e); } } }
267 Consider the follow ing program. Select the statement that should be added to get correct output. import 4 N A 2 Statement s = c.creat
java.sql.*; class DBEx { public static void main(String args[]) { try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection c =
DriverManager.getConnection("jdbc:odbc:mydsn","",""); ResultSet rs = s.executeQuery("select
* from StudTable"); w hile(rs.next()) { System.out.println("Roll No.: "+rs.getInt(1));
System.out.println("Name : "+rs.getString(2)); System.out.println("Branch :
"+rs.getString("Branch")+"\n"); } s.close(); c.close(); }catch(Exception e) { System.out.println("Caught:
"+e); } } }

268 Consider the follow ing program. W hat should be the correction done in the program to get correct output?. i 4 N A 2 Statement missing

Consider the follow ing program. W hat should be the correction done in the program to get correct output?. i

269 stt(name,rollno,city)values('RAJ',12,'THANE')"); Statement st=con.createStatement(); st.executeUpdate(r1); 4 N A 2 rs.next()

270 Consider the follow ing program. W hat should be the correction done to get correct output? import java.sql.* 4 N A 2 Use ? symbol instead

271 Consider the follow ing program. W hat should be the correction done to get correct output? import java.sql.* 4 N A 2 No correction is requi

272 Consider the follow ing program. W hich tw o exceptions are throw n? package javaapplication21; import 4 N A 2 ClassNotFoundExcept
java.sql.*; public class db15 { public static void main(String args[]) throw s _____________________,
__________________ { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection c
=DriverManager.getConnection("jdbc:odbc:MyDSN","",""); System.out.println("Connection
Established"); } }

273 Consider the follow ing program.Find error in the program. import java.sql.*; public class dbAccess { public s 4 N A 2 exception in main cla

274 Consider the follow ing program.Find out the output ? import java.sql.*; class Ddemo1 { public static void ma4 N A 2 Riya w ill be inserted

275 Consider the follow ing program.Find w hich statement contains error. import java.io.*; class Demp1 { public 4 N A 2 Error in package
276 Consider the follow ing program.Select the statement that should be added to the program to delete the recor4 N A 2 stm.executeUpdate(q

277 Consider the follow ing program.Select the statement that should be added to the program to get correct outp4 N A 2 con.close()

stmt.executeQuery("select * from tab"); System.out.println("TNAME" + "\t\tTABTYPE" + "\tCLUSTERID"); w h

278 Consider the follow ing program.W hat shoud be added to the program to get the correct output. import java. 4 N A 2 ps.executeUpdate();

279 Consider the follow ing programe & find the error statement. import java.sql.*; class Test{ public static 4 N A 2 Missing Statement st=
void main(String ar[]){ try{ String url="jdbc:odbc:mydsn";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection c=DriverManager.getConnection(url);
ResultSet rs=st.executeQuery("select * from login"); w hile(rs.next()){
System.out.println(rs.getString(1)); } }catch(Exception ee)
{System.out.println(ee);} } }

280 Consider the given code.W hat should be the correction in the program to get correct output? import java.sql.4 N A 2 Type of exception not

281 createStatement( ) method returns_____________________ 4 N R 2 Statement object

282 database programming using Java throw s w hich exception? 4 N R 2 SQLException

283 DatabaseMetaData are retrieved through ____________. 4 N R 2 Connection object

284 DatabaseMetaData md=rs.getMetaData(); System.out.println("Database is:”+md.getDatabaseProductName() 4 N A 2 Object of Database, d

285 Debug the follow ing code and find w hich statement contains error. import java.sql.*; import java.io.*; class 4 N A 2 All of the above

286 Debug the follow ing code and find w hich statement contains error. import java.sql.*; import java.io.*; class 4 N A 2 Error in statement w

287 DriverManager class does not provides methods for ___________________ 4 N R 2 Executing sql statement and retrievi

288 executeQuery() method returns_____________________ 4 N R 2 ResultSet object

289 Find Correction in follow ing statment to prepare prepareStatment Object. PreparedStatement pstmt; String q4 N U 2 pstmt = con.prepareS
pstmt.setString(2,&qu

Find Errors import java.sql.*; class Test{ public static void main(String ar[])throw s Exception {

290 String url="jdbc:odbc:mydsn"; Connection c=DriverManager.getConnection(url); } } 4 N A 2 Drivers are not loaded


291 Find Errors import java.sql.*; class Test{ public static void main(String ar[])throw s Exception { String url="j4 N A 2 no url is passed for ge

292 Find Missing Statemt in program. import java.sql.*; import java.net.*; class conn { public static void main(St4 N U 2 Connection con=Drive

293 find out the error in the follow ing program to get correct output? import java.sql.*; import java.io.*; class 4 N A 2 error in main()
InsertDemo { public Static void Main(String args[]) { int c=0; try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String myURL="jdbc:odbc:college"; Connection
con=DriverManager.getConnection(myURL); Statement st=con.createStatement();
c=st.executeUpdate("insert into emp values(1,4000)") if(c!=0) System.out.println("Record inserted"); else
System.out.println("Record NOT inserted"); con.close(); }catch(Exception e){}
}}

294 Find out the missing statement to get the correct output in bellow program import java.sql.*; class stud2 { 4 N A 2 s1=con.createStatem
public static void main(String ar[])throw s Exception { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:studdsn"); Statement s1; ResultSet res;
System.out.println("Before deletion"); res=s1.executeQuery("select * from student"); w hile(res.next()) {
System.out.println("Name\t"+res.getString(1)+" Roll_NO\t"+res.getInt(2)+" per\t"+res.getInt(3)); }
Statement st=con.createStatement(); st.executeUpdate("delete from student w here Roll_No=2");
System.out.println("deleted"); System.out.println("After
deletion"); res=s1.executeQuery("select * from student"); w hile(res.next()) {
System.out.println("Name\t"+res.getString(1)+" Roll_NO\t"+res.getInt(2)+" per\t"+res.getInt(3)); } } }

295 Find out the statement containing error. import java.sql.*; import java.io.*; class DisTable1 { public static vo4 N A 2 Statement w here pre

296 Find the error in follow ing program. import java.sql.*; class conn3 { public static void main(String h[]) { 4 N A 2 Error in PreparedState
try { int i; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); System.out.println("Driver are properly
loaded"); String url="jdbc:odbc:abc1"; Connection con=DriverManager.getConnection(url);
System.out.println("connection established"); PreparedStatement state=con.PrepareStatement("select
Name,Age from stud9 w here
Age=?"); System.out.println("statement obj created"); String sql="select Name,Age from stud9 w here
Age=?"; int Age=2; state.setInt(1,Age); ResultSet rs=state.executeQuery(); String text=""; w
hile(rs.next()) { text=text+rs.getString(1)+""+rs.getInt(2); } System.out.println(text); }
catch(SQLException e) { System.out.println("Sql error has occured"+e.getMessage()); } catch(Exception e)
{ System.out.println("error!connection not establishd"+e.getMessage()); } } }

297 Find the error in the follow ing program import java.sql.*; public class dbDemo2 { public static void 4 N A 2 Both A and C
main(String args[])throw s Exception { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection c
=DriverManager.getConnection("jdbc:odbc:MyDSN","",""); Statement s=c.createStatement("select* from
student"); ResultSet rs=s.executeUpdate(); System.out.println("Name"+"\t"+"Roll no"+"\t"+"Avg"); w
hile(rs.next())
{System.out.println(rs.getString(1)+"\t"+rs.getInt(2)+"\t"+rs.getDouble(3)); } s.close();
c.close(); } }

298 Find the error in the follow ing program import java.sql.*; class Ddemo1 { public static void main(String args4 N A 2 error in call to execut

299 Find the error in the given code import java.sql.*; class Mydatabase1 { public static void main(String args[]) 4 N A 2 Drivermanager class n
300 Find the error in the given code import java.sql.*; class Mydatabase1 { public static void main(String args[]) 4 N A 2 Syntax of SetInt &am

301 Find the error in the given code Statement st=c.createStatement(); Resultset rs=st.executeQuery("Select * f 4 N A 2 Resultset interface na

302 Find the error of follow ing code import java.sql.*; public class dbAccess { public static void main(String[] arg4 N U 2 Try and catch block m

303 Find the missing method in follow ing code. class jdbc1 { public static void main(String ar[])throw s Exception4 N A 2 createStatement();

304 Find the missing statement import java.sql.*; class Ddemo1 { public static void main(String args[]) throw s E4 N A 2 ResultSet rs=s.execut

305 find the missing statement import java.sql.*; public class dbDemo1 {public static void main(String args[])thr4 N A 2 s.executeUpdate(quer

306 Find the missing statement from w hich the output w ill be displayed as connection established. import java.s4 N A 2 con=DriverManager.g

307 Find the missing statement to get output. import java.sql.*; class conn1 { public static void main(String h[]) 4 N A 2 Missing }

catch(SQLException e) { System.out.println("Sql error has occured"); } catch(Exception e) { System.out.prin

308 getConnection() method have w hich parameters: _____________________ 4 N R 2 URL -JdbclOdbc:DSN ,String Usernam

309 getConnection() method of DriverManager returns __________________________ 4 N U 2 Connection Object

310 getResultSet() method belongs to _____________________. 4 N U 2 Statement interface

311 getUsername() method is used to 4 N U 2 retrieve name of user

312 How do you use a savepoint? 4 N A 2 A savepoint is used to

313 How is a pre-compiled query w ritten? Pick out the correct statement. 4 N A 2 Class.forName(&quot;
c=DriverManager.getC
&quot;); PreparedSta
empid=?&quot;); Res
314 How many firstname w ill be displayed using follow ing code ? import java.sql.*; public class 4 N A 2 3
JdbcPreparedstatementExample { static private final String driver = "sun.jdbc.odbc.JdbcOdbcDriver"; static
private final String connection = "jdbc:odbc:emp"; public static void main(String args[]) { Connection con
= null; PreparedStatement pst = null; ResultSet rs = null; try { Class.forName(driver); con =
DriverManager.getConnection(connection); String sql = "select * from Employees w here FirstName " +
"in(?,?,?)"; pst = con.prepareStatement(sql); pst.setString(1, "komal"); pst.setString(2, "ajay");
pst.setString(3, "santosh"); rs = pst.executeQuery(); System.out.println("EmployeeID\tFirstName"); w hile
(rs.next()) { System.out.print(" "+rs.getString(1)); System.out.print("\t\t"+rs.getString(2));
System.out.println("\t\t"+rs.getString(3)); } } catch (Exception e) { System.out.println(e); } }
}

315 How w ill JDBC help the programmers to w rite java applications that manage programming activities: 4 N U 2 All of Above

316 Identify Component at ?___________________ Figure:- 4 Y1 R 2 DBMS

317 Identify correct syntax of executeQuery() method of statement interface. 4 N U 2 public ResultSet executeQuery( Strin

318 Identify the correct code to retrive values from database 4 N A 2 Statement st=con.cre
}

319 Identify the missing code in the program given below . import java.sql.*; class stud_records { public static vo4 N A 2 prepareStatement();

320 Identify w rong type of ResultSet 4 N U 2 ResultSet.TYPE_BACKW ORD_ONLY


321 If ResultSet is forw ard only then w hich method can not be execute 4 N A 2 first

322 If ___________is set to true,then a commit is implicitly applied after the execution of every 4 N R 2 AutoCommit
SQL statement.

323 import java.io.IOException; import java.sql.*; w hat is the correction in the follow ing code to get the output 4 N A 2 Missing Semicolon

324 import java.sql.*; public class jdbcConn { public static void main(String[] args) throw s Exception{ 4 N A 2 Id Name Job 23 Rosha
Class.forName("org.apache.derby.jdbc.ClientDriver"); Connection con = DriverManager.getConnection
("jdbc:derby://localhost:1527/testDb","name","pass"); PreparedStatement updateemp =
con.prepareStatement ("insert into emp values(?,?,?)"); updateemp.setInt(1,23);
updateemp.setString(2,"Roshan"); updateemp.setString(3, "CEO"); updateemp.executeUpdate();
Statement stmt = con.createStatement(); String query = "select
* from emp"; ResultSet rs = stmt.executeQuery(query); System.out.println("Id Name Job"); w hile
(rs.next()) { int id = rs.getInt("id"); String name = rs.getString("name"); String job = rs.getString("job");
System.out.println(id + " " + name+" "+job); } } }

325 import java.sql.*; public class jdbcConn { public static void main(String[] args) throw s Exception{ Class.forN4 N A 2 no of columns in the t
No of characters in 3r
326 Import java.sql.*; class connectionTest { public static void main(String args[]) { try { Class.forName(“sun.jd 4 N A 2 undefined symbol url

327 import java.sql.*; class S14 { public static void main(String args[])throw s Exception; { Class.forName("sun.j4 N A 2 Error in main()

328 import java.sql.*; import java.io.*; import java.sql.Satement; import java.lang; public class conTestTable { p4 N A 2 Selected record is del

329 import java.sql.*; import sun.jdbc.odbc.*; class mydatabase { public static void main(String args[]) throw s S4 N A 2 this program w ill cha

330 import java.sql.*; public class Pstatement { public static void main(String args[]) { try { Class.forName("sun 4 N A 2 ?,?

331 import java.sql.*; class FetchRecord{ public static void main(String args[])throw s Exception{ Class.forName 4 N A 2 deletes the record hav

332 import java.sql.*; class InsertPrepared{ public static void main(String args[]){ try{ 4 N A 2 101 is inserted at firs
Class.forName("oracle.jdbc.driver.OracleDriver"); Connection
con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","oracle");
PreparedStatement stmt=con.prepareStatement("insert into Emp values(?,?)"); stmt.setInt(1,101);//1
specifies the first parameter in the query stmt.setString(2,"Ratan"); int i=stmt.executeUpdate();
System.out.println(i+" records inserted"); con.close();
}catch(Exception e){ System.out.println(e);} } }

333 In W hich driver Netw ork connection is indirect that a JDBC client makes to a middlew are process that acts a4 N U 2 A.JDBC-Net

334 In DriverManager class w hich method is used to establish the connection w ith the specified url? 4 N A 2 public static Connecti

335 In follow ing Java code fill statement show ing ***.Select any one option from given options import java.io.*;4 N A 2 insert into student va

336 In follow ing Java program fill statement show ing **************.Select any one option to get correct outp4 N A 2 pstm.setInt(1, rno); a
337 In follow ing Java program fill statement show ing ***.Select any one option fro given options import java.sq 4 N A 2 con.createStatement(

338 In follow ing Java program fill statement show ing ________________. Select any one option fro given 4 N A 2 DriverManager.getCon
options import java.sql.*; class Type1 { public static void main(String[] args) {try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String url="jdbc:odbc:dsn3"; Connection conn
= ____________________ System.out.println("successfully connected"); }catch(Exception e)
{System.out.println(e); } } }

In follow ing Java program fill statement show ing _______________________.Select any one option fro give

339 srgs[]) { try { Class.forname("sun.jdbc.odbc.JdbcOdbcDriver"); System.out.println("Driver loaded"); String 4 N A 2 executeQuery(sql);


url="jdbc:odbc:info"; Connection con=DriverManager.getConnection(url); System.out.println("connection
to database created"); Statement smt=con.createStatement(); System.out.println("Statement object
created"); String sql="Select Name,Age from Amol"; ResultSet result=smt._______________________
String text=""; w hile(result.next()); { text
+result.getString(1)+""+results.getInt(2)+'\n'; } System.out.println(text); } catch(sQLException e) {
System.out.pritln("SQL error"); } catch(Exceptionn e) { System.out.println("error"); }

340 In setXxx() methods used for PreparedStatement the first argument specifies w hich value? 4 N U 2 index of Question mark

341 In the below code, rs is an object of _________ interface of JDBC API w hile (rs.next()) { System.out.println(4 N U 2 ResultSet

342 In the below statement, w hich type of query can be used w ith executeUpdate() method statement.executeU4 N U 2 INSERT, UPDATE, DEL

343 In the follow ing JDBC drivers w hich are know n as fully java driver? 4 N A 2 Both B &amp; C

344 In the follow ing JDBC drivers w hich is know n as partially java driver? 4 N A 2 Native-API driver

345 In the follow ing program make corrections to get correct output: import java.sql.*; class DBEx 4 N A 2 s.executeUpdate(sql);
{ public static void main(String args[]) { try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection
c = DriverManager.getConnection("jdbc:odbc:mydsn","",""); Statement s =
c.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE); String sql =
"create table Product(prod_id Integer, prod_name varchar(25), price Double)"; s.executeCreate(sql);
System.out.println("Table created."); c.close(); }catch(Exception e) { System.out.println("Exception
generated: "+e); } } }

346 In Transaction Management in JDBC Transaction represents? 4 N A 2 single unit of w ork

347 In Transaction Management of JDBC w hich means once a transaction has been committed, it w ill remain so, 4 N A 2 Durability

348 In w hich layer tw o tier model are divided into tw o parts 4 N R 2 application layer &amp; database la

349 In w hich the result set generally does not show changes to the underlying database that are made w hile it is4 N U 2 B.TYPE_SCROLL_INSE

350 insert the missing statement ,rectify incorrect statement and choose the correct option for given program. Im4 N A 2 import java.sql.*; con

351 Invoking Class.forName(mydriver) throw s ___________. 4 N A 2 ClassNotFoundException

352 JDBC is …………………level interface w hich means that it is used to invoke SQL command directly 4 N A 2 low level

353 JDBC-ODBC Bridge is 4 N U 2 multithreded

354 kind of driver converts JDBC calls on client API for Oracle, cybase, Informix, DB2, or other DBMS 4 N U 2 Native API partly-Java
is know n as__________

355 Method w hich drops the driver from the list of drivers registered in the DriveManager class. 4 N A 2 deregisterDriver(Driver driver)

356 Methods such as next(),previous(),last(),first() are of w hich interface? 4 N U 2 ResultSet

357 Microsoft Access data in a _________________file format. 4 N U 2 .MDB


358 Modified the stament from follow ing program to get correct output. import java.sql.*; public class 4 N A 2 int iNo=s.executeUpd
TestStudData { public static void main(String args[])throw s Exception {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection c
=DriverManager.getConnection("jdbc:odbc:MyDSN","",""); PreparedStatement

s=c.prepareStatement( "update db3 set Name=? w here Roll_no=?"); s.setString(1,args[0]); s.setString(2,In

359 Observe follow ing code and find out missing statement. import java.io.*; import java.sql.*; 4 N A 2 Semicolon Missing
class updatdb {public static void main(String args[]) {try
{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con
=DriverManager.getConnection("jdbc:odbc:stud"); Statement s = con.createStatement(); int r
= s.executeUpdate("update stud set name=priti w here name='preety'"); System.out.println("No. of row
updated:"+r) ResultSet rs=s.executeQuery("select * from stud"); w hile(rs.next())
{System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getInt(3));
} con.close(); } catch(Exception e){ } } }

360 Observe follow ing code and select correct statement for it to be executed. ResultSetMetaData md = rs.getMe4 N A 2 ResultSetMetaData m

361 Observe the follow ing code and w hat w ill be the output of the program import java.sql.*; import java.io.*; 4 N A 2 The output w ill give i

362 Observe the follow ing figure and identify the type of architecture. Figure:- 4 Y1 R 2 Tw o-Tier

363 Observe the follow ing program import java.sql.*; class TYIFCon{ public static void main(String args[]){ try{ 4 N A 2 This program w ill fet

364 Observer the follow ing program. import java.sql.*; import java.io.*; class TYIFloop{ public static void main(S4 N A 2 This program w ill ins

System.out.println(i+" records affected"); System.out.println("Do you w ant to continue: y/n"); String s=br.r

365 Observer the follow ing program. import java.sql.*; class Test{ public static void main(String ar[]){ try{ 4 N A 2 Follow ing statement
String url="jdbc:odbc:mydsn"; Connection c=DriverManager.getConnection(url); Statement
st=c.createStatement(); ResultSet rs=st.executeQuery("select * from login"); w hile(rs.next()){
System.out.println(rs.getString(1)); } }catch(Exception ee)
{System.out.println(ee);} }
366 Observer the follow ing program. import java.sql.*; class Test{ public static void main(String ar[]){ try{ Strin4 N A 2 There is compiler erro

367 Observer the follow ing program. import java.sql.*; class TYIFCon{ public static void main(String args[]){ try4 N A 2 In This program execu

368 Output of follow ing code is : import java.sql.*; class createTable { public static void main(String[] args) { tr 4 N A 2 driver loaded connect
Record Inserted :: 3 R
CCC

369 Output of the follow ing program import java.sql.*; Class ExecuteUpdateTest { Public static void 4 N A 2 Driver loaded Connec
main(String argu[]) { Try { int I; Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”); Record Inserted 2 Rec
System.out.println(“Driver Loaded”); String url=”jdbc:odbc:xyz”; Connection
con=DriverManager.getConnection(url); System.out.println(“Connection to database created”); Statement
state=con.createStatement(); System.out.println(“Statement object created”); String sql=”Insert into tanni
values(‘Tanmy’,2)”; I=state.executeUpdate(sql); System.out.println(“Record inserted ”+i); String
sql1=”Insert into tanni values(‘Raddhi’,2)”;
I=state.executeUpdate(sql1); System.out.println(“Record inserted”+i); String sql2=”Insert into tanni
values(‘Siddi’,2)”; I=state.executeUpdate(sql2); System.out.println(“Record inserted”+i);
} Catch(SQLException e) { System.out.println(“SQL error”); } Catch(Exception e){ System.out.println(“SQL
error”); } } }

370 Permission class is part of_________package 4 N A 2 java.security.permission

371 Predict output import java.sql.*; class Test{ public static void main(String ar[])throw s Exception { String url 4 N A 2 Drivers Loaded and co

372 Predict output import java.sql.*; class Test{ public static void main(String ar[])throw s Exception { String url 4 N A 2 Error

373 Prepared Statement interface creates an object that represents a________________ 4 N U 2 Precompiled SQL Statement

374 PreparedStatement interface extends____________________ interface 4 N U 2 Statement

375 PreparedStatement object in JDBC is used to execute ____________________quiries 4 N A 2 parameterized

376 PreparedStatement updateemp = con.prepareStatement("insert into emp values(?,?,?)"); How many values a4 N A 2 3

377 PrepareStatement() method is of ____________________ interface 4 N U 2 Connection

378 Provides information about occurance of event____________ 4 N A 2 javax.sql.ConnectionEvent

379 public class DriverManager extends 4 N U 2 Object

380 Rearrange the steps to connect to the database in SQL a. Create the connection object b. Execute the query c4 N U 2 d-a-e-b-c

381 ReslutSetMetaData Interface Object created by ______________ method, of ____________ 4 N U 2 getMetaData(), Resul
interface

382 ResultSet interface is used to retrive the result form the database table? 4 N A 2 1
383 ResultSet is __________________W hich Represents a data from database 4 N R 2 Table of Data

384 ResultSet rs = stmt.executeQuery("SELECT COF_NAME, PRICE FROM COFFEES"); w here the stmt is Stateme 4 N A 2 pst = con.prepareStat
ResultSet rs = pst.exe

385 ResultSetMetadata are retrieved through ____________. 4 N A 2 None of Above

386 select correct method of statement interface 4 N U 2 public ResultSet executeQuery(String

387 select correct statement to delete row from table employee w here emp_id=? 4 N A 2 String sql=”delete fro

388 Select correct statement w hich is to be used here for inserting a new record in DB having columns 4 N A 2 int r = s.executeUpda
RollNo,Name and Percentage. import java.io.*; import java.sql.*; import java.sql.Statement; class insertdb
{public static void main(String args[]) {try
{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con
=DriverManager.getConnection("jdbc:odbc:stud"); Statement s = con.createStatement();
System.out.println("No. of row updated:"+r); ResultSet rs=s.executeQuery("select * from stud"); w
hile(rs.next()) {System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getInt(3));
} con.close(); } catch(Exception e){ } } }

389 Select correct statements to be w ritten in space provided w ith * in follow ing given codeimport java.sql.*; c 4 N A 2 Connection con=Drive

390 Select the correct method(s) to create CallableStatement: 4 N U 2 All of the above

391 Select the correct option for fill in the blank import java.sql.*; class data { public static void main(String 4 N A 2 A. PreparedStatement
a[]) { Driver d= new sun.jdbc.odbc.JdbcOdbcDriver(); DriverManager.registerDriver(d); Connection con
=DriverManager.getConnection("Jdbc:Odbc:UUU");
_____________________________________________ } }

Select the correct option for fill in the blank import java.sql.*; class data { public static void

392 main(String a[]) { try { Driver d= new sun.jdbc.odbc.JdbcOdbcDriver(); DriverManager.registerDriver(d); 4 N A 2 DSN name and con.cr
Connection con
=DriverManager.getConnection("Jdbc:Odbc:_____________________"); Statement
s=_____________________________ int n=s.executeUpdate("Insert into Table1 values('hhh',12)");
if(n==1) { System.out.println("Record inserted "); con.close(); } } catch(Exception e) {
System.out.println("not Inserted"+e); } } }

393 Select the correct option that can be used to create a result set in w hich the cursor can move in both the dire4 N U 2 TYPE_SCROLL_SENSI

394 select the missing statement from program given below import java.sql.*; class ps_insert { public static void 4 N U 2 String str=&quot;inse
ps=con.prepareStatem

395 Select the missing statement in the program to get the follow ing output. import java.sql.*; class Demo1 { 4 N A 2 ps.setString(2,s1);
public static void main(String args[]) throw s Exception { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c=DriverManager.getConnection("jdbc:odbc:student"," "," "); int r1=11; String s1="suhas";
String str="insert into studTable values(?,?); PreparedStatement ps=c.prepareStatement(str);
ps.setInt(1,r1); ps.executeUpdate(); System.out.println("Data inserted:"); s.close(); c.close();
}}

396 Select the missing statement in the program to get the output import java.sql.*; import java.io.*; class RS{ p4 N A 2 ps.executeUpdate();
397 Select the proper missing method for the follow ing code String queryLehigh = "select * from Lehigh"; Result 4 N A 2 executeQuery()

398 select the proper statement to establish the connection w ith database 4 N U 2 Connection con=DriverManager.getC

399 Select the statement from options that should get added at ********************** in bellow program 4 N A 2 st.executeUpdate();
import java.sql.*; class stud4 { public static void main(String ar[])throw s Exception {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection
con=DriverManager.getConnection("jdbc:odbc:studdsn"); Statement s1=con.createStatement(); ResultSet
res; System.out.println("Before Updation"); res=s1.executeQuery("select * from student"); w
hile(res.next()) { System.out.println("Name\t"+res.getString(1)+" Roll_NO\t"+res.getInt(2)+"
per\t"+res.getInt(3)); } PreparedStatement st=con.prepareStatement("update student set Name=? w here
Name=? "); st.setString(1,"Ram"); st.setString(2,"Ramesh");
**************************************************** System.out.println("updated");
System.out.println("After updation"); res=s1.executeQuery("select * from student"); w hile(res.next()) {
System.out.println("Name\t"+res.getString(1)+" Roll_NO\t"+res.getInt(2)+" per\t"+res.getInt(3)); } } }

Select the statement that should be added to program to get corrected output import java.sql.*; import java.

400 s1; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); System.out.println("Drivers loaded"); String url="j 4 N A 2 ResultSet rs=st.execu

401 Select the statement that should be added to the follow ing program to get the correct output. import java.sq 4 N A 2 Class.forName(&quot;

402 Select the statement that should be added to the program to get correct output. import java.sql.*; public 4 N A 2 s.executeUpdate()
class db15 { public static void main(String args[])throw s Exception {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection c
=DriverManager.getConnection("jdbc:odbc:MyDSN","",""); PreparedStatement s=c.prepareStatement(
"update db3 set Name=? w here Roll_no=?"); Statement s=c.createStatement( ); s.setString(1,args[0]);
s.setString(2,args[1]); s.setString(3,args[2]); ResultSet rs=s.executeQuery("select* from db3");
System.out.println("Name"+"\t"+"Roll no"+"\t"+"Avg"); w hile(rs.next()) {
System.out.println(rs.getString(1)+"\t"+rs.getInt(2)+"\t"+rs.getDouble(3)); } s.close(); c.close(); } }

403 Set XXX() method binds values to the parameters. W here XXX represents 4 N U 2 Data Type

404 Statement interface is used for ________________________________ 4 N U 2 sending SQL queries to the databas

405 Stored procedures have w hich of the follow ing advantages? 4 N U 2 Data integrity improves as multiple a

406 Suggest corrections in the follow ing program segment import java.sql.*; import sun.jdbc.odbc.*; class myda 4 N A 2 public static void main
DriverManager.getCon

407 Suppose a prepared statement is created as follow s: Statement preparedStatement = 4 N U 2 preparedStatement.se


connection.prepareStatement("insert into Student (firstName, mi, lastName)" + "values (?, ?,
?)"); To set a value John to the first parameter, use

408 The CallableStatement interface extends _____________________ interface 4 N U 2 PreparedStatement

409 The follow ing example to connect Java Application w ith access? import java.sql.*; class Test { public static v4 N A 2 w ith DSN
410 The follow ing step is for stmt.executeUpdate(sql); sql = "INSERT INTO Registration " + "VALUES(103, 'Sumit4 N A 2 Insert

411 the interface to the database is handle by 4 N U 2 APIS

412 The JDBC-ODBC bridge allow s ---------------------- to be used as --------------------------- 4 N U 2 ODBC drivers,JDBC drivers

413 The JDBC-ODBC Bridge driver is 4 N U 2 Both A &amp; B


414 The JDBC-ODBC Bridge supports multiple concurrent open statements per connection? 4 N A 2 one

415 The method - "public DatabaseMetaData getMetaData()" - belongs to the Interface 4 N A 2 Connection interface
_____________________

416 The methods of Statement interface are 4 N U 2 All of the above

417 The output of follow ing program is : import java.sql.*; class preparestmt { public static void main(String[] a 4 N A 2 driver loaded connect

418 The parameters of the PreparedStatement object are _____w hen the user clicks on the Query button 4 N U 2 initialized

419 The ResultSet is used to get information about a……………………….. 4 N U 2 ResultSet

420 The Statement interface is mainly used to_______________ 4 N U 2 To execute queries asked to databa

421 The statement ___________ changes the Course title to Java Programming for the CourseID 4 N U 2 update Course set titl
11111.

422 The __________ method can be used on a ___________ object to create its meta data object 4 N U 2 getMetaData(),Result

423 The __________ package contains classes that help in connecting to a database, sending 4 N U 2 java.sql
SQL statements to the database, and processing the query result

424 The __________method sets the query parameters of the PreparedStatement Object. 4 N U 2 setString()

425 The __________object provides you w ith methods to access data from the table. 4 N U 2 ResultSet

426 This is an example of prepared statement interface that ? PreparedStatement stmt=con.prepareStatement("se4 N A 2 B. retrieve the record

427 This is an example of Statement interface that? import java.sql.*; class PreStat { public static void 4 N A 2 retrieve the record
main(String args[]) throw s Exception { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection
c=DriverManager.getConnection("jdbc:odbc:student"," "," "); Statement s=c.createStatement("select *
from studTable"); ResultSet rs=s.executeQuery(); System
.out.println("Name" + " \t " + "Roll_No"); w hile(rs.next()) { System.out.println(rs.getInt(1)+" \t
"+rs.getString(2)); } s.close(); c.close(); } }

428 This statement Tells the DB to empty transaction log & bring DB back to the state, before the changes in tran4 N U 2 rollback()

429 Three-tier Architecture includes w hich of the follow ing. 4 N U 2 client layer and tw o server layers

430 To connect to a local MySQL database named test, use 4 N U 2 Connection connection

431 To delete reord from database table student w hat modification w e have to do in follow ing program. import j4 N A 2 int result=stmt.execu

432 To establish connection w ith database w hich method of DriverManager class is used? 4 N U 2 getConnection()

433 To establish the connection w ith the specified url? 4 N U 2 public static Connection getConnection(Str

434 To execute a SELECT statement "select * from Address" on a Statement object stmt, use 4 N U 2 stmt.executeQuery(&quot;select * from Ad
To execute a stored procedure "totalStock" in a database server, w hich of the follow ing code CallableStatement clbstmnt = con.prepare
435 4 N U 2
is used? totalStock}&quot;);cs.executeQuery();
436 To execute create query w hich method is used? 4 N U 2 execute()
To obtain a scrollable or updateable result set, you must first create a statement using the Statement statement = connection.createS
437 4 N U 2
follow ing syntax: ResultSet.CONCUR_UPDATABLE);
438 To set the parameters in PreparedStatement w hich methods are used? 4 N U 2 both a&amp; b

439 To syntax for creating a table named Course should begin w ith __________. 4 N U 2 create table Course (
To to get the column names and row data from a table. Select the proper statement from the
follow ing AT *____________line import java.sql.*; public class SelDemo { public static void
main(String args[]) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con =
DriverManager.getConnection("jdbc:odb c: myDSN "); Statement st = con.createStatement();
440 *_________________________________//(Choose correct option for this line) 4 N A 2 ResultSet sel = st.executeQuery (&quot;se
w hile(sel.next()) { String name = sel.getString(1); String pass = sel.getString(2);
System.out.println(name+" "+pass); } } catch(Exception e) {
System.out.println("Errooorrrr"+e.getMessage()); } } }

try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
441 Class.forName("oracle.jdbc.driver.OracleDriver"); } catch(ClassNotFoundException cnfe) { 4 N A 2 W ill load tw o different drivers
System.err.println("Error loading driver: " + cnfe); }

442 tw o-tiers and three-tiers architecture is applicable w ith the database? 4 N A 2 YES

443 Valid constant to set ResultSet as Scrollable is _____________________ 4 N A 2 Both B and C

444 W e can use ResultSet navigation methods w hen w e have ResultSet that is of type 4 N U 2 both b&amp;c

445 W hat contains object specific to database,and Used to create Connection object from the options ? 4 N R 2 Driver Interface / Conn

W hat correction should be done in the program to get corrected output import java.sql.*;
import java.io.*; class JdbcP { public static void main(String arg[]) { try { DataInputStream
in=new DataInputStream(System.in); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Drivers loaded"); String url="jdbc.odbc.abc"; Connection
con=DriverManager.getConnection(url); System.out.println("connection established");
PreparedStatement ps=con.prepareStatement("create table movie6(num Integer,mvnm
446 Varchar(30))"); ps.executeUpdate(); System.out.println("Table Created"); String sql="insert 4 N A 2 String url=&quot;jdbc:odbc:abc&quot;;
into movie6 VALUES(?,?)"; PreparedStatement ps2=con.prepareStatement(sql);
System.out.println("Enter movie code"); int mcd=Integer.parseInt(in.readLine());
ps2.setInt(1,mcd); System.out.println("Enter movie name"); String name=in.readLine();
ps2.setString(2,name); ps2.executeUpdate(); con.close(); } catch(SQLException e) {
System.out.println(" sql error"); } catch(Exception e) { System.out.println(" connection
error1"); } } }

W hat correction should be done in the program to get corrected output import java.sql.*;
import java.io.*; class JdbcP { public static void main(String arg[]) { try { DataInputStream
in=new DataInputStream(System.in); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Drivers loaded"); String url="jdbc:odbc:abc"; Connection
con=DriverManager.getConnection(url); System.out.println("connection established");
447 ps.executeUpdate(); System.out.println("Table Created"); String sql="insert into movie6 4 N A 2 Missing Statement
VALUES(?,?)"; PreparedStatement ps2=con.prepareStatement(sql); System.out.println("Enter
movie code"); int mcd=Integer.parseInt(in.readLine()); ps2.setInt(1,mcd);
System.out.println("Enter movie name"); String name=in.readLine(); ps2.setString(2,name);
ps2.executeUpdate(); con.close(); } catch(SQLException e) { System.out.println(" sql error");
} catch(Exception e) { System.out.println(" connection error1"); } } }
W hat does "msbte" indicate in the below code?
448 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection 4 N U 2 Data Source Name
con=DriverManager.getConnection("jdbc:odbc:msbte");
449 W hat does the follow ing code do? smt=con.createStatement(); 4 N A 2 A Statement object is created to sen

450 W hat happens after executation of follow ing code import java.sql.*; public class JdbcAccessConnectionDemo4 N A 2 Connecction OK.

451 W hat happens after executation of follow ing code import java.sql.*; import java.io.*; public class new { 4 N A 2 Successfully Run and
public static void main(String args[]) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Drivers are loaded properly."); String url = "jdbc:odbc:Demo"; Connection c1 =
DriverManager.getConnection(url); String sql="create table emp1(emp_id INTEGER,emp_name
varchar(20))"; PreparedStatement ps = c1.prepareStatement(sql); ps.executeUpdate(); c1.close();
}catch(SQLException se) { System.out.println("SQL Error."); }catch(Exception e) {
System.out.println("Other Error."); } }
}}

452 W hat happens if the follow ing code is executed? import java.sql.*; public class S1Q57{ public static void 4 N A 2 There is a compiler er
main(String[] args) { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con =
DriverManager.getConnection("jdbc:odbc:shree"); Statement stm = con.createstatement(); String query
="select rollno,name,percent from student "; ResultSet rs
= stm.executeQuery(query); w hile(rs.next()){ System.out.println("Roll No = "+rs.getInt(1));
System.out.println("Name = "+rs.getString(2)); System.out.println("per = "+rs.getDouble(3));
} con.close(); } }
453 W hat happens if you call deleteRow () on a ResultSet object? 4 N A 2 The row you are positioned on is del

454 W hat happens if you call the method close() on a ResultSet object? 4 N U 2 the database and JDBC resources ar

455 W hat is correct about DDL statements (create, grant,…)? 4 N A 2 DDL statements are t

456 W hat is error in follow ing program import java.sql.*; class PreparedStatementDemo { public static void mai 4 N A 2 error:incompatible typ

457 W hat is error in follow ing program? import java.sql.*; class PreparedStatementDemo { public static void ma4 N A 2 java.sql.SQLException

458 W hat is error in follow ing program? import java.sql.*; class PreparedStatementDemo { public static void 4 N A 2 java.sql.SQLException
main(String args[]) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con= operator) in query exp
DriverManager.getConnection("jdbc:odbc:Samarth"); PreparedStatement
ps1=con.prepareStatement("update student set Name=? City=? ID=? w here ID=?");
ps1.setString(1,"tttt"); ps1.setString(2,"Belhe"); ps1.setInt(3,777); ps1.setInt(4,777);
ps1.executeUpdate(); ps1.close(); con.close(); } catch(Exception e) { System.out.println(e); }
}}

459 W hat is error in follow ing program? import java.sql.*; class PreparedStatementDemo { public static void ma4 N A 2 java.sql.SQLException

W hat is error in follow ing program? import java.sql.*; class Demo3 { public static void

460 main(String args[]) { try { Class.forName("sun.jdbc.odbc.JdbcodbcDriver"); Connection con= DriverManager.4 N A 2 java.lang.ClassNotFou

461 W hat is meaning of follow ing code snippet System.out.println("NAME\tAGE"); String sql = "select Name, Ag 4 N A 2 executeQuery() meth
ResultSet class

462 W hat is missing in the follow ing program? import java.sql.*; public class execute { public static void main(S4 N A 2 to register the driver

463 w hat is Native Protocol, Pure Java Driver? 4 N A 2 This type of driver, w ritten entirely in

464 W hat is output of follow ing code import java.sql.*; import java.io.*; public class StudentTableInsert { public4 N A 2 Driver Loaded Connec

465 W hat is output of follow ing program. import java.sql.*; public class jdbc1 { public static void main(String 4 N A 2 values of id and name
args[]) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection
con=DriverManager.getConnection("jdbc:odbc:data"); Statement st=con.createStatement(); ResultSet
rs=st.executeQuery("select * from student"); w hile(rs.next()) { System.out.println("id:"+rs.getInt("id"));
System.out.println("name:"+rs.getString("name1"));
} con.close(); } catch(SQLException e) {} catch(Exception e) { } } }

466 W hat is the correct sequence of database connectvity 4 N A 2 My Computer-&gt;Con

467 W hat is the disadvantage of Type-4 Native-Protocol Driver? 4 N A 2 At client side, a separate driver is ne
468 W hat is the error in this code import java.sql.*; class ConnectionDemo { public static void main(String args[ 4 N A 2 Statement not created

469 w hat is the main components of JDBC ? 4 N A 2 all of these

470 W hat is the missing in the follow ing program import java.sql.*; public class connection { public static void m4 N A 2 Connection to databas

471 w hat is the missing statement in follow ing program to access the database using jdbcodbc connection 4 N A 2 Statement stmt = con
import java.util.*; import java.sql.*; public class JdbcDemo { public static void main(String args[]) { String
query = "SELECT Name,Description,Qty,Cost FROM Stock"; try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection
("jdbc:odbc:Inventory"); ResultSet rs = stmt.executeQuery(query); w hile (rs.next()) { String name =
rs.getString("Name"); String desc
= rs.getString("Description"); int qty = rs.getInt("Qty"); float cost = rs.getFloat("Cost");

System.out.println(name+", "+desc+"\t: "+qty+"\t@ $"+cost); } con.close(); } catch(ClassNotFoundExceptio

472 W hat is the ouput of follow ing code?Assume suitable data import java.sql.*; class contest { public static voi 4 N A 2 Table created

473 w hat is the output of follow ing code import java.sql.*; class StudentData { public static void main(String 4 N A 2 marks&gt;40
args[]) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con =
DriverManager.getConnection("jdbc:odbc:stud"); PreparedStatement ps = con.prepareStatement("select *
from Student w here Marks > ?"); ps.setInt(1,40); ResultSet rs
= ps.executeQuery(); System.out.println("marks"); w hile(rs.next()) System.out.println(rs.getString(2));
con.close(); } catch(Exception e){ } } }

474 w hat is the output of follow ing code import java.sql.*; class cont { public static void main(String args[]){ tr 4 N A 2 both b and c

475 w hat is the output of follow ing code Try{ String sql=”update emp set salary=? W here id=?”; PreparedState 4 N A 2 update emp by accep

476 W hat is the output of follow ing Program import java.sql.*; public class jdbcConn { public static void 4 N A 2 No. of row s before co
main(String[] args) throw s Exception{ Class.forName("org.apache.derby.jdbc.ClientDriver"); Connection
con = DriverManager.getConnection("jdbc:derby://localhost:1527/testDb","name","pass"); Statement stmt
= con.createStatement(); String query = "insert into emp values(2,'name1','job')"; String query1 ="insert
into emp values(5,'name2','job')"; String
query2 = "select * from emp"; ResultSet rs = stmt.executeQuery(query2); int no_of_row s = 0;
w hile (rs.next()) { no_of_row s++; } System.out.println("No. of row s before commit statement
= "+ no_of_row s); con.setAutoCommit(false); stmt.execute(query1); stmt.execute(query); con.commit();
rs = stmt.executeQuery(query2); no_of_row s = 0; w hile (rs.next()) { no_of_row s++; }
System.out.println("No. of row s after commit statement = "+ no_of_row s); }

477 W hat is the output of follow ing program: import java.sql.*; class exp10_5 { public static void main(String 4 N A 2 Compile Error
m[])throw s Exception { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection
con=DriverManager.getConnection("jdbc:odbc:dsnname"); Statement cmd=con.createStatement();
rs=cmd.executeQuery("select * from tabel1"); w hile(rs.next()) {
System.out.println(rs.getInt(1)+""+rs.getInt(2)+""+rs.getString(3)); } cmd.close(); con.close();
}}
478 W hat is the purpose of follow ing code? import java.sql.*; class DeleteRecord { public static void 4 N A 2 Deletes all the record
main(String args[])throw s Exception { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection
con=DriverManager.getConnection("jdbc:odbc:xyz"); Statement stmt=con.createStatement(); int
result=stmt.executeUpdate("delete from emp"); con.close();
}}

479 W hat is the purpose of next() method? 4 N U 2 next ( ) method is used to retain nex

480 W hat is the query used to display all tables names in SQL Server (Query analyzer)? 4 N A 2 select * from information_schema.ta

481 W hat is the return value from stmt.executeQuery("insert into T values (100, 'Smith')") 4 N A 2 Result Set object

482 W hat is the return value from stmt.executeUpdate("insert into T values (100, 'Smith')") 4 N A 2 an int value indicating how many ro

483 w hat is the syntax of close() method in conection interface method 4 N A 2 public void close() throw s SQLExcept

484 W hat is the type of 'cmd' object in the follow ing program. import java.sql.*; class exp11_4 { public static 4 N A 2 PreparedStatement
void main(String arg[]) { Class.forName("sun.jdbc.odbc,JdbcOdbcDriver"); Connection
con=DriverManager.getConnection("jdbc:odbc:dsnname"); String str="select * from emp w here
ename='ram'";
____________________cmd=con.__________________(str); ResultSet rs=cmd.executeQuery(); w
hile(rs.next()) { System.out.println(rs.getString(1)+" "+rs.getString(2)); } cmd1.close(); con.close(); } }

485 W hat is the use of Statement interface? 4 N U 2 Statement interface provides metho

486 W hat is, in terms of JDBC, a DataSource? 4 N U 2 A DataSource is a factory of connecti

487 w hat may be the output of follow ing program import java.sql.*; class exp10_1 { public static void main(Stri4 N A 2 1 123 Mahesh 2 453 S

488 W hat MySQL property is used to create a surrogate key in MySQL? 4 N U 2 AUTO_INCREMENT

489 W hat should be at the place of ________ to get the correct output: import java.sql.*; public class 4 N A 2 createStatement()
Updatedbase { public static void main(String args[]) { try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection
con=DriverManager.getConnection("jdbc:odbc:data"); Statement st=con._______________; ResultSet
rs=st.executeQuery("select * from emp"); System.out.println("before change"); w hile(rs.next()) {
System.out.println("id:"+rs.getInt("id")); System.out.println("salary:"+rs.getString("salary"));
System.out.println("name:"+rs.getString("name1")); } int k=st.executeUpdate("Update emp set
salary=1000 w here id=3"); System.out.println("row s affected:"+k); System.out.println("\n\nafter
change"); rs=st.executeQuery("select * from emp"); w hile(rs.next()) {
System.out.println("id:"+rs.getInt("id")); System.out.println("salary:"+rs.getString("salary"));
System.out.println("name1:"+rs.getString("name1")); } con.close(); } catch(SQLException e)
{} catch(Exception e) {} } }

490 W hat should be the correction done in the follow ing program to get correct output? import java.sql.*; 4 N A 2 missing semicolon
import java.io.*; class InsertDemo { public static void main(String args[]) { int c=0; try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String myURL="jdbc:odbc:college"; Connection
con=DriverManager.getConnection(myURL); Statement st=con.createStatement();
c=st.executeUpdate("insert into emp values(1,4000)") if(c!=0) System.out.println("Record inserted"); else
System.out.println("Record NOT inserted"); con.close(); }catch(Exception e){}
}}

491 W hat should be the correction done in the follow ing program to get correct output? import java.Sql.*; 4 N A 2 import java.SQL.*;
import java.io.*; class insertDemo { public static void main(String args[]) { int c=0; try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String myURL="jdbc:odbc:college"; Connection
con=DriverManager.getConnection(myURL); Statement st=con.createStatement();
c=st.executeUpdate("insert into emp values(1,4000)"); if(c!=0) System.out.println("Record inserted"); else
System.out.println("Record NOT inserted"); con.close(); }catch(Exception e){}
}}

492 W hat should be the correction done in the program to get correct output? class Ddemo1 { public static void m4 N A 2 Missing package state

W hat should be the correction done in the program to get correct output? import java.sql.*; class Ddemo1 {
493 c=DriverManager.getConnection("jdbc:odbc:ODSN"," "," "); Statement s=c.createStatement(); ResultSet rs= 4 N A 2 Missing }

494 W hat should be the correction done in the program to get correct output? import java.sql.*; class TestData {4 N A 2 Error in connection st

495 W hat statement should be modified to get the output as show n in fig. import java.sql.*; class stud1 { 4 Y1 A 2 System.out.println(&q
public static void main(String ar[])throw s Exception { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); &quot;+res.getInt(2)+
Connection con=DriverManager.getConnection("jdbc:odbc:studdsn"); Statement System.out.println(&q
s1=con.createStatement(); ResultSet res; System.out.println("Before insertion"); &quot;+res.getInt(2)+
res=s1.executeQuery("select * from student"); w hile(res.next()) {
System.out.println("Name\t"+res.getInt(1)+" Roll_NO\t"+res.getInt(2)+" per\t"+res.getInt(3));
} Statement st=con.createStatement(); st.executeUpdate("insert into student values('Joshi',10,75)");
System.out.println("inserted"); System.out.println("After insertion"); res=s1.executeQuery("select * from
student"); w hile(res.next()) { System.out.println("Name\t"+res.getString(1)+"
Roll_NO\t"+res.getInt(2)+" per\t"+res.getInt(3)); } } }
Figure:-

496 W hat the follow ing statement returns? SQLW arning w arning = statement.getW arnings(); System.out.print4 N U 2 Description about SQL

497 W hat w ill be display in output using the follow ing code. import java.sql.*; class Test { public static void ma4 N A 2 connection establishe

498 w hat w ill be output of given code //Load the database Driver Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"4 N A 2 record w ill be deleted

499 W hat w ill be output of this program import java.sql.*; public class JDBCExample { public static void main(S 4 N A 2 It w ill create a table

W hat w ill be the out of the follow ing code? import java.aw t.*; import java.io.*; public class

500 Demo { public static void main(String args[]) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); System4 N U 2 Error

501 W hat w ill be the output for follow ing code? import java.sql.*; class SelectD { public static void main(String 4 N A 2 Display student’ roll n
greater than 70.
502 W hat w ill be the Output of follow ing code? import java.sql.*; public class SmtInterfaceDemo { public static 4 N U 2 Table is created w ith

503 W hat w ill be the output of follow ing code? import java.sql.*; public class JdbcGetConnection { 4 N A 2 Connection is closed :
public static void main(String args[]) { Connection con = null; Statement st = null; ResultSet rs
= null; try { Class.forName("com.mysql.jdbc.Driver"); con = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/komal", "root", "root"); System.out.println("Connection is closed
: " + con.isClosed()); con.close(); System.out.println("Connection is closed : " +
con.isClosed()); } catch (Exception e) { System.out.println(e); } } }

504 W hat w ill be the output of follow ing program? import java.sql.*; class DBTest { public static void main(Stri 4 N A 2 Driver Loaded Connec

505 W hat w ill be the output of follow ing program? import java.sql.*; class conn1 { public static void main(Strin 4 N A 2 Driver are properly lo

506 W HAT W ILL BE THE OUTPUT OF THE BELOW PROGRAM: import java.sql.*; class ConnectionTest 4 N A 2 BOTH Option i and Op
{ public static void main(String args[]) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Driver loaded"); String url="jdbc:odbc:xyz"; Connection con =
DriverManager.getConnection(url); System.out.println("connection to database created"); }
catch(SQLException e) { System.out.println("SQL error"); } catch(Exception e) {
System.out.println("error"); } } }

507 W hat w ill be the result of executing the follow ing code snippet? Statement sql2 = 4 N A 2 W ill result in compila
con.createStatement(); int result=sql2.executeUpdate("Select * From Publishers");

508 W hat w ill happen if resultSet() is not present in JDBC? 4 N A 2 None of the above

509 W hat w ill happen if w e does not use the close() method? 4 N A 2 Connection w ill does not close

510 W hat w ill the follow ing statement display? select Student.* from Student, Course, Enrollment w here Stude4 N A 2 The statement display
starting w ith S.

511 W hen a connection is created, by default it is in _____________ 4 N U 2 auto commit mode

512 W hen the message "No suitable drivers found" is displayed? 4 N U 2 if JDBC database URL passed is not c

513 W hen using ODBC, w hich of the follow ing processes ODBC requests and submits specific SQL 4 N A 2 Driver.
statements to a given type of data source?

514 W here is Metadata stored in MYSQL? 4 N U 2 In MYSQL database Mysql

515 W here to w rite query to delete records in the follow ing program import java.sql.*; public class DeleteRecord4 N A 2 As a parameter to Exe

516 W hich are the statements related to retrieving table names from a database? 4 N A 2 … Connection con = …

517 W hich class has traditionally been the backbone of the JDBC architecure ? 4 N U 2 A.the JDBC driver manager

518 W hich interface allow s storing results of query.F39 4 N U 2 Resultset


519 w hich are Exception generated follow ing code import java.sql.*; class Test { public static void main(String[]4 N A 2 ClassNotFoundExcept

520 W hich are methods belongs to DataBaseMetaData? 4 N U 2 getUserName(). ,isReadonly()

521 w hich are the methods are used for Connection interface 4 N U 2 All of the above

522 W hich class not comes under java.sql package 4 N A 2 Class

523 W hich class w ill use to create the ps object in the given code? import java.sql.*; public class create { public 4 N A 2 PreparedStatement

524 W hich code is correct to generate the given output? Figure:- 4 Y1 A 2 a) PreparedStatement
Name='Ram'&quot;);

525 W hich code segment could execute the stored procedure "countRecs()" located in a database server? 4 N U 2 CallableStatement cs

526 W hich driver is called as thin-driver in JDBC 4 N A 2 Type-4

527 W hich driver is efficient and alw ays preferable to use in JDBC applications? 4 N U 2 Type 4

528 W hich interface provides methods to execute queries w ith the database? 4 N U 2 Statement interface

529 w hich interfaces provide methods for batch processing in JDBC 4 N U 2 Both A &amp; B

530 W hich is a correct coponent of JDBC API 4 N U 2 both a &amp; b

531 W hich is not a Navigation method of ResultSet interface 4 N U 2 beforeLast()

532 w hich is the correct discription of the close() method 4 N A 2 closes the curtrent stmt object

533 W hich is the correct method for updating table row s from given option. import java.sql.*; public class 4 N A 2 executeUpdate()
Updatedbase { public static void main(String args[]) { try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection
con=DriverManager.getConnection("jdbc:odbc:data"); Statement st=con.createStatement(); ResultSet
rs=st.executeQuery("select * from emp"); St.********("Update emp set name1='jack' w here id=2");
System.out.println("\n\nafter change"); rs=st.executeQuery("select * from emp"); w hile(rs.next()) {
System.out.println("id:"+rs.getInt("id")); System.out.println("salary:"+rs.getString("salary"));
} con.close(); } catch(SQLException e){} catch(Exception e) { } } }

534 W hich is the correct option form the follow ing for JDBC driver types? 4 N U 2 1 JDBC-ODBC bridge

535 W hich JDBC driver maps the JDBC calls to the native method calls, w hich are passed to the local native Call 4 N U 2 Native-API-Partly-Jav

536 W hich JDBC driver Type(s) can be used in either applet or servlet code? 4 N A 2 Both Type 3 and Type 4
537 W hich JDBC driver Type(s) can you use in a three-tier architecture and if the W eb server and the DBMS are 4 N A 2 All of Type 1, Type 2,

538 W hich JDBC driver Type(s) is (are) the JDBC-ODBC bridge? 4 N U 2 Type-1

539 W hich JDBC driver Types are for use over communications netw orks? 4 N A 2 Both Type 3 and Type 4

540 W hich kind of driver converts JDBC calls into calls on the client API for Oracle, Sybase, Informix, IBM DB2, or4 N U 2 B. Native -API partly-

541 W hich list gives a quick w ay to determine w hich Connection method is appropriate for creating different typ4 N U 2 D.All of the mentione

542 W hich maintains a cursor pointing to a particular row of data,Initially, cursor points to before the first row ? 4 N U 2 ResultSet interface

543 W hich method executes an sql statement that may return multiple results. 4 N U 2 execute()

544 W hich method is incorrect to execute sql query 4 N U 2 executeUpdate(&quot;select * from

545 W hich method is missing of statement Interface to create table? import java.sql.*; public class createtable { 4 N A 2 execute()

546 W hich method returns the current result in multiple result statements? 4 N A 2 getUpdateCount()

547 W hich minimum package statements are missing? class conn { conn() { try { 4 N U 2 java.sql.*;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection
con=DriverManager.getConnection("jdbc:odbc:samarth"); PreparedStatement
ps=con.prepareStatement("Select * from Book"); ResultSet rs=ps.executeQuery(); w hile(rs.next()) {
System.out.println("ID="+rs.getInt(1)); System.out.println("Name="+rs.getString(2));
System.out.println("Author="+rs.getString(3)); }
} catch(Exception e) { System.out.println(e); } } public static void main(String args[]) { new conn(); } }

548 W hich object provides DatabaseMetaData object? 4 N U 2 Connection

549 W hich object provides ResultSetMetaData object? 4 N U 2 ResultSet

550 W hich object provides you w ith methods to access data from the table? 4 N U 2 ResultSet

551 W hich of the follow ing statement is a prepared statements ? 4 N A 2 Insert into department values(?,?,?)

552 W hich of the follow ing are the methods of statement interface? 4 N A 2 Both A &amp; B

553 W hich of the follow ing describes the correct sequence of the steps involved in making a connection w ith a d4 N A 2 1,3,4,2

554 W hich of the follow ing describes the correct url String format of getConnection() method. 4 N U 2 protocol,subprotocol,datasource na

555 W hich of the follow ing invokes stored procedures in sql? 4 N U 2 callable statements

556 W hich of the follow ing is correct sequence of steps regarding to establish the connection w ith database. 1. C4 N U 2 1,4,3,2

557 w hich of the follow ing is not true for Statement and PreparedStatment? 4 N U 2 None of above

558 W hich of the follow ing is the correct syntax of executeQuery() method? 4 N U 2 ResultSet executeQuery(String str)

559 W hich of the follow ing is true 4 N A 2 The tw o tiers are ofte

560 W hich of the follow ing is used to access the database server at time of executing the program and get the d 4 N U 2 Dynamic SQL

561 W hich of the follow ing method is supported by Statement interface? 4 N U 2 All of the mentioned

562 W hich of the follow ing method is used to open the connection w ith the database 4 N U 2 Connection con = DriverManager. ge

563 W hich of the follow ing piece of code show s how to retrieve the value of the Row Id for a particular Row ? 4 N U 2 String selectQuery =
564 W hich of the follow ing query is correct to fetch all thye records from database. Import java. Sql.*; class 4 N A 2 C. Stmt.executeQuery
MysqlCon{ public static void main (String args[]){ try { Class.forName ("com.mysql.jdbc. Driver");
Connection con = DriverManager. getConnection ("jdbc:mysql://localhost:3306/abc","root","root'');
Statement stmt = stmt = con. createStatement(); ResultSet rs =
______________________________________________________________ w hile (

rs.next()) System.out printIn(rs.getInt(1)+ " " + rs. getString (2) + "" + rs. getString(3));
con.close(); } catch (Exception e ) { System.out.println(e);} }}
565 W hich of the follow ing query is used for SELECT query? 4 N U 2 executeQuery(String sql)

566 W hich of the follow ing statement is false as far as different type of statements is concern in 4 N U 2 D)Interim Statement
JDBC.

567 W hich of the follow ing statement is false as Type 4 driver is concern: 4 N U 2 Type 4 drivers can not be used w ith

568 w hich of the follow ing statement is true in case security consideration for JDBC. A)normal unsigned applets 4 N A 2 all of the above

569 w hich of the follow ing statement is used to scroll databse forw ard and backw ard 4 N A 2 Statement si=con.createStatement(

570 W hich of the follow ing statement should be inserted to display contents of last record and w here that 4 N A 2 After line no 13 rs.las
statement should be inserted 1.import java.sql.*; 2.public class JDBCExample { 3. public static void
main(String[] args) { 4. Connection conn = null; 5. Statement stmt = null; 6.
Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver"); 7. System.out.println("Connecting to database..."); 8.conn
= DriverManager.getConnection(jdbc:odbc:stud”);
9.System.out.println("Creating table in given database..."); 10.System.out.println("Creating statement...");
11. stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
12.String sql = "SELECT id, age FROM Registration"; 13. ResultSet rs = stmt.executeQuery(sql); 14. int id
= rs.getInt("id"); 15. int age = rs.getInt("age"); 16. System.out.print("ID: " + id); 17. System.out.print(",
Age: " + age); } 18. rs.close(); 19. System.out.println("Goodbye!");}}

571 W hich of the follow ing statements are true about Tw o tier client server model. a)it is simple in design b)clie4 N U 2 a and b

572 W hich of the follow ing statements are true? 4 N U 2 A AND C

573 W hich of the follow ing statements is a true statement concerning the open database connectivity standard ( 4 N U 2 All of the above.

574 W hich of the follow ing statements is true concerning JDBC? 4 N U 2 It is similar concept to ODBC.

575 W hich of the follw ing method is used for sending SQL statements 4 N U 2 Statement

576 W hich of the missing code need to be inserted in a given code to delete second row in ResultSet. import 4 N A 2 rs.absolute(2); rs.dele
java.sql.*; import java.sql.ResultSet.*; class delrset {public static void main(String args[]) {try
{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con
=DriverManager.getConnection("jdbc:odbc:stud"); Statement s =
con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); ResultSet
rs=s.executeQuery("select * from stud"); w hile(rs.next()) System.out.println(rs.getInt(1)+"
"+rs.getString(2)+" "+rs.getInt(3)); System.out.println("After deleting row :"); rs.first();
System.out.println(rs.getInt(1)+" "+rs.getString(2)+"
"+rs.getInt(3)); w hile(rs.next()) {System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getInt(3)); }
con.close(); } catch(Exception e){ } } }

577 W hich ONE of the follow ing is missing statement in the program below ? import java.sql.*; class 4 N A 2 results.next()
ExecuteQueryTest { public static void main(String args[]) { try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); System.out.println("Driver loaded"); String
url="jdbc:odbc:aditya"; Connection con = DriverManager.getConnection(url);
System.out.println("connection to database created"); Statement st = con.createStatement();
System.out.println("Statement object created"); String sql="select Name,Age from tanni"; ResultSet
results = state.executeQuery(sql); String text=" "; w hile() { text
+=results.getString(1)+ "" +results .getInt (2)+ '\n'; } System.out.println(text); } catch(SQLException e)
{ System.out.println("SQL error"); } catch(Exception e) { System.out.println("error"); } } }

578 W hich one of the follow ing methods is used to execute INSERT, UPDATE, and DELETE 4 N U 2 executeUpdate()
statements in a Java application?

579 W hich statement create an error import java.sql.*; class data { public static void main(String a[]) throw s 4 N A 2 w hile creating Driver
Exception { Driver d= new Driver(); DriverManager.registerDriver(d); Connection con
=DriverManager.getConnection("Jdbc:Odbc:XXX"); Statement s=con.createStatement(); }
}
580 W hich statement is correct after firing delete statement of SQL? import java.sql.*; class DeleteD { public 4 N A 2 stmt.executeUpdate(q
static void main(String a[]) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Driver Loaded"); String url="jdbc:odbc:if"; Connection
con=DriverManager.getConnection(url); System.out.println(" Connection to DataBase created"); Statement
stmt = con.createStatement(); String querySel
= "Select * from student"; ResultSet rs = stmt.executeQuery(querySel); System.out.println("Before
Delete"); w hile(rs.next()) { System.out.println(" Roll number : "+ rs.getInt(1)); System.out.println("
Student Name : "+ rs.getString(2)); System.out.println(" Student Marks : "+ rs.getInt(3));
System.out.println(); } String querydel = "delete from student w here stud_name='Sanjay'";
__________________________________________ rs
= stmt.executeQuery(querySel); System.out.println("After Delete"); w hile(rs.next()) {
System.out.println(" Roll no : "+ rs.getInt(1)); System.out.println(" Student Name : "+ rs.getString(2));
System.out.println(" Student marks : "+ rs.getInt(3)); System.out.println(); }
} catch(SQLException e) { e.printStackTrace(); } catch(Exception e) { e.printStackTrace(); } }
}

581 W hich statement is correct in case of Type 1 JDBC driver a) Type I driver is slow driver. b)Type I Driver is no4 N U 2 all of above

582 W hich Statement is given the error in the follow ing code import java.sql.*; class dataI { public static void 4 N A 2 Sql Query Statement
main(String a[]) { try { Driver d= new sun.jdbc.odbc.JdbcOdbcDriver(); DriverManager.registerDriver(d);
Connection con
=DriverManager.getConnection("Jdbc:Odbc:xxx"); Statement s=con.createStatement();
s.executeUpdate("Insert into Table1 values('hhh',12)"); if(n==1) { System.out.println("Record inserted ");
con.close(); } } catch(Exception e) { System.out.println("not Inserted"+e); } } }

583 W hich statement is static and synchronized in JDBC API? 4 N U 2 getConnection()

584 W hich Statement is used to execute Dynamic Query 4 N U 2 PreparedStatement

585 W hich statement required for getting proper output import java.sql.*; public class updatevalues1 { public sta4 N A 2 ps.executeUpdate()

586 W hich statement should be correct for displaying the correct out put? import javax.sw ing.*; 4 N A 2 Import Package and c
import java.io.*; class dataM { public static void main(String a[]) { String type[]=
{“TABLE”,”View ”}; try { Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”); Connection con
=DriverManager.getConnection("Jdbc:Odbc:xxx"); Statement s=con.createStatement(); DatabaseMetaData
md=rs.getMetaData(); System.out.println("Database is:”+md.getDatabaseProductName() );
System.out.println("SQL Keyw ords is:”+md.getSQLKeyw ords()); ResultSet
rs=md.getTables(null,null,null,types); W hile(rs.next()) { String to=rs.getString(2); String
tn=rs.getString(3); String tt=rs.getString(4); System.out.println(to+” ”+tn+” ” +tt+” ”); } con.close(); }
catch() { System.out.println(e); } }
}

587 W hich statements about JDBC are true? 4 N A 2 JDBC stands for Java DataBase Conn

588 W hich statements are needed to establish connection to database? 4 N A 2 Class.forName(&quot;


c=DriverManager.getC
&quot;);

589 W hich statements are required in follow ing program to insert one record in table import java.sql.*; public 4 N A 2 String sql = &quot;IN
class JDBCExample { public static void main(String[] args) { Connection conn 18)&quot;; stmt.exec
= null; Statement stmt = null; Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Connecting to database..."); conn = DriverManager.getConnection(jdbc:odbc:stud”);
System.out.println("Inserting records into the table..."); stmt = conn.createStatement();
______________________________________________________
__________________________________________________________________
System.out.println("Inserted records into the table..."); System.out.println("Goodbye!"); }}

590 W hich statements are used to display the contents of table? import java.sql.*; public class jdbcResultSet { p 4 N A 2 getString,getInt meth
591 W hich statements are w rong in bellow program import java.sql.*; class stud5 { public static void main(Strin4 N A 2 Class.forName(&quot;
con=DriverManager.g

592 W hich type of driver converts JDBC calls into the netw ork protocol used by the database management syste 4 N U 2 Type 4 driver

593 W hich type of Statement can execute parameterized queries? 4 N U 2 PreparedStatement

594 w hile(rs.next()) { String n=rs.getString("name"); System.out.println("name:"+n); String n1=rs.getString("r 4 N A 2 D. none of the above

595 W rite a java code to access id, age, first from table given below Employees : l id l first l last l age l 4 N A 2 A. sql = &quot;SELEC

596 W rite the missing statement? import java.sql.*; class Rsmd{ public static void main(String args[]){ try{ 4 N A 2 ResultSetMetaData rs
Class.forName("oracle.jdbc.driver.OracleDriver"); Connection con=DriverManager.getConnection(
"jdbc:oracle:thin:@localhost:1521:xe","system","oracle"); PreparedStatement
ps=con.prepareStatement("select * from emp"); ResultSet rs=ps.executeQuery(); ----------------------------
----------------------- System.out.println("Total columns: "+rsmd.getColumnCount());
System.out.println("Column Name of 1st column: "+rsmd.getColumnName(1));
System.out.println("Column Type Name of 1st column: "+rsmd.getColumnTypeName(1)); con.close();
}catch(Exception e){ System.out.println(e);} }
}

597 W rite the missing statements? import java.sql.*; class InsertPrepared{ public static void main(String args[])4 N A 2 con.close();

System.out.println(i+" records inserted"); ------------------------------------- }catch(Exception e){ System.out

598 W rite w hich method is used for follow ing program execution in blank space: import java.sql.*; class exp11_4 N A 2 executeQuery()

599 ____type of driver is very flexible and need not code installation on the client machine 4 N U 2 Type 3-JDBC-Net Pure java

600 ______moves the cursor to the specified row 4 N A 2 public boolean absolute(int row )

601 ________ is an open source DBMS product that runs on UNIX, Linux and W indow s. 4 N U 2 MySQL

602 __________is the key to__________w ith respected to RDBMS? 4 N U 2 Serialization,persistence

603 ___________Calls get converted into native c or c++ API calls 4 N A 2 JDBC API

604 _______________ interface allow s stroing results of query? 4 N R 2 Resultset

605 ________________ method of Connection interface is used to create the Statement object. 4 N U 2 createStatement()

606 ________________ method of DriverManager is used to establish connection w ith the database. 4 N U 2 getConnection()

607 ____________________ Returns the current row number, w ith the first row starting at 1 4 N U 2 getRow ()

608 _______________________Returns a ResultSetMetaData object describing the ResultSet. 4 N U 2 getMetaData

609 …………………… can not directly communicate w ith database to submit data & retrive the result. 4 N U 2 JDBC

610 W hich of the follow ing statements loads the JDBC-ODBC driver? 4 N U 2 Class.forName(&quot;sun.jdbc.odbc.

C opyright © 2014 - 2015. All rights reserved.

22 CGI w as expensive in terms of ___________and _________to create 5 N R 1 Process,Memory, Resource


separate process for each client reqest
23 Choose correct scopes into JSP 5 N R 1 page,request,session,application

24 choose correct syntax of directive: 5 N R 1 &lt;%@ directive_name%&gt;

25 Cookie class consist __________________. 5 N R 1 name and value


Cookie is the piece of information w hich stores the session related
26 5 N R 1 username,passw ord,time,date
data like_______________.

27 Cookies can be deleted by using………………………….. Method. 5 N R 1 setMaxAge( )

28 Cookies sent from ______ to _________ 5 N R 1 Server,Client

29 Different methods used by cookie class are 5 N R 1 All of the above

30 During Initialization of Servlet, a servlet instance can throw ________. 5 N R 1 Both i) and ii)

31 Dynamic interception of requests and responses to transform the 5 N R 1 Servlet filter


information is done by

32 Filters w ere officially introduced in the 5 N R 1 2.3


Servlet_______________Specification.

33 Follow ing method is not valid life cycle method of JSP 5 N R 1 jspStop()

34 Generic Servlet belongs to___________________package of java. 5 N R 1 javax.servlet

35 GenericServlet implements the _______ and _______. 5 N R 1 Servlet, servletConfig

36 getCookies is method of w hich of the follow ing ? 5 N R 1 HttpServletRequest

37 getSession() method w ith true as parameter it w ill return the appropriate session object 5 N R 1 session is existing

38 getW riter() method can be called by --------------------object 5 N R 1 ServletResponse object

39 Give the examples of Application Server from the follow ing? 5 N R 1 All of the above

40 How can w e get context init parameter and run some code before rest of the application c5 N R 1 ServletContextListener

41 How does tomcat executes a JSP? 5 N R 1 By one of Tomcat's thread

42 How many character w e send though doGet()? 5 N R 1 1024

43 How many copies of a JSP page can be in memory at a time? 5 N R 1 one

44 How to send data in get method? 5 N R 1 through URL

45 HTTP servlet uses methods like__________________. 5 N R 1 doPost(),doGet()

46 HttpServlet is a subclass of ____________________. 5 N R 1 GenericServlet

47 Identify correct servlet interface 5 N R 1 Servlet

48 Identify correct syntax of service() method of servlet class 5 N R 1 void service(ServletRequest req, ServletResponse res)

49 If an expiration date is not explicitly assigred to a cookie __________ 5 N R 1 it is deleted w hen the current brow ser session ends

50 If you w ant to track active session or how many users are there? 5 N R 1 HttpSessionListener
w hich listener you should use.
51 in a w eb application, running in a w ebserver, w ho is responsible for 5 N R 1 Servlet
creating request and response object

52 In Http request method w hich is non-idempotent? 5 N R 1 POST method

53 In HTTP Request W hich Asks for the loopback of the request message, for testing or troub5 N R 1 TRACE

54 In JSP a Canvas object provides access to a Graphics object via one of its methd called___5 N R 1 paint()

55 In order to run JSP .................... is required. 5 N R 1 Java W eb Server

56 In response to HTTP Request servlet sends ______________ 5 N R 1 HTTP Response

57 In w hich file do w e define a servlet mapping? 5 N R 1 w eb.xml

58 In w hich of these getAttribute () and setAttribute() method is not defined? 5 N R 1 ServletConfig

59 In w hich phase of JSP life cycle ,JSP page turns into servlet? 5 N R 1 JSP Compilation
60 init() ,service(),destroy() methods are defined in ____________ 5 N R 1 javax.servlet.Servlet interface

61 Java servlets are an efficient and pow erful solution for creating ………….. for the w eb. 5 N R 1 Dynamic content

62 javax.servlet package does not contain follow ing class or interface. 5 N R 1 HttpServlet

63 JSDK stands for 5 N R 1 Java Servlet Development Kit

64 JSP basically used to ……………………… 5 N R 1 develop server pages

65 JSP containers are required to support ..................... different formats of JSP syntax 5 N R 1 Tw o

66 JSP embeds in ................ in ...................... 5 N R 1 Java, HTML

67 JSP implicit object associated w ith request is 5 N R 1 HttpServeletRequest

68 JSP includes a mechanism for defining ............................... or custom tags 5 N R 1 dynamic attributes

69 JSP is not governed by the syntax and semantics defined by the 5 N R 1 Java 2
................... specifications.

70 JSP is transformed into __________ 5 N R 1 Java Servlet

71 JSP page compiled and it turn in to________________ 5 N R 1 Servlet

72 JSP Start and end W ith the Symbol 5 N R 1 &lt;% %&gt;

JSP supports __________ implicit objects that JSP container makes


73 available to developers in each page. 5 N R 1 9

74 Life cycle of a JSP page consist of follow ing steps. 5 N R 1 Translation,compilation,Loading and initialization,Request H

75 Life cycle of the servlet is managed by 5 N R 1 servletContainer

76 Name a class that includes the getSession() method that is used to get the HttpSession 5 N R 1 HttpServletRequest

77 Name the class that can be used to get the cookies from the client brow ser 5 N R 1 HttpServletRequest

78 Name the http method that sends the same response as the request. 5 N R 1 TRACE method

79 Name the http method used to send resources to the server 5 N R 1 PUT method
Name the interface w hich is used to get initialization parameters for
80 5 N R 1 ServletConfig
Servlet

81 Name the location of compiled class files w ithin a jar file? 5 N R 1 /W EB-INF/classes

82 Name the method defined in the HttpServletResponse class that may 5 N R 1 setContentType
be used to set the content type.

83 On typing a URL on the address bar, w hich HTTP request gets generated? Select the one c5 N R 1 GET method

84 Parameters are present in URL w hile using__________method 5 N R 1 doGet()

85 Servlet are w ebpages generated by the w eb server In response to the requests send by t5 N R 1 client

86 Servlet is _______ side scripting language 5 N R 1 Server

87 Session management is possible using ___________________ 5 N R 1 All of the mentioned

State true or false for the follow ing statements in Java. i) Java beans
88 slow dow n softw are development process. ii) Java Servlets do not 5 N R 1 i-false, ii-false
have built in multithreading feature.

89 The doGet() Extracts values of the parameter type and number by using ___________ 5 N R 1 request.getParameter()

90 The GET and POST methods are specified in _________. 5 N R 1 an HTML form

91 The getSession() method w ith its parameter [getSession(true)]. It w ill return the approp 5 N R 1 the session is existing

92 The HTTPSErvlet class is defined in ___________ package 5 N R 1 javax.servlet.http

93 The HttpServlet class support ____________________________. 5 N R 1 All of the mentioned


94 The init parameter name and value pairs that are defined in w eb.xml file are handled by _5 N R 1 ServletConfig

The Java __________ specification defines an application programming


95 interface for communication betw een the W eb server and the 5 N R 1 Servlet
application program.

96 The javax.servlet.jsp package has tw o interfaces find in the follow ing? 5 N R 1 JspPage &amp; HttpJspPage

The JspPage interface defines the __________ and ____ method


97 w hich the page w riter can use in their pages and are invoked in much 5 N R 1 jspInit(), jspDestroy(), init() , destroy()
the same manner as the ____ and _____ methods of a servlet.

98 The lifecycle of Servlet is managed by______________ 5 N R 1 ServletContainer

99 The major difference betw een servlet and CGI is 5 N R 1 Servlets are thread based and CGI is process based

100 The maximum size of data can be sent by doGet() of HTTP request is 5 N R 1 240 bytes

101 The parameters can be passed to an applet by using <PARAM> tag in 5 N R 1 &lt;PARAMNAME=parameter_name VAL
the follow ing w ay:

102 The purpose of init () in servlet life cycle is 5 N R 1 initialization

The servlet can read its initialization arguments through the

103 ______________________________. 5 N R 1 ServletConfig object


104 The w hole life cycle of a servlet breaks up into 3 phases: 5 N R 1 Initialization, Service , Destroy
The _______ method is called w hen the servlet is first created, and is

105 5 N R 1 init
not called again as long as the servlet is not destroyed.

These methods doGet(),doPost(),doHead(),doDelete(),doTrace() are


106 5 N R 1 HttpServlet
used in?
The__________________package contains a number of interfaces
107 5 N R 1 javax.servet.http
and classes that are commanly used by servlet developers
This method is called once just before the servlet is unloaded and
108 5 N R 1 public void destroy()
taken out of service.
TLDs are used by a ___________________ to validate the tags and
109 5 N R 1 w eb container
by JSP page development tools

110 To compile a Java servlet program, the ___________ file must be in the classpath. 5 N R 1 TomcatRootDir\common\lib\servlet.jar

111 To get the servlet environment information 5 N R 1 ServletContext object is used

112 Tomcat is a _____________ 5 N R 1 W eb Server

113 w hat are mechanism avilable in servletContextListener interface? 5 N R 1 contextInitialized(),contextDestroyed()

114 W hat are the correct statements about filter? 5 N R 1 All of these

115 W hat are the true sentences about Session-Id? 5 N R 1 All of these

116 W hat is bytecode? 5 N R 1 Machine Independent code

W hat is difference betw een servlets and applet 1)Servlets executes on

server ,w here applet exexute on brow ser 2)Servlets have no


117 GUI,W here as Applet has GUI 3) Servlets create static w eb pages 5 N R 1 1,2 are correct
,w here as applet creates dyanamic pages 4)Servlets can handle only a
single request, w here as applet can handle multiple request

118 W hat is invoked via HTTP on the W eb server computer w hen it 5 N R 1 Java Servlet
responds to requests from a user's W eb brow ser?

119 W hat is return type of getSession( ) method? 5 N R 1 HttpSession

120 W hat is servlet? 5 N R 1 Servlets are small program used for developing and executi

121 W hat is the meaning of jar? 5 N R 1 java archived

122 W hat JSP Stands for______ 5 N R 1 Java server pages

123 W hat method is used to specify a container's layout in JSP? 5 N R 1 setLayout()

124 W hat programming language(s) or scripting language(s) does Java 5 N R 1 Java only
Server Pages (JSP) support?

125 W hat servlet processor w as developed by Apache Foundation and 5 N R 1 Apache Tomcat
Sun?

126 W hat value does readLine() returns w hen it has reached the end of a file in JSP? 5 N R 1 Null

127 W here the servlets run? 5 N R 1 on server side


128 W here the session data w ill store ? 5 N R 1 Session objects.
W hich method returns names of the request parameters as
129 5 N R 1 getParameterNames
Enumeration of String objects

130 W hich among the below is the class of javax.servlet package 5 N R 1 GenericServlet

131 W hich are true about tag libraries in w eb applications? 5 N R 1 all of the above

132 W hich attribute is mandory w hile creating cookie 5 N R 1 Value

133 W hich cookie it is valid for single session only; it is removed each time 5 N R 1 Non-persistent cookie
w hen user closes the brow ser?

134 W hich HTTP method gets invoked w hen a user clicks on a link? Select 5 N R 1 GET method
the one correct answ er

135 W hich http method send by brow ser that asks the server to get the page only? 5 N R 1 get

136 W hich interface declares life cycle method of servet? 5 N R 1 Servlet

137 W hich interface define a getSession() method? 5 N R 1 HttpServletRequest

138 W hich is interface of follow ing 5 N R 1 Servlet

139 W hich is least visibility scope for Javabean in JSP 5 N R 1 Page

140 W hich is not the method in servlet to handle http request 5 N R 1 doShow ()

141 W hich JSP tag is used to transfer processing to another JSP page ? 5 N R 1 &lt;jsp:forw ard&gt;

142 W hich life cycle method is used to process a client's request? 5 N R 1 service()

143 W hich method are central to life cycle of a servlet? 5 N R 1 init(), service() and destroy()

144 W hich method decides w hether doGet() or doPost() method to call? 5 N R 1 service

145 W hich method does not exist on HttpServlet class? 5 N R 1 init()

146 W hich method is called on every servlet request ? 5 N R 1 service()

147 W hich method is used in the servlet class, to retrieve the input values from HTML page? 5 N R 1 request.getParameter()

148 W hich method is used to end servlet lify cylce 5 N R 1 destroy

149 W hich method is used to extract cookies from a request? 5 N R 1 getCookies()

150 W hich method is used to specify before any lines that use the 5 N R 1 setContentType()
PrintW riter?

151 W hich method of HttpServletRequest is used to create a session? 5 N R 1 getSession()

152 W hich method of HttpServletResponse is used to redirect an HTTP 5 N R 1 sendRedirect()


request to another URL?

153 W hich method of the component class is used to set the position and size of a component5 N R 1 setBounds()

154 W hich methods are available in ServleContext interface? 5 N R 1 getAttribute(),getMimeType(String File),void Log(String s)

155 W hich metod allow s the client to send data of unlimited length to the 5 N R 1 doPost()
w eb pageserver a single time.
156 w hich of follow ing is not true for servlet? 5 N R 1 it is single threaded

157 W hich of the follow ing are class 5 N R 1 GenericServlet

158 W hich of the follow ing are examples of JSP directive. 5 N R 1 include
W hich of the follow ing are interface? 1.ServletContext 2.Servlet
159 5 N R 1 1,2
3.GenericServlet 4.HttpServlet

160 W hich of the follow ing are the session tracking techniques? 5 N R 1 URL rew riting, using session object, using cookies, using hi

161 W hich of the follow ing correctly represents the follow ing JSP 5 N R 1 &lt;jsp:expression&gt;x&lt;/jsp:express
statement. <%=x%>

162 W hich of the follow ing implicit objects is not available to a JSP page by 5 N R 1 context
default?

163 W hich of the follow ing is an approach for state maintenance in W eb 5 N R 1 All of the above.
applications?

164 W hich of the follow ing is legal JSP syntax to print the value of i. Select the one correct an5 N R 1 &lt;%int i = 1;%&gt;

165 W hich of the follow ing is not a server-side technology ? 5 N R 1 DHTML

166 W hich of the follow ing is used to redirect the response from a servlet 5 N R 1 response.sendRedirect()
to a JSP page?

167 W hich of the follow ing JSP variables are not available w ithin a JSP 5 N R 1 httpsession
expression. Select the one correct answ er.

168 W hich of the follow ing method does not exist in HttpServelet class? 5 N R 1 init

169 W hich of the follow ing method is used to destroy the session? 5 N R 1 destroy( )

W hich of the follow ing methods are main methods in life cycle of
170 servlet? 1.init() 2 .service() 3.destroy() 4.w ait() 5 N R 1 1,2 and 3

171 W hich of the follow ing packages are required to create servlets in 5 N R 1 javax.servlet, javax.servlet.http
java?

172 W hich of these is a protocol for breaking and sending packets to an address across a netw5 N R 1 TCIP/IP

173 W hich of these is not a method of GenericServlet? 5 N R 1 doGet

174 W hich of these method can be called multiple times in servlet's life 5 N R 1 service()
cycle?

175 W hich of these protocol uses service() method to process the request in servlet? 5 N R 1 HTTP

176 W hich packages represent interfaces and classes for servlet API? 5 N R 1 both a and b

177 W hich servlet processor w as developed by Apache Foundation and sun? 5 N R 1 Apache Tomcat

W hich statements about HttpSession objects are true? 1. A session

may become invalid due to inactivity. 2. A new session is created each


178 time a user makes a request. 3. A session may become invalid as a 5 N R 1 1,3,4 are correct
result of a specific call by a servlet. 4. Multiple requests made from the
same brow ser may have access to the same session object.
179 W hich tag is used to declare one or more variables or methods 5 N R 1 &lt;%!-----%&gt;

180 W hy JSP is basically used today? 5 N R 1 b) To develop server pages

181 _____ is the first phase of servlet lifer cycle 5 N R 1 initialization

182 _____ Method returns true if the server created the session and it has not yet been access5 N R 1 isNew ()

183 ______is a small piece of Information that is passed back & forth in 5 N R 1 Cookie
HTTP request & response

184 __________declares life cycle methods of servlet. 5 N R 1 Servlet

___________is a technology for developing w eb pages that supports


185 dynamic content w hich helps developer to insert java code in HTML 5 N R 1 JSP
pages by making use of special tages <% _________%>.

186 ____________ is used to read data from a client request. 5 N R 1 ServletRequest

187 ______________ method gives the current session 5 N R 1 getSession()

188 ______________ class provides functionality that makes it easy to handle requests and re5 N R 1 GenericServlet

189 ______________Defines page-dependent attributes, such as scripting language, error pag5 N R 1 &lt;%@ page ... %&gt;

190 ________________method execute at end of servlet life cycle. 5 N R 1 destroy()

191 ________________methos is secure. 5 N R 1 doPost()


192 …………………. Life cycle method handles all client request. 5 N R 1 service( )

import java.io.*; import javax.servlet.*; import javax.servlet.http.*;

public class HelloW orld extends HttpServlet { public void


doGet(_______________, ____________________) throw s

193 PrintW riter out = res.getW riter(); out.println("<HTML>"); out.println(" 5 N A 2 HttpServletRequest req &amp; HttpServletResponse res

<HEAD><TITLE>Hello W orld</TITLE></HEAD>"); out.println("


<BODY>"); out.println("<H1>Hello W orld</H1>"); out.println("</BODY>
</HTML>"); } } W hat are the parameters for doGet()?
Consider the follow ing program and identify the missing method name

****** if you w ant to implement HTTP POST. import java.io.*; import


javax.servlet.*; import javax.servlet.http.*; public class
ColorGetServlet extends HttpServlet { public void ******
194 (HttpServletRequest request, HttpServletResponse response) throw s 5 N A 2 doGet()
ServletException, IOException { String color =
request.getParameter("color"); response.setContentType("text/html");
PrintW riter pw = response.getW riter(); pw .println("<B>The selected
color is: "); pw .println(color); pw .close(); } }
In follow ing Java program fill statement show ing ******.Select any

one option from given options import java.io.*; import java.util.*;


import javax.servlet.*; public class PostParametersServlet extends
GenericServlet { public void service(ServletRequest request,
ServletResponse response) throw s ServletException, IOException { //
195 Get print w riter. PrintW riter pw = response.getW riter(); 3. SOFTW ARE 5 N A 2 request.getParameterName(pname)
DEVELOPMENT 4. USING JAV// Get enumeration of parameter names a)
Enumeration e = request.getParameterNames(); ; // Display parameter
names and values. w hile(e.hasMoreElements()) { String pname =

follow ing methods of the HttpServletRequest interface:


A servlet life cycle can be defined as the entire process from its
creation till the destruction. The follow ing are the paths follow ed by a 5 N A 2 All of above
servlet

</HEAD>"); out.println("<BODY>"); if (request.getParameter("name")==null) out.println

248 choose the classes of javax.servlet package 5 N U 2 ServletException GenericServlet

Choose the correct code that displays the output as show n in the figure

Figure:-

import java.io.*;import java.util.*;import javax.servlet.*;import

5 Y1 A 2 javax.servlet.http.*;public class DateServlet extends HttpServlet{public void doGet(HttpServletRequesEd

ServletException, IOException{HttpSession hs = request.getSession(true);resp

ServletException, IOException { 4.0\common


response.setContentType("text/html"); PrintW riter pw =
response.getW riter(); pw .println("<B>Hello!"); pw .close(); } }

Choose the missing statement in the given method syntax public void
doGet(HttpServletRequest request, HttpServletResponse response) 5 N A 2 IOException
throw s ____________

Choose the missing statements in follow ing code from given options. import java.io.*; im

consider below program and print message " hi h r u" . select proper

method. import java.io.*; import javax.servlet.*; import


javax.servlet.http.*; public class HelloW orld extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletRespons
private String message; public void init() throw s ServletException { 5 N A 2 throw s ServletException, IOException {
message = "hi h r u"; } public void doGet(HttpServletRequest request, response.setContentType(&quot;text/html&quo
HttpServletResponse response) throw s ServletException, IOException response.getW riter(); out.println(&quot;&lt;h1&gt;&amp;quo
{ response.setContentType("text/html"); PrintW riter out =
response.getW riter(); } public void destroy() { } }
261 program import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public 5 N A 2 service()
class Mathservlet extends HttpServlet { public void (HttpServletRequest request,
HttpServletResponse response) throw s ServletException, IOException {
response.setContentType("text/html"); PrintW riter out = response.getW riter();
out.println("<html><h1>Table Example</h1>"); out.println("<table border = 1>");
out.println("<tr><td> Number </td>
<td> Result <td></tr>"); for(int i=1;1<10;i++) { out.println("<tr>
<td>"+ i + "\t" + Math.pow (2,i) + "<td><tr>"); } out.println("</table>
</html>"); printw riter.close(); } }

262 Consider follow ing code. W hat should be correction done in program to get correct 5 N A 2 Error in if statement
output . import java.io.*; import javax.servlet.http.*; import javax.servlet.*; public
class SessionId extends HttpServlet { public
void doGet(HttpServletRequest req, HttpServletResponse res) throw s IOException,
ServletException { res.setContentType("text/html"); PrintW riter pw = res.getW riter();
if(s != null) { pw .println("Your session Id is : "); String sId = s.getId(); pw
.println(sId); } else { pw .println("Your session is not created yet"); } } }

263 Consider follow ing code.Fill _____________statement in follow ing code from option 5 N A 2 request.getParameter(&quot;cookieNa
given below import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public
class CookieExample extends HttpServlet { public void doGet(HttpServletRequest
request, HttpServletResponse response) throw s IOException, ServletException
{ response.setContentType("text/html"); PrintW riter out = response.getW riter();
Cookie[] cookies = request.getCookies(); for (int i = 0; i < cookies.length; i++) {
Cookie c = cookies[i]; String name = c.getName(); String value = c.getValue();
out.println(name + " = " +
value); } String name = ______________________ if (name != null && name.length()
> 0) { String value = request.getParameter("cookieValue"); Cookie c = new
Cookie(name, value); response.addCookie(c); } } }

264 Consider follow ing code.find syntax error in code import java.io.*; import java.util.*; 5 N A 2 error in the if statement
import javax.servlet.*; import javax.servlet.http.*; public class SessionExample extends
HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse
response) throw s IOException, ServletException {
response.setContentType("text/html"); PrintW riter out = response.getW riter();
HttpSession session = request.getSession(true); Date created = new
Date(session.getCreationTime()); Date accessed = new
Date(session.getLastAccessedTime()); out.println("ID " + session.getId());
out.println("Created: " + created); out.println("Last Accessed: " + accessed); String
dataName = request.getParameter("dataName"); if (dataName != null &&
dataName.length() > 0) String dataValue = request.getParameter("dataValue");
session.setAttribute(dataName, dataValue); } Enumeration e =
session.getAttributeNames(); w hile
(e.hasMoreElements()) { String name = (String)e.nextElement(); String value =
session.getAttribute(name).toString(); out.println(name + " = "
+ value); } } }

Consider follow ing code.Select proper html code to get correct output. import java.io.*; im &lt;html&gt; &lt;body&gt; &lt;form ac

Consider the follow ing code and find w hich statement has error. <%@ taglib
uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> <%@ taglib
uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <html>
<head><title>Using the JSTL functions</title></head> <body>
<h2>Using JSTL functions</h2> <c:set var="string" value="W elcome!
to the site of roseindia.net"/> The length of the String:

268 ${fn:lengthOf(string)}<br> Does the String contain "W elcome"? 5 N A 2 Both A and B
${fn:contains(string,"W elcome")} <br> Converting the String into
upper case using fn:toUpperCase(): ${fn:toUpperCase(string)}<br>
Converting the String into low er case using fn:toLow erCase():
${fn:toLow erCase(string)}<br> Making the substring of
"roseindia.net" : ${fn:substrings("roseindia.net", 0,9)} </body>
</html>

Consider the follow ing code. Select the missing statement in the given
code. import java.io.*; import javax.servlet.http.*; public class
CookieExample extends HttpServlet { public void doGet(
HttpServletRequest request, HttpServletResponse response) throw s
IOException, ServletException {
response.setContentType("text/html"); PrintW riter out =
= cookies[i]; String name = c.getName(); String value = c.getValue(); out.println(name +

270 Consider the follow ing code.Find missing satement import java.io.*; import 5 N A 2 doGet(request, response);
javax.servlet.*; import javax.servlet.http.*; public class RequestInfo extends
HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse
response) throw s IOException, ServletException {
response.setContentType("text/html"); PrintW riter out = response.getW riter();
out.println("<html>"); out.println("<body>"); out.println("<head>");
out.println("<title>Request Information Example</title>"); out.println("</head>");
out.println("<body>"); out.println("<h3>Request Information Example</h3>");
out.println("Method: " + request.getMethod()); out.println("Request URI: " +
request.getRequestURI()); out.println("Protocol: " + request.getProtocol());
out.println("PathInfo: " + request.getPathInfo()); out.println("Remote Address: " +
request.getRemoteAddr()); out.println("</body>"); out.println("
</html>"); } public void doPost(HttpServletRequest request, HttpServletResponse
response) throw s IOException, ServletException
{ doGet(request, response); } }

271 Consider the follow ing code.Find missing statement public class HelloForm extends 5 N A 2 import java.io.*; import javax.servlet.
HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse
response) throw s ServletException, IOException { Cookie firstName = new
Cookie("first_name", request.getParameter("first_name")); Cookie lastName = new
Cookie("last_name", request.getParameter("last_name"));
firstName.setMaxAge(60*60*24); lastName.setMaxAge(60*60*24);
response.addCookie( firstName ); response.addCookie( lastName );
response.setContentType("text/html"); PrintW riter out = response.getW riter(); String
title = "Setting Cookies Example"; String docType = "<!doctype html public \"-//w
3c//dtd html 4.0 " + "transitional//en\">\n"; out.println(docType + "<html>\n" +
"<head>
<title>" + title + "</title></head>\n" + "<body bgcolor=\"#f0f0f0\">\n" + "<h1
align=\"center\">" + title + "</h1>\n"
+ "<ul>\n" + " <li><b>First Name</b>: " + request.getParameter("first_name") +
"\n" + " <li><b>Last Name</b>: " + request.getParameter("last_name") + "\n" +
"</ul>\n"
+ "</body></html>"); } }

272 Consider the follow ing code.Select the missing statement to get proper output. import 5 N A 2 res.addCookie(c);
java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class CookEx
extends HttpServlet { public void doPost(HttpServletRequest req,HttpServletResponse
res)throw s IOException,ServletException { res.setContentType("text/html"); PrintW
riter out=res.getW riter(); String name=req.getParameter("name"); String
value=req.getParameter("age"); Cookie c=new Cookie(name,value); String
p1=c.getName(); String p2=c.getValue(); out.println("Name:"
+p1); out.println("Age:"+p2); out.println(" "); } }

Consider the follow ing code.W hat should be added to the program to get correct output..

273 import="java.lang.*"%> <html> <body> <H1><center>Result for 5 N A 2 %&gt;


<%=request.getParameter("a1")%></center></H1> <% int
i=Integer.parseInt(request.getParameter("t1")); int
j=Integer.parseInt(request.getParameter("t2")); int k=0; String
str=request.getParameter("a1"); if(str.equals("add")) k=i+j; if(str.equals("mul")) k=i*j;
if(str.equals("div")) k=i/j; Result is <%=k%>
</body> </html>
274 Consider the follow ing output . find the missing statement in the program import 5 Y1 U 2 import javax.servlet.http.*;
javax.servlet.*; public class EE extends HttpServlet { public void
doGet(HttpServletRequest request, HttpServletResponse response) throw s IOException,
ServletException { response.setContentType("image/gif"); File f= new File("C:/Program
Files/Apache Softw are Foundation/Tomcat5.5/w ebapps/servlets-
examples/images/first.gif"); byte[] a=new byte[(int)f.length()]; FileInputStream
is=new FileInputStream(f); is.read(a); OutputStream os= response.getOutputStream();
os.w rite(a); os.flush(); } }
Figure:-

275 Consider the follow ing program Select the statement that should be added to the program5 N A 2 responce.addCookie(cookie);

276 Consider the follow ing program Select the statement that should be added to the program5 N A 2 response.addCookie(c2);

out.println("</HTML>"); }

277 Consider the follow ing program and identify the class at bank space import java.io.*; imp5 N A 2 HttpServlet

278 Consider the follow ing program and identify the error statement. import java.io.*; import 5 N A 2 String e[]=request.getParameterName
279 Consider the follow ing program and identify the missing method attribute ***** if you 5 N A 2 post
w ant to implement HTTP POST. <html> <body>
<center> <form name="Form1" method=*****
action="http://localhost:8080/examples/servlet/ColorPostServlet">
<B>Color:</B> <select name="color" size="1"> <option value="Red">Red</option>
<option value="Green">Green</option>FTW ARE DEVELOPMENT USING JAVA
<option value="Blue">Blue</option> </select> <br><br> <input type=submit
value="Submit"> </form> </body> </html>

280 Consider the follow ing program and identify the missing method name 5 N A 2 doGet()
****** if you w ant to implement HTTP GET. import java.io.*; import javax.servlet.*;
import javax.servlet.http.*; public class ColorGetServlet extends HttpServlet { public
void ****** (HttpServletRequest request, HttpServletResponse response) throw s
ServletException, IOException { String color =
request.getParameter("color"); response.setContentType("text/html"); PrintW riter pw =
response.getW riter(); pw .println("<B>The selected color is: "); pw .println(color); pw
.close(); } }

281 Consider the follow ing program and identify the missing statement. class URLDemo { 5 N A 2 Missing package statement
public static void main(String args[]) throw s MalformedURLException { URL
netAddress= new URL("http://w w w .sun.com:/index.html");
System.out.println("Protocol
:"+netAddress.getProtocol()); System.out.println("Port
:"+netAddress.getPort()); System.out.println("Host
:"+netAddress.getHost()); System.out.println("File
:"+netAddress.getFile()); } }

282 Consider the follow ing program and identify the missing statement. import java.io.*; imp 5 N A 2 PrintW riter pw ;

Consider the follow ing program and identify the missing statement. public class Hellot ex

doGet(HttpServletRequest req, HttpServletResponse res) { String data= request.getParam

283 resp.setContentType(“text/html”); PrintW riter pw =res.getW riter(); 5 N A 2 Missing package statement


String name=req.getParameter(“name”); out.Println(“<HTML>”);
out.Println(“<HEAD><TITLE>Hello,”+name+</TITLE></HEAD>”);
out.Println(“<BODY>”); out.Println(“Hello,”+name);
out.Println(“</BODY></HTML>”); } }

Consider the follow ing program and identify the missing statement.

public class HelloW orld extends HttpServlet { private String message;


public void init() throw s ServletException { message = "Hello W orld"; }
public void doGet(HttpServletRequest request, HttpServletResponse
284 response) throw s ServletException, IOException { 5 N A 2 Missing package statement
response.setContentType("text/html"); PrintW riter out =
response.getW riter(); out.println("<h1>" + message + "</h1>"); }
public void destroy() { } }

288 name="mybean" property="*" /> <html> <head><title>Hello, User</title></head> 5 N A 2 Closing Table tag is missing
<body bgcolor="#ffffff" background="background.gif"> <%@ include
file="dukebanner.html"
%> <table border="0" w idth="700"> <tr> <td w idth="150"> </td>
<td w idth="550"> <h1>My name is Duke. W hat’s yours?</h1> </td>
</tr> <tr> <td w idth="150" </td> <td w idth="550"> <form method="get"> <input
type="text" name="username" size="25">
<br> <input type="submit" value="Submit"> <input type="reset" value="Reset">
</td> </tr> </form> <% if ( request.getParameter("username") != null ) { %> <%@
include file="response.jsp" %> <% } %> </body> </html>
289 Consider the follow ing program. W hat should be the correction done in the program to 5 N A 2 Missing }
get correct output? import java.io.*; import java.util.*; import javax.servlet.*; import
javax.servlet.http.*; public class DateServlet extends HttpServlet { public void
doGet(HttpServletRequest request,HttpServletResponse response) throw s
ServletException ,IOException { HttpSession hs=request.getSession(true);
response.setContentType("text/html"); PrintW riter pw =response.getW riter(); pw
.print("<B>"; Date date= (Date)hs.getAttribute("date"); if(date!=null) { pw .print("Last
access: "
+ date +"<br>"); } date=new Date(); hs.setAttribute("date", date);
pw .println("Current date:" + date); }

290 Consider the follow ing program. Identify the exception that might be throw n import java 5 N A 2 MalformedURLException

291 Consider the follow ing program. Identify the exception that might be throw n import java 5 N A 2 ServletException,IOException

292 Consider the follow ing program. Identify w hich statement contains error. import javax.se5 N A 2 Error in getParameter() method return

Consider the follow ing program. Fill the missing(*******) statement. import java.io.*; im

293 doGet(HttpServletRequest request,HttpServletResponse response)throw s ServletException5 N A 2 HttpSession hs = request.getSession(true);

294 Consider the follow ing program. Identify the missing statement import java.io.*; import j5 N A 2 import javax.servlet.http.*;
295 Consider the follow ing program. Identify the missing statement from the output. import ja5 N A 2 Port: -1

296 Consider the follow ing program. Identify the missing statement in the program. import 5 N A 2 response.getW riter();
java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class Exp extends
HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse
response) throw s ServletException, IOException {
response.setContentType("text/html;charset=UTF-8"); PrintW riter out
= ___________________ out.println("the server name:
"+request.getServerName()+"<br>"); out.println("the server port:
"+request.getServerPort()+"<br>"); out.println("the server protocol:
"+request.getProtocol()+"<br>"); out.println("the server scheme:
"+request.getScheme()+"<br>"); out.close(); } }

297 Consider the follow ing program. Identify the missing statement to get correct output. imp5 N A 2 response.addCookie(cookie);

298 Consider the follow ing program. Identify the missing w ord ****. 5 N A 2 localhost:8080
<html> <body> <center> <form name="Form1"
action="http://****/examples/servlet/ColorGetServlet"> <B>Color:
</B> <select name="color" size="1"> <option value="Red">Red</option> <option
value="Green">Green</option>

314 Fill in the missing statements import javax.servlet.*; import javax.servlet.http.*; import 5 N A 2 new Cookie(&quot;MyCookie&quot;, da
java.io.*; public class AddCookieServlet extends HttpServlet { public void
doPost(HttpServletRequest request, HttpServletResponse response) throw
sServletException, IOException { String data = request.getParameter("data"); Cookie
cookie = -----------
------------------- response.addCookie(cookie); response.setContentType("----------------
--l"); PrintW riter pw = response.getW riter(); pw .println("<B>MyCookie has been set
to"); pw .println(data); pw .close(); } }

315 Find correct output of follow ing code HTML FILE <html> <body> <form 5 N A 2 Firstly input username &amp; passw o
action=”pass1”> name:<input type=”text” name=”t1”> passw ord: page&quot;
<input type = “passw ord” name=”t2”> <input type=”submit” value=”login”> </form>
</body> </html> // Servlet file import java.io.*; import javax.servlet.*; public class
pass1 extends GenericServlet { public void service(ServletRequest req,ServletResponse
res)throw s ServletException, IOException { res.setContentType(“text/html”); PrintW
riter pw = res.getW riter();
String un=”abc”; String pw d=”xyz”; String p1=req.getParameter(“t1”); String
p2=req.getParameter(“t2”); if((p1.equals(un)) && (p2.equals(pw d))) { pw
.println(“<h1>w elcome to home page</h>”);
}else{ pw .println(“invalid”); } pw .close(); } }

316 Find error in follow ing code from given options. import java.io.*; import javax.servlet.*; i5 N A 2 Error in doPost() method
317 Find errors in follow ing code. import java.io.*; import javax.servlet.*; public class MyServ5 N A 2 Error in service() method declaration

318 Find out error in the follow ing program import javax.servlet.*; import javax.servlet.http.*5 N A 2 statement w here http servlet class is

319 Find out the error in the follow ing code. import java.io.*; import javax.servlet.*; public cl5 N A 2 Mismatch servlet

Find out the missing statement <html> <head> <title>Reading Cookies</title> </head>

null; // Get an array of Cookies associated w ith this domain if( cookies

320 != null ){ out.println("<h2> Found Cookies Name and Value</h2>"); 5 N A 2 cookies = request.getCookies();
for (int i = 0; i < cookies.length; i++){ cookie = cookies[i];
out.print("Name : " + cookie.getName( ) + ", "); out.print("Value: " + cookie.getValue(
)+" <br/>"); } }else{ out.println("<h2>No cookies founds</h2>"); } %> </body>
</html>

Find out the missing statement in follow ing program import java.io.*; import javax.servle

321 IOException, ServletException { rs.setContentType("text/html"); 5 N A 2 PrintW riter out = rs.getW riter();


out.println("<html>"); out.println("<body bgcolor=red>"); out.println("
<h1>Hello W orld!</h1>"); out.println("</body>"); out.println("
</html>"); } }

Find out the missing statement to get the correct output in bellow program import java.io.

322 if(count==null) { count=new Integer(1); } else count=new 5 N A 2 HttpSession ss=req.getSession();


Integer(count.intValue()+1); ss.setAttribute("tracker.count",count); w .println("<h1>Sess

323 Find the Syntactally Correct Statement 5 N A 2 public void doGet(HttpServletRequest re


throw s ServletException, IOException
Find the statement missing in the below code import java.io.*; import javax.servlet.*; pub

324 void doGet(HttpServletRequest request, HttpServletResponse 5 N U 2 both A and B


response) throw s ServletException, IOException { PrintW riter out =
response out.println("Hello W orld"); } }

Find the w rong statement in given program: import java.io.*; import javax.servlet.*; imp
Figure:-

325 5 Y1 A 2 response.getPrintW riter(); replace this statement w ith res


333 public class SessionExample1 extends HttpServlet { public void 5 N A 2 String id=session.getId();
doGet(HttpServletRequest request, HttpServletResponse response) throw s IOException,
ServletException { HttpSession session = request.getSession(true);
response.setContentType("text/html"); PrintW riter out = response.getW riter(); ---------
------------------------------
---- out.println("ID="+id); } }

334 For given figure w hich method of ReuestDispatcher is applicable 5 Y1 U 2 forw ard
(S1Q41) Figure:-

335 For the below html code: <input type="text" name="username”> The servlet code to retr 5 N U 2 String str=req.getParameter(&quot;us
HttpServletRequest object

336 For the follow ing code identify the correct syntax of service () method of servlet class. 5 N A 2 void service(ServletRequest req,Servle
import java.io.*; import javax.servlet.*; public class HelloServlet extends
GenericServlet { public void service(___________________)throw s ServletException,
IOException
{ response.setContentType("text/html"); PrintW riter pw =
response.getW riter(); pw .println("<B>Hello"); pw .close(); } }

337 For the follow ing code select the missing statement that can be used . import java.io.*; im
5 N A 2 String name=request.getParameter(&q

338 For the follow ing output, w hat is the html <form> tag code? Figure:- 5 Y1 A 2 &lt;FORM METHOD=&quot;GET&quot;

339 Generic servlet implements the _________&_______ interface. 5 N U 2 Servlet &amp; servlet config

340 getSessioin() is a method of __________ class. 5 N U 2 HttpServletRequest

341 getSession(true) method w ill return appropriate session object if…… 5 N U 2 the session is existing

342 getW riter method is accessed as ___________ 5 N U 2 response.getW riter()

Given a w eb application ShoopingCart w ith 2 files:

343 ShoppingCart/customer/ show Cart.jsp w hich of the follow ing code are 5 N A 2 request.getRequestDispatcher(&quot;/s

valid in addProductToCart.jsp to dispatch request to the show Cart.jsp?


Given an HttpServletRequest request and an httpServletResponse

response: 41. HttpSession session = null; 42. / / insert code here 43. if
344 (session = = null) { 44. / / do something if session does not exist 45. } 5 N U 2 session = request.getSession (false);
else { 46. / / do something if session exists 47. } To implement the
design intent, w hich statement must be inserted at line 42?
Given an HttpServletRequest request and HttpServletResponse

345 response, w hich sets a cookie "username" w ith the value "joe" in a 5 N U 2 response.addCookie(new Cookie(&quot;username&quot;, &q
servlet?

Given that resp is an HttpServletResponse, and no custom headers

exist in this response before this snippet executes:


346 resp.addHeader(“myHeader”, “foo”); resp.addHeader(“myHeader”, 5 N A 2 Compilation fails
“bar”); resp.setHeader(“myHeader”, “baz”); String [] s =
resp.getHeaders(“myHeader”); W hat is the value of s[0]?
Given the follow ing servlet mapping definition for the w eb application

named 'secureapp', <servlet> <servlet-


name>ProcessLoginData</servlet-name> <servlet-
347 class>DoLogin</servlet-class> </servlet> <servlet-mapping> <servlet- 5 N U 2 http://localhost:8080/secureapp/do/Login?name=&quot;bo
name>ProcessLoginData</servlet-name> <url-pattern>do/Login</url-
pattern> </servlet-mapping> w hich of the follow ing URLs w ill correctly
request the Servlet?

348 Given: <%-- insert code here --%> <html> <body> Today is: <%= new 5 N A 2 &lt;%@ page import='java.util.Date' %
Date() %> </body> </html> W hat needs to go on line 1?
Given: 1. public void service(ServletRequest request, 2.
349 ServletResponse response) { 3. ServletInputStream sis = 4. // insert 5 N A 2 request.getInputStream();
code here 5. } W hich retrieves the binary input stream on line 4 ?

350 How does Tomcat execute a JSP? 5 N U 2 By one of Tomcat's threads

How is the form data stored as a cookie on client machine? Pick out the

353 only in W indow s Operating System iv) allow s developers to customize 5 N U 2 i, ii &amp; iv are true

any java enabled server


Identfy the follow ing is/are true for JSP technology ? I. It is persistent.
354 5 N U 2 Both (I) &amp; (II)
II. Platform independent. III. Brow ser executes the code.

355 Identify correct syntax of addCookie() method 5 N U 2 void addCookie(Cookie cookie)

356 Identify correct syntax of doPost() method used in servlets. 5 N U 2 void doPost(HttpServletRequest req,HttpServletResponse re

357 Identify correct syntax of service() method of servlet class 5 N U 2 void service(ServletRequest req, ServletResponse res)

358 Identify method used by follow ing url 5 N A 2 get()


http://localhost:8080/examples/servlet/test.html?uid=xyz?pass=vvpp?

359 Identify proper syntax of doGet() 5 N U 2 void doGet(HttpRequest req, HttpRespo

360 Identify the correct sequence in Lifecycle of JSP 5 N U 2 Compile, Initialize, Execute, Destroy

Identify the correct sequence of Steps for creation and execution of

java and html file for servlet A) Create a directory structure under

361 5 N U 2 ABCDEF
import the B)Javax.servlet package and the javax.servlet.http package
in your source file. C)Compile your source code. D)Create a deployment
descriptor. E)Run Tomcat. F)Call your servlet from a w eb brow ser.

362 identify the correct signature of setContextLenght() method of 5 N U 2 void setContextLength(int size)
ServletResponse interface.

363 If you w ant to override a JSP file's initialization method, w ithin w hat 5 N A 2 &lt;%!%&gt;
type of tags must you declare the method?

364 If your servlet class file does not have a package statement, the 5 N A 2 TomcatRootDir\w ebapps\examples\W E
servlet .class file must be placed in ________ by default.
365 PrintW riter pw = response.getW riter(); pw .print("<B>"); Date date = 5 N A 2 Both A and B

(Date)hs.getAttribute("date"); if(date != null) { pw .print("Last access:


" + date + "<br>"); } Date = new Date(); hs.setAttribute("date",
date); pw .println("Current date: " + date); } } find the error in the
above code.
In a URL query string, the parameter name and value are associated
366 5 N U 2 =
using the ____ symbol.
<title>Form</title> </head> <body> <form method="get" 5 N A 2
Cookie(&quot;name&quot;, s); response.addCookie(c);
action="CServlet"> Enter your name : <input type="text"
name="myname"> <input type="submit" value="go"> </form>
</body> </html>
http://jenkov.com/somePage.html?param1=hello&m2=w orld Such line
5 N A 2 all of above
w ill be in brow ser address bar w hich statements are true
367 In follow ing Java code fill statement show ing ***.Select any one option from given optio5 N A 2 ServletException

368 In follow ing Java program fill statement show ing *** . Select any one option from given 5 N A 2 request.getSession(true);

369 In follow ing Java program fill statement show ing ******.Select any one option from give5 N A 2 request.getParameterNames();

370 In follow ing Java program fill statement show ing ***.Select any one option fro given opt5 N A 2 GenericServlet

371 In follow ing Java program fill statement show ing ***.Select any one option fro given 5 N A 2 HttpServlet
options import javax.servlet.*; import javax.servlet.http.*; public class
AddCookieServlet extends *********
{ public void doPost(HttpServletRequest request, HttpServletResponse response) throw
sServletException, IOException { String data = request.getParameter("data"); Cookie
cookie = new Cookie("MyCookie", data); response.addCookie(cookie);
response.setContentType("text/html"); PrintW riter pw = response.getW riter(); pw
.println("<B>MyCookie has been set to"); pw .println(data); pw .close(); } }

372 In follow ing Java program fill statement show ing ***.Select any one option fro given 5 N A 2 addCookie(cookie);
options import javax.servlet.*; import javax.servlet.http.*; public class
AddCookieServlet extends HttpServlet
{ public void doPost(HttpServletRequest request, HttpServletResponse response) throw
sServletException, IOException { String data = request.getParameter("data"); Cookie
cookie = new Cookie("My Cookie",data); response.*********;
response.setContentType("text/html"); PrintW riter pw = response.getW riter(); pw
.println("<B>MyCookie has been set to"); pw .println(data); pw .close(); } }

= new Cookie("MyCookie", data); response.addCookie(cookie); response.setContentType("


378 In follow ing Java program fill statement show ing ______.Select any one option from 5 N A 2 request
given options import javax.servlet.*; import javax.servlet.http.*; public class
AddCookieServlet extends HttpServlet
{ public void doPost(HttpServletRequest request, HttpServletResponse response) throw
sServletException, IOException { String data =
______.getParameter("data"); Cookie cookie = new Cookie("MyCookie,data);
response.addCookie(cookie); response.setContentType("text/html"); PrintW riter pw =
response.getW riter(); pw .println("<B>MyCookie has been set to"); pw .println(data);
pw .close(); } }

379 In follow ing Java program fill statement show ing __________. import java.io.*; import 5 N A 2 service
javax.servlet.*; public class HelloServlet extends GenericServlet { public void
__________(ServletRequest request,ServletResponse response) throw s
ServletException, IOException { response.setContentType("text/html"); PrintW riter out
= response.getW riter(); out.println("<h1> W elcome to Servlet</h1>"); }
}

380 In follow ing Java program w hich package is used public class HellosServlet extends 5 N A 2 import java.io.*; import javax.servlet.
HttpSevlet { public void doPost(HttptReuest request,httpResponse response) trow s
ServletException,IOException { string color=request.getParameter("color")
responce.setConteType("text/html"); PrintW riter pw =responce.getW riter(); pw
.println("<B>The selected color is:"); pw .println(color); pw .close(); } } <html>
<body> <form name="Form1" method="post"
action:""http://localhost:8080/examples/servlet/HelloServlet">
<B>Color:</B> <select name="color"size="1"> <option value="Red">Red</option>
</select> <br><br> <input type=submit value="submit"> </form> </body> </html>

381 In follow ing Java program w hich package needs to be imported for Enumeration? import 5 N A 2 import java.util.*;

382 In follow ing program fill statement show ing ***** Select any one option from given opti 5 N A 2 doGet

5 N A 2 Value of &quot;Name&quot; attribute


response.getW riter(); String n=request.getParameter("userName");

423 out.print("W elcome "+n); Cookie ck=new Cookie("uname",n); 5 N A 2 Run the servlet2
response.addCookie(ck); out.print("<form action='servlet'>");
out.print("<input type='submit' value='go'>"); out.print("</form>");
out.close(); }catch(Exception e){System.out.println(e);} } } Output w ill
have messgae W elcome w ith user name and go button. On click of Go
public class ServletX extends HttpServlet { public void

doGet(HttpServletRequest req, HttpServletResponse res) throw s


IOException, ServletException { req.getSession().setAttribute(“key”,
new X()); req.getSession().setAttribute(“key”, new X());
req.getSession().setAttribute(“key”, “x”);
424 req.getSession().removeAttribute(“key”); } } and given a listener 5 N A 2 BBUBUB
public class X implements HttpSessionBindingListener { public void
valueBound(HttpSessionBindingEvent event) { System.out.print(“B”); }
public void valueUnbound(HttpSessionBindingEvent event) {
System.out.print(“UB”); } } W hich logging output w ould be generated
by an invocation of the doGet method?

javax.servlet.*; import javax.servlet.http.*; public class


SessionIdServlet extends HttpServlet { protected void

431 doGet(HttpServletRequest request, HttpServletResponse response) 5 N A 2 missing semicolon,missing }


throw s ServletException,IOException {
response.setContentType("text/html"); printW riter pw =response.getW riter();
HttpSession session=request.getSession(); String id=session.getId(); pw
.println("Session Id is:"+ id) }

Select the missing code to print sevletconfig object initialization parameter in the follow in

439 Select the valid program w hich show s all life cycle methods of 5 N A 2 GenericServlet { public void init() { // i
GenericServlet.

IOException,ServletException { // actual service is provided


destroy(){ }

440 Seperation of business logic from JSP this is the advantage of? 5 N A 2 Custom Tags in JSP

441 service mthod of servelet is use 5 N U 2 to send request and to get response

442 Servlet Life Cycle have _____________________ state. 5 N U 2 5

443 Servlet offer follow ing advantage over CGI 5 N U 2 CGI is not platform independent but servlet are platform ind

ServletContext is 1. an Interface 2.A container w hich is used to store

an object so that it is available for w hole application 3.A container


444 w hich is used to store an object so that it is available for session only. 5 N U 2 1,2
4.A container w hich is used to store an object so that it is available for
request only.

445 Servlets becomes thread safe by implementing the javax. Sevlet. Sigle 5 N U 2 as every request is handled by separate
ThreadModelinterface ___________

446 Servlets only needs be loaded once, w hile CGI programs needs to be load for every reque5 N U 2 True

447 Servlets play important role in MVC Architecture as ------------- 5 N A 2 Controller

State true or false for the follow ing statements in Java i) Java beans

448 slow dow n softw are development process. Ii) Java servlets do not 5 N U 2 i-false,ii-false
have built in multithreading feature.

449 Steps in JSP Page execution 5 N U 2 1. Compilation 2. Initialization 3. Execution 4. Cleanup

450 Suppose the servlet class named Test does not have the package statement, by default, y 5 N A 2 http://localhost:8080/examples/servlet

451 Suppose the tw o parameters in the doGet or doPost method are request and response. 5 N A 2 You have to use request.getCookies() to
To retrieve a cookie from a client, use
____________.
Suppose the tw o parameters in the doGet or doPost method are

452 request and response. To specify HTML content type sent to the client, 5 N U 2 response.setContentType(&quot;text/html&quot;)
invoke ___________.

453 Suppose you w ant to know each time request comes in, so that you can log it. W hich list5 N U 2 ServletRequestListener

454 Syntax of Scriptlet Element 5 N U 2 &lt;% code %&gt;

455 Task performed by filter is 5 N U 2 All the above

456 The authentication mechanism in the servlet specification uses a technique called? 5 N A 2 Role Based Authentication

457 The correct sequence of JSP life Cycle is 5 N U 2 init(), Service(), destroy()

458 The difference betw een servelets and JSP is the 5 N U 2 Syntax

459 The doGet() method extract values of the parameters type and number by using_____. 5 N U 2 request.getParameter()

460 The follow ing method of HttpServlet is invoked in response to HTTP 5 N U 2 doPost()
POST request.
461 The follow ing methods belongs to the life cycle methods of the servlet. 5 N U 2 All Of Above
The follow ing program contains tw o errors. Identify them from the follow ing- import
java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class SessionDemo
extends GenericServlet
{ public void doGet(HttpServletRequest request, HttpServletResponse

are handled by.


The Java __________ specification defines an application programming

interface for communication betw een the W eb server and the 5 N A 2 Servlet
application program.

The life cycle of a servlet is managed by______________- 5 N U 2 servlet container


</HTML></BODY>"); out.close(); } }

W hat happens after execution of follow ing code import java.io.*;

import javax.servlet.*; import javax.servlet.http.*; public class


sessionDemo extends HttpServlet { private static final long
serialVersionUID = 1L; protected void doGet(HttpServletRequest
request, HttpServletResponse response) throw s ServletException,
IOException { response.setContentType("text/html"); PrintW riter
pw =response.getW riter(); HttpSession
session=request.getSession(true); Integer count= 5 N A 2 Successfully run and display visited page count , session ID.
(Integer)session.getValue("tracker.count"); if(count==null) count=new
Integer(1); else count= new Integer(count.intValue()+1);
session.putValue("tracker.count",count); pw .println("<HTML><BODY>
<H2>SESSION TRACKING DEMO</H2>"); pw .println("You Have Visited
This Page: "+count+"times"); pw .println("Session ID is
:"+session.getId()); pw .println("</HTML></BODY>"); } }

response.setContentType("text/html"); PrintW riter pw =


response.getW riter(); pw .println("<B>Hello!"); pw .close(); } }

499 W hat is meaning of jar 5 N U 2 java archived

W hat is ouput of program? import java.io.*; import java.util.Date;

import java.util.Hashtable; import javax.servlet.*; import


javax.servlet.http.*; public class DateServlet extends HttpServlet {
public void service(HttpServletRequest req, HttpServletResponse res)
500 throw s ServletException, IOException { Date today = new Date(); 5 N A 2 date w ill be displayed
res.setContentType("text/plain"); ServletOutputStream out =
res.getOutputStream(); out.println(today.toString()); } public String
getServletInfo() { return "Returns a string representation of the
current time"; } }
W hat is Output of follow ing program //client <html> <head></head>

<body><form name =sd


action="http://127.0.0.1:8080/examples/servlet/sd1"> Name: <input
type=text name="name1"value=""> <input type ="submit"
value="login"> </form> </body> </html> //servlet import java.io.*;
501 import java.net.*; import javax.servlet.*; import javax.servlet.http.*; 5 N A 2 Hello name inputed in text box
public class sd1 extends HttpServlet { public void
service(HttpServletRequest rq,HttpServletResponse rs)throw s
ServletException,IOException { rs.setContentType("text/html");
PrintW riter out=rs.getW riter(); String nm=
(String)rq.getParameter("name1"); out.println("Hello "+nm); } }

502 W hat is Servlet Jobs ? 5 N U 2 All The Above

503 W hat is the difference betw een cookies and Httpsession? 5 N U 2 Cookies w orks at clientside w hereas HttpSession w orks at

504 W hat is the difference betw een GenericServlet and HttpServlet? 5 N U 2 all of the above

W hat is the diffrence betw een servlet and applet? 1. Servlet execute

on server, w here as applet execute on brow ser. 2. Servlet have no


505 GUI, w here as applet has GUI. 3. Servelet create static w eb page 5 N A 2 1,2 are correct
w here as applet create dynamic w eb pages. 4. Servelet can handle
only one request w here as applet can handle multiple request.

PrintW riter p = res.getW riter(); p.println("<HTML>"); p.println("<HEAD> HELLO </HEAD


518 w hat w ill be the correct output follow ing program. import java.io.*; import 5 N A 2 Hello message is printed w ith bold sty
javax.servlet.*; public class H extends GenericServlet { public void
service(ServletRequest req, ServletResponse res)throw s ServletException, IOException
{ res.setContentType("text/html"); PrintW riter pw = res.getW riter(); pw
.println("<B>Hello!!"); pw .close();
}}

519 w hat w ill be the correct output of the follow ing program? import java.io.*; import 5 N A 2 Hello message is printed w ith H1 style
javax.servlet.*; public class H extends GenericServlet
{ public void service(ServletRequest req, ServletResponse res)throw s ServletException,
IOException { res.setContentType("text/html"); PrintW riter pw = res.getW riter(); pw
.println("<H1>Hello!!"); pw .close(); } }

520 w hat w ill be the final output after Enter the valute for First & Second and also click on 5 Y3 U 2 o1
Clac Button? import javax.servlet.*; import javax.servlet.http.*; import java.io.PrintW
riter; import java.io.IOException; public class calcServlet extends HttpServlet { public
void doGet(HttpServletRequest req,HttpServletResponse res)throw s
ServletException,IOException { PrintW riter pw =res.getW riter();
res.setContentType("text/html"); pw .println("
<html><head><title>CALCULATOR</title></head>"); pw .println("
<body>"); pw .println("<form method=post action=calcServlet>");
pw .println("Enter first No.:"); pw .println("<input type=text name=nm>
<br>"); pw .println("Enter Second No.:"); pw .println("<input type=text name=r>");
pw .println("<input type=submit value=calc>"); pw .println("
</form></body></html>"); pw .close(); } public void doPost(HttpServletRequest
req,HttpServletResponse res)throw s ServletException,IOException { String
a=req.getParameter("nm"); String b=req.getParameter("r"); int c=Integer.parseInt(a);
int d=Integer.parseInt(b); int e=c+d; int f=c-d; int g=c*d; PrintW riter pw =res.getW
riter(); res.setContentType("text/html"); pw .println("
<html><head><title>CALCULATOR</title></head>"); pw .println("
<body>"); pw .println(a+"+"+b+"="+e+"<br>"); pw .println(a+"-
"+b+"="+f+"<br>"); pw .println(a+"*"+b+"="+g+"<br>"); int h=c/d; pw
.println(a+"/"+b+"="+b+"<br>"); pw .println("</body></html>"); pw .close(); }
public void destroy() {} }
Figure:-

<0.5)%> hello <%=} else { %> hi <%}%>


W hat w ill be the ouput of the follow ing code. import javax.servlet.*;

public class HelloServlet extends GenericServlet { public void


522 service(ServletRequest req,ServletResponse res)throw s 5 N A 2 display Hello Servlet w ith bold style
ServletException,IOException { res.setContentType("text/html");
pw .println("<b>Hello Servlet</b>"); pw .close(); } }
W hat w ill be the outpt of the Program import java.io.*; import

java.util.*; import javax.servlet.*; import javax.servlet.http.*; public


class session1 extends HttpServlet { public void
doGet(HttpServletRequest request, HttpServletResponse response)

523 request.getSession(true); response.setContentType("text/html"); 5 N A 2 Display the Last Session Date and the Current Date

PrintW riter pw = response.getW riter(); pw .print("<B>"); Date date =


(Date)hs.getAttribute("date"); if(date != null) { pw .print("Last access:
" + date + "<br>"); } date = new Date(); hs.setAttribute("date",
date); pw .println("Current date: " + date); } }
W hat w ill be the output of follow ing program. public class DemoServlet

extends HttpServlet { public void doGet(HttpServletRequest request,


HttpServletResponse response) throw s ServletException, IOException

524 out.println("<HEAD>"); out.println("<TITLE>Servlet Page</TITLE>"); 5 N A 2 W elcome to the Servlet W orld

out.println("</HEAD>"); out.println("<BODY>"); out.println("W elcome


to the Servlet W orld"); out.println("</BODY>"); out.println("</HTML>");
}}

525 W hat w ill be the output of the follow ing code snippet? <% int a=5; %> 5 N A 2 a = 15 :: 10
<%! int a=10; %> a = <%=a + this.a%> :: <%= this.a%>
526 static w eb pages, w here as Applets creates dynamic w eb pages 5 N U 2 1,2 are correct

4.Servlets can handle only a single request, w here as Applet can


handle multiple requests

527 W hen to use doPost Method? 5 N U 2 all of the above

528 W hen using HTML forms w hich of the folow ing is true for POST method 5 N U 2 POST method sends data in the body of the request

529 W hich Action element Includes file at time the page is requested in JSP. 5 N A 2 jsp:include

530 W hich among the below is not a method of Servlet Interface 5 N U 2 All are methods above are of Servlet Interface

531 W hich are the methods of servlet life cycle? 5 N A 2 b)init(),service(),destroy()

532 W hich are useful methods w hich you can use w hile manipulating cookies in servlet? 5 N A 2 All of above

533 W hich authentication mechanism employs a base64 encoding scheme to protect user pass5 N A 2 HTTP Basic Authentication

534 W hich class provides stream to read binary data such as image etc. from the request obje5 N U 2 ServltInputStream

535 W hich classes are present in javax.servlet.http package? 5 N U 2 HttpServlet Cookie


W hich Content Type used in follow ing Program? import

javax.servlet.http.*; import javax.servlet.ServletException; import


java.io.PrintW riter; import java.io.IOException; public class
ServiceServlet extends HttpServlet { public void
service(HttpServletRequest request,HttpServletResponse
response)throw s ServletException,IOException {
response.setContentType("text/plain"); PrintW riter
out=response.getW riter(); if(request.getMethod().equals("GET")) {
out.println("Request handeled by the service() method"); } else {
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
out.println("Method not supported by this servlet"); } out.close(); } }
Figure:- 5 Y1 A 2 text/plain

537 W hich coockie name w as incorrect 5 N U 2 &quot;[email protected]&quot;

538 W hich cookie it is valid for single session only; it is removed each time 5 N U 2 Non-persistent
w hen user closes the brow ser?

539 W hich file w ill start tomcat Server? 5 N U 2 startup.bat

W hich import statement required for follow ing program. public class

servlet extends GenericServlet { public void service(ServletRequest

540 5 N A 2 import java.io.*; import javax.servlet.*;


IOException { response.setContentType("text/html"); PrintW riter
printw riter = response.getW riter(); printw riter.println("<B>Hello from
Java!</B>"); printw riter.close(); } }
HttpServletRequest ,HttpServletResponse ,HttpSession,
541 W hich interfaces contained by Servlet 5 N A 2
HttpSessionBindingListener

542 W hich is least visibility scope for java beans In JSP 5 N U 2 Page

543 w hich is not the methods of GenericServlet class 5 N U 2 getSession()

544 W hich is the Microsoft solution for providing dynamic W eb content? 5 N A 2 ASP

W hich is the missing statement in follow ing code to get proper output:

import java.io.*; import java.util.*; public class HelloW orld extends


HttpServlet { public void doGet(HttpServletRequest request,
HttpServletResponse response) throw s IOException, ServletException

545 5 N A 2 Missing Package Statement


response.getW riter(); HttpSession hp=request.getSession(true); Date
create=new Date(hp.getCreationTime()); Date access=new Date(hp.getLastAccessedTime

546 W hich JDBC driver types can be used in either applet or servlet code 5 N U 2 type 3 and 4

547 W hich JSTL code snippet can be used to perform URL rew riting? 5 N A 2 &lt;a href='&lt;c:url value=&quot;foo.jsp&quot;/&gt;' /&gt;

548 W hich mechanism is included by jsp for defining custom tags? 5 N U 2 dynamic attributes

549 W hich method is called by the servlet container to allow the servlet to respond to a reque5 N U 2 service()

550 W hich method is used to get HttpSession object and it belongs to w hich object? 5 N U 2 getSession method and HttpServletRequ

551 W hich method of the request object is used to extract values of the input fields in a form 5 N A 2 getParameter()

552 W hich method of the servlet is/are called several times in its life? 5 N U 2 doPost()

553 W hich method returns a servletConfig object that contains any initialization parameters? 5 N U 2 servletConfig getServletConfig()

554 W hich method returns the current session associated w ith this request, or if the request 5 N A 2 getSession()

556 Http request 5 N U 2 getParameterNames() and getParamete

W hich minimum packages are required to execute this Program? public

class RequestHeaderExample extends HttpServlet { public void


doGet(HttpServletRequest request, HttpServletResponse response)
throw s IOException, ServletException {
557 response.setContentType("text/html"); PrintW riter out = 5 N A 2
java.util.*;
response.getW riter(); Enumeration e = request.getHeaderNames();
w hile (e.hasMoreElements()) { String name = (String)e.nextElement();
String value = request.getHeader(name); out.println(name + " = " +
value); } }
W hich of the follow ing allow s substitution of code to occur at the
558 5 N A 2 &lt;@ include&gt; directive
translation time in a JSP page?

559 W hich of the follow ing are examples of JSP directive. 5 N U 2 include

560 W hich of the follow ing are the session tracking techniques? 5 N A 2 URL rew riting,using session object,using cookies,using hidd
5 Y1 A 2 request.getMethod().equals(&quot;GET&quot;)
579 i=Integer.parseInt(request.getParameter("t1")); int 5 N A 2 request.getParameter(&quot;a1&quot;);
j=Integer.parseInt(request.getParameter("t2")); int k=0; String str=****** ; if(str.equal

W hich statements should be w ritten in the place of dotted lines to display output "Hello W

585 import java.io.*; public class ServletDemo extends GenericServlet { 5 N A 2 PrintW riter pw =response.getW riter(); pw .println(&quot;H
public void service(ServletRequest request,ServletResponse response)
{ try { ................................ ................................ } catch(Exception e) {
System.out.println(e); } } }

W hich statemnet of servlet counts and displays the number of times it has been accessed

Figure:-

Your w eb page includes a Java SE v1.5 applet w ith the follow ing declaration: <object cla

595 ABCDEFFEDCBA' w idth='200' height='200'> <param name='code' 5 N U 2 Get


value='Applet.class' /> </object> W hich HTTP method is used to
retrieve the applet code?

596 __________ uses doGet(),doPost(),doHead,doDelete(),deTrace(). 5 N U 2 HttpServlet

___________this packege responssible for follow ing code Date date =

597 (Date)hs.getAttribute("date"); if(date != null) { pw .print("Last access: 5 N A 2 Import java.util.*; package


" + date + "<br>"); } date = new Date();

598 _____________ method of the request object is used to extract values of the input fields 5 N U 2 getParameter()
599 ______________ are JSP code fragments embedded w ithin <% ...%> 5 N A 2 Scriptlets
tags.

600 ____________________ method is used to Return the value of the 5 N U 2 getParameterName(pname)


Parameter named pname

601 …………...is first phase of servlet life cycle. 5 N U 2 intitialization

602 Apache Tomcat is a ________. 5 N U 2 W eb server that is capable of running Java programs.
heck boxes, Choice lists.
BorderLayout(3,4);

x objects w ith a CheckboxGroup

fontstyle,int pointsize)
t, String boxName)
ardlayout(int hor, int ver) //second

quot;);

pear on the button

eft, int w idth, int height)


s allow users to interact w ith applicat ion

umns of text.

multiple lines of text

the JDialog.

of text in label in terms of pixel


nt y,int w idth,int height)

idth, int new Height)

00 height = 100&gt;& lt;/applet&gt;

boolean selected, CheckboxGroup gr oup)

ate a process w here as Sw ing Compon ent create a thread


, Object colHeads[])

n I, Boolean State)
ean multipleSelect)
w ing() { JLabel l1 = ne w JLabel(&quot;User
quot;Passw ord&quot ;); JTextField t1 = new ew
ield(); JButton b1 = n

ow s and columns of data.

ated

eated

nd b.
created

ow s and columns of data.


r to the component.

can be added to the top of a top-level w indow

*; /*&lt;applet code=&quot;Depublic class Demo


Bar(); setMenuBar(mbr); ew ”);
MenuItem i2=new
eckboxMenuItem i4=new
2); m.add(i3); m.add(i4);
me text &quot;Java& quot;
aultMutableTreeNod e (&quot;Third Year

eated

ject
is invoked

p i.e. JRadioButtonG roup

er class
w Label(&quot;tw o& quot;); b1=new
s Frame { Button b; GridLayoutDemo3() { setLayout(new
String.valueOf(i))); }
ow s Exception { new

va
ageIcon(“India.gif”); JButton Jb= new JButton(“ok”,ii);
*;public class Demo e b1,b2; xtends JApplet{ JButton
Container c=g etContentPane(); Red&quot;,
ew JCheckBox(&quot; true);
false); b1=new

;c.add(cb2);c.add(b1 );c.add(b2);} }

ckboxGroup
mo extends Frame { mbr = MenuDemo() { MenuBar
u f = new Men Menu e = new u(&quot;File&quot;);
Menu MenuItem f1=new (&quot;View &quot;);
x MenuItem f2=new
true); f.add(f1); f.ad d(f2); mbr.add(f);
void main(String args []) { MenuDemo m = new
Size(400,400); } }
ge java.aw t

oButton(&quot;Indian &quot;); b2= new


b3= new JRadioButto n(&quot;German&quot;);

el,fig(d)-List,fig(e)-Ch eckBoxGroup,fig(f)-
o row s and three col vertical umns w ith horizontal and

orderLayout placing b east,w utton on

w o layouts: Border la yout and Flow Layout.

w o labels and tw o te xtfields


is created
h any layout manage r

/*&lt;applet code=& w quot;Flow Test.class&quot; w


;*/ public class Flo public Test extends Applet { or(int
out()); Default f add(new i=1; i&lt;6; i++) {
}

rderLayout.SOUTH);

; public class choice1 void 1 extends Applet { public


(&quot;w nn18& xp&quot;); quot;); os.add(&quot;w nn
quot;w in 2000&quot;); add(os); }
ot; height=200 w idt h=300&gt;

port java.aw t.event.*; import javax.sw ing.*; import

; public class Sample void extends Applet { public eckbox


kboxGroup(); Ch red=new
Checkbox green=ne ww
; Checkbox blue=ne n); add(blue); }}
add(red); add(gree
oxMenuItem(&quot; Bold&quot;);
oxMenuItem(&quot;I talic&quot;);
boxMenuItem(&quot ;Underline&quot;);
boxMenuItem(&quot ;Stikethrough&quot;);

; /*&lt;applet code= w &quot;Demo&quot;


;*/ public class De void init() mo extends Applet { public
mber:&qu TextField(12); ot;); TextField jtf1=new

view er combodemo1 1.java


addTab() to Add a ta b to the pane 3.Repeat
Pane to the conte

e platform independent.

nd displays the string “YES” on it.

,true) Companies=new List(4,false)


ut focus can not be directed to anoth er w indow

ew BorderLayout())

nt height,int w idth)
kground(Color.RED); N);
kground(Color.GREE ;
kground(Color.BLUE)

N, 48)
yout

&quot;, Font.BOLD,24);
Constants related to s crollbars
tem

,JTextArea
olumns

ate change in proce ssing.

at presents a hierarchical view of data


l halt until another ob notifyAll(ject sends a notify() or
a set of components of linking them w ith tabs.

mponent in a rectangular area

public void itemStat l.setText(&eChanged(ItemEvent ie) {


} }); } public static void
w idth 50, w ith a cent at an angre point of 45,90 starting lockw is

e w orking of Application

new FileInputStream(&quot;in.dat&q uot;);


ar.VERTICAL,0, 1, 0, 100); Scrollbar horz = new
, 100);

uot;,Font.ITALIC,14) ; setFont(f); //setting the


;

; public class LayDem public o extends Applet {


on (&quot;OK &quot;); Button w
Flow Layout f=ne
etLayout(f); add(
0,30)

GHT)

inherited from the ja class vax.sw ing.AbstractButton

200 height = 100&gt ;


], Object colHeads[ ])

ne object, Add the t ree to the scrollpane and


of the applet.
t;);

();
ends Frame { public s argv[]) tatic void main(String
etLayout(new Flow ton(&quot;Hello&quot;);
elloBut=new But Button ); add(ByeBut);
; add(HelloBut

n
nswer

utton , List ,MenuItem

mpty implementation of all metho ds of a listener

etSource() and toString()

sing getActionCommand( ) metho d.


sing removeTypeListener( ) meth od.

va.aw t package;

l mentioned above

emStateChanged()

ouseMotionListener

ouseMotionListener

ventObject(Object src)

hen there is changes in text occu rs

EXT_VALUE_CHANGED

ctionEvent,TextEvent

extEvent(Object source, int event _type)

ction Event,FocusEvent ,Containe r Event

xtChanged(TextEvent obj)

l of the mentioned

etActionCommand()

OUSE_W HEELMOVE

ublic void mouseClicked(MouseEv ent e)

oid mouseDragged(MouseEvent me)

ublic void addActionListener(Actio nListener l)


emListener,ActionListener

eceiving and processing events

listener is a object that is notifie d w hen an event occurs.

listener is an object that notified w hen event had occurred.

n event is an object that describe s a state change in a source.

oid focusGained(FocusEvent fe)

o determine w hic h listener w ill be invoked first.

ance model is m deleore efficient than the event -

daptor classes reduce Complexit y of event Listener.

utton,List,MenuItem

ublic void mouseDragged(MouseE vent )

method.

ddMouseMotionListener()

oid componentHidden(Componen tEvent obj)

ousePressed(MouseEvent e){}

heckBoxMenuItem

va.util.EventObject
ddActionListener(ActionListener o bj)

d()

etAdjustmentType()

ddMouseMotionListener().

l of the mentioned

OMPONENT_SIZED

ata array and Column Headings

correct
(ItemEvent ie)

.jpg

ublic void keyRel eased(KeyEvent e) {


;Key up&quot;); }

MouseListener methods ,class name not found

ntentPane();

ouseMoved(MouseEvent) mouse Dragged(MouseEvent)

utton, TextField, List, Menu

uot;NO&quot;)

er(AdapterDemo (this));
ror is in the statement String s= (String)ie.getItem();

tatement

ayed w ith the sa me border.

isplayed w ith th e same text &quot;Java&quot;.

er(this);

display &quot;Bu tton clicked &quot; message in sta


scrollpane is cre ated

has not been a dded on the button

er()
nt e)

Released(Mouse Event me)

ssed(KeyEvent k e)
add(jtp);
s);

istener class
void valueChan ged(TextEvent e) is w rong it shoul t
anged(TextEven e)

tement

e extends Apple t implements ItemListener


ner(this); branc h.addItemListener(this); public void
(ItemEvent ie) { repaint(); }

leared in code

ent w here publi c void actionPerformed() method is


dActionListener, actionPerformed, ActionEvent

Color.yellow );

; import java.aw t .event.*; import java.applet.*; pu


nds Applet imple ments ActionListener { Button red
void init() { red =new Button(&quot;Red&quot;);
(&quot;Green& quot;); blue=new d);
&quot;); add(re

vent.*; is missin g
mport java.aw t.* ; import java.aw t.event.*; import ve
ic class choicee extends Applet implements uot;;
ng m=&quot; &q Choice os; public void init() W indow
; os.add(&quot; s 98&quot;);
dow s XP&quot;) ; os.add(&quot;W ind

ed(KeyEvent k) { msg+=k.getKeyChar(); repaint();

ner,actionEvent(ActionEvent ae)
,addActionListe

new MyMouseA dapter()); class MyMouseAdapter

Pressed (Mouse Event me )


new MouseAda pter())

dapter,W indow Ev ent


1);

Listener

ener(this);

(ItemEvent ie)

se of Anonymou s Inner class


void mouseMove d(MouseEvent me){}

tionPerformed(A ctionEvent ae)

d()

hanged(Adjust mentEvent ae)

ctionEvent e)
(ItemEvent ev)

hanged(Adjust mentEvent ae)

nt ke)

hanged

ctionEvent ae)

Event e)
ctionEvent ae)

ctionEvent ae)

vent ke)

ed(ItemEvent ie )

hanged(Adjust mentEvent ae)


ctionEvent e)

(ItemEvent ie)

(ItemEvent e)

hanged(Adjust mentEvent ae)

stener(this), mo moususeMoved(MouseEvent e),


vent

erformed(Action Event ae) {


ctionCommand() ); }

ionPerformed(Ac tionEvent e)

ousepressedListener

yped Key Releas ed

eyListener interface

omponent object w hich generate d event.

sing W indow Listener


u,MenuItems,Me nuBar
ox,ItemListener

mport java.aw t.*; import java.aw t .event.*;

ublic void actionPerformed(Action Event ae)

new MouseAda mous pter() { public void


x=me.getX(); y=me.getY(); } })

1.addActionlistener(this) should r equired in program

er(this);b2.add ActionListener(this);

eyDragged(KeyEvent ke)

hanged(Adjust mentEvent e)

nd the selected i tem in text area w hen list item is


ned in Applet w ith tw o layouts: Border layout and

ionPerformed
l mentioned above

oid itemStateChanged(Item ie)

essed and then released

oth Options A and B correct.

ouseExited,mouseEntered,mous ePressed,mouseClicked,mouseRele

dles the Event W ithin the class

onListener

splay Tw o button s labelled &quot;OK&quot; and w ith


t;; The button label &quot;cancel&quot; w ill b

ins Tw o buttons labelled &quot;OK&quot; and


t;; The button not w ith label &quot;cancel&quot; w ill b

splay buttons in a sequence 5 4 3 2 1

onatain a multilin e textbox having background colou

addActionListener(this);
tfield

tItem();

er( this ); cance l.addActionListener( this ); implem

lse

ditable(true);
m1.addActionLis tener(this);

r(this); and cp.a dd(cb);

ed(KeyEvent ke) { msg += ke.getKeyChar(); repai

; import java.app let.*; public class ListDemo extend


d init() { List con =new List();
ia&quot;); con. add(&quot;Austrailia&quot;);
uthAfrica&quot;) ; add(con); } } /*&lt;applet
emo.class&quot; height=200

importjava.appl et.*; public class choice11 extends


d init() { Choice os=new Choice(); dd(&quot;w
n18&quot;); os.a nnxp&quot;); dd(&quot;w in
nnt&quot;); os.a 2000&quot;); add(o
e=&quot;choice1 1&quot; height=200 w idth=300&g
ActionListener(t his) actionPerformed(ActionEvent a

; import java.app let.*; public class app1 extends A new


{ TextField tf =
heckbox c=new
Checkbox(&quo

utton - ActionEvent Checkbox - It emEvent List - ItemEvent,ActionEv

ctionEvent e),ite mStateChanged(ItemEvent e)


ctionEvent ae)

his);

r passw ord echo charachter


er(this)

this); addMous eMotionListener(this); import

this);
B

er(new MyAdapt er());

s);

r(this);

tener

ctionEvent ae)
; brow ser = new Choice();

a.aw t.event.*; p ackage

ontainer cpane=jframe.getConte ntPane();

g.*;

w ImageIcon(&q uot;star.gif&quot;));

er(this)
r(new mouse() );

u);

u);
u);

u); m.setMenuBa r(mbr);

B
ner(this);

er(this);

w JScrollPane(jp ,v,h);

emStateChanged(ItemEvent ie)
(ItemEvent ie)

ActionListener,a ctionPerformed(ActionEvent e)

vent.*; check.ad dItemListener(this);


r(this);

vent.*; addMous eMotionListener(this)

); b1.addActionL istener(this);
; add(maybe);

; import java.aw t cla.event.*; import javax.sw ing.*; pu t


implements ActionListener { JButton
b1; public void init() { g&quot;);
draw =new
w JButton(clock); } public void
b1.setIcon(draw ); }

bodemo11.java

d()

ctionEvent a)

hanged(Adjust mentEvent ae)

oid mouseMoved(MouseEvent me )
onperfomed()
play vertical and sb2 display horizontally

extEvent(Obect source,int event_ type)

ocus_Gained and Focus_Lost

method

this); inside the init() method

indow _Activated,W indow _ICONI FIED,W indow _GAINED_Focus

ublic void addActionListener(Actio nListener l)


ouseMotionListener

anel(); jp.setLay out(new GridLayout(3,3)); int b =

3; i++) { for(int j = 0; j &lt;3; j++) { jp.add(new


ton &quot; + b)) ; ++b; } }

e( dataValues, c olumnNames ); scrollPane = new


);

ActionEvent
s KeyListener ke yPressed(KeyEvent ke)

bove

s JTabbedPane, w Jbutton,JCheckBox, Jtable,JCombo

va.aw t.* and java.aw t.event.*

on
abstract and doe s not override abstract method
hanged(Adjust class mentEvent) in AdjustmentListener p
s Applet i mplements AdjustmentListener

ed

me

d?false Is Butto n 2 enabled?true


ateChanged(Ite mEvent ie)

va.util.eventObject

ouput

dd one or more event listener to handle the events


nts generated b y these buttons

should extends KeyAdapter

emStateChanged()

ed in Checkbox Constructor

hanged

; import java.aw t .event.*; import javax.sw ing.*; pu


ds JApplet imple ments ActionListener { JTextAreaj
ublic void init() { Container
ontentPane(); Flow ContentPane.setLayout(new
uttonjb=ne w JRad
isplayed.

e Displayed and event w ill not be handled

w hich can be clos ed.

programming
splay the string & quot;Advanced Java
t; in appletview er w indow . The size of the string w
oints w ith every mouse click.

and Choice as o uput

be displayed in t extfield
em from list1 is added to list2

l methods defined in that interfa ce

omponent is added or removed

ects

y A is pressed

t w ass added a s listner

o determine w hic h listener w ill be invoked first.

t w as added as listener

o determine w hic h listener w ill be invoked first

r is invoked, the n Init method is invoked


oid mouseMoved(MouseEvent e) , void mouseDragged(MouseEvent

ublic class MyApplet extends Japp let implements ActionListener

utton,List,MenuItem

a , Button

ny of one depends on single click and double click

r
vent.*; import ja va.aw t.*; import java.applet.*;

er(this);

eased(KeyEvent e) { show Status(&quot;Key up&q

void keyRelease d(KeyEvent e) {


;Key up&quot;); }
useMotionListe ner

r()

emStatechanged(ItemEvent e)
onPerformed (Act ionEvent event )

etIcon(ImageIcon i)

utton object may generate an Ac tionEvent

ontainer c1=getContentPane(); c 1.setLayout(new Gridlayout());

splaying the text in a label.

ect

ublic void itemStateChanged(Ite mEvent obj)

ouseDragged(MouseEvent me), mouseMoved(MouseEvent me)

tructor new JBu instatton(Action) that enables you to a

l of the mentioned

ner(p)
l of the mentioned

LL of the mentioned

EXT_VALUE_CHANGED

l of the mentioned

ddMouseMotionListener()

()

mouseDragged()

gment w ill gener ate the follow ing output. import


port java.aw t.*; import java.aw t.event.*; public cla
ds JFrame imple ments ItemListener { JComboBox l
DemoFrame() { this.setLayout(new
ick.addActionListener(this)

or may not have listea w ay to register and deregister

er(this);

w ithout error a a nd defines a class that could be us

AdjustmentList ener(this);

dActionListener( this), actionPerformed(ActionEvent

e
class

; import java.aw t .event.*; import java.applet.*; pu


xtends Applet i mplements MouseListener { pub
ddMouseListen er(this); } public void
seEvent me) { show Status(&q

vent.ItemListene r;

the w ord Dolly w ill be seen at the top of the form,


etContainerEvent()

Edit Dele

is automatically allocated. Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

unication end point Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

ained in datagram Edit Dele

or Edit Dele

on-oriented, concurrent Edit Dele

et Edit Dele

Edit Dele

Edit Dele

me() Edit Dele

Edit Dele

Edit Dele
Edit Dele
Edit Dele

Edit Dele

Edit Dele

ection, Socket, InetAddress Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

name to ip address Edit Dele

Edit Dele

Edit Dele

on oriented protocol Edit Dele

Edit Dele

sion Control Protocol Edit Dele

Edit Dele

Edit Dele

. Edit Dele

netAddress IPAddress, int port). Edit Dele

Edit Dele

Edit Dele

Edit Dele

ort to w hich this Socket object is connected. Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

et.accept() Edit Dele

Hostname, portnumber, filepath Edit Dele

Edit Dele

Edit Dele
eam in = s.getInputStream(); Edit Dele

ectOutputStream(socket.getOutputStream()) Edit Dele

Methods of InetAddress class Edit Dele

olicy() Edit Dele

Edit Dele

Edit Dele

mPacket and DatagramSocket Edit Dele

Edit Dele

n Edit Dele

URLConnection class Edit Dele

Resource Locator Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

the host Edit Dele

a connection betw een the client &am server p; Edit Dele

tion is automatically established w ith that URL Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

rt) Edit Dele

Edit Dele

n Edit Dele

Edit Dele
Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

etAddress getLocalHost( ) Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

ess class does not contain any visible constructor. Edit Dele

Edit Dele

Edit Dele

mSocket(InetAddress address) Edit Dele

Edit Dele

eate connection betw een client and server Edit Dele

nsmission of lost packets. Edit Dele

aliable and connection oriented Edit Dele

nrealiable and connection less Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

etAddress getAllName(String hostName) Edit Dele

Edit Dele

Edit Dele
Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

DatagramSocket() Edit Dele

n Edit Dele

); Edit Dele

() Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

r socket. Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

t packet) Edit Dele


Edit Dele

Edit Dele

Edit Dele

ame=w w w .msbte.com Port Number =-1 Edit Dele

Edit Dele

Edit Dele

Edit Dele

ion; import java.net.*; public class S erver


n(String[] args) throw s IOException {

ServerSocket(2000); Socket sock=ss.accept(); Edit Dele

Edit Dele

Edit Dele

Edit Dele

the port number on w hich the socket is connected Edit Dele


4,16 Edit Dele

n Edit Dele

= new DatagramPacket(dataOut, Edit Dele


ddress, 9876)

Edit Dele

Edit Dele

rverSocket(int portno) Edit Dele

Edit Dele

Edit Dele

Edit Dele

ost:w w w .javajazzup.com File: Ext:http://w Edit Dele

Edit Dele

Edit Dele

ry.com/javamcq Edit Dele


Edit Dele

Edit Dele

the host Edit Dele

w .msbte.com&quot;); Edit Dele

Edit Dele

s getLocalHost() Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

eive message from client to server Edit Dele

ups of four hexadecimal digits each Edit Dele

Edit Dele
Edit Dele

Hostname,Port Number, File Name Edit Dele

ns a URLConnection object Edit Dele

urity.Permission Edit Dele

Edit Dele

Edit Dele

ata[],int size) DatagramPacket(byte data[],int Edit Dele

t java.net.*; public class URLConnecti public on { Edit Dele


] args) { try{ URL url=new
w .javatpoint.com/java-tutorial&quot;);
RLConnection)url.o

Edit Dele

Host(),getByName(),getAllByName() Edit Dele

Edit Dele

otHost( ) Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

ocket(int port, int maxQueue) Edit Dele

tring hostName, int port) Edit Dele

Edit Dele

etAddress getLocalHost() Edit Dele

Edit Dele

Edit Dele

yName(String hostName)throw s Edit Dele


n

ocalHost( )throw s Edit Dele


n
ocalHost( )throw s Edit Dele
n

Edit Dele

ds/index.php Edit Dele

Edit Dele

tion Edit Dele

Edit Dele

nection oriented protocol. Edit Dele

Edit Dele

Edit Dele

erverName,port); Edit Dele

ay handshaking Edit Dele

edURLException Edit Dele

ermission(&quot;/tmp/abc&quot;,&quot;read&uot;); Edit Dele

Edit Dele

w .google.com Edit Dele

at 2000 port number and sends w el come Edit Dele


Edit Dele

t.accept() Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

s = InetAddress.getAllByName(&quot;w w w .g Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

eam in = s.getInputStream(); Edit Dele

urld { public static void main(String args[]) th)); Edit Dele

olicy() Edit Dele

g the attributes of a remote resource. Edit Dele

Host name or address 3.port number or resour 4.File Edit Dele

Edit Dele
ot correct Edit Dele

ot correct Edit Dele

ent Edit Dele

Edit Dele

Edit Dele
rver socket bound to the specified p An exceptort. Edit Dele

Edit Dele

Edit Dele

InetAddressTest { public static void main(Stri Edit Dele

Edit Dele
Edit Dele

s and host name as LocalHost Edit Dele

etAddressgetLocalHost( )throw s Unknow nHostExce ption Edit Dele


Edit Dele

uot;Local hostname is: &quot; + Edit Dele


()); is w rong

Edit Dele
ct containing data from inputstream object Edit Dele

ml Edit Dele

Edit Dele

Edit Dele
Edit Dele

Edit Dele

Edit Dele

ve IP address of the specified host machine. Edit Dele

Edit Dele

cket to a local IP address and port Edit Dele

hod w rites a string into underlying output stream Edit Dele

Edit Dele
in method Edit Dele

ime and date of response in terms of millisecond Edit Dele

Edit Dele

nHostException Edit Dele

ddress Edit Dele

the host Edit Dele

ncurrent Edit Dele

e server regardless of w hehter the p in use ort is Edit Dele

ddress of a host could not be determined Edit Dele

Edit Dele
rt java.io.*; class tcpip_client { publi static c Edit Dele
) throw s IOException { Socket s=null;
try { s=new
LocalHost(),98); b=new
putStreamReader(s.getInputStream( )));
ception u) { System.err.println(&quot; don't }I
em.exit(0); } String inp; w
!=null) { System.out.println(inp); }

dress.getByName(&quot;localhost&quot;); Edit Dele

Edit Dele

ocket = HttpURLConnection.open(8080); Edit Dele

Edit Dele

Edit Dele

Edit Dele

cal MAC, Remote MAC and Protocol Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele
Edit Dele

rt java.util.*; import java.io.*; Edit Dele

lLocalHost() throw s Edit Dele


n

; Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

acket=DatagramPacket(sendData, Edit Dele


ress, port);

); Edit Dele

() Edit Dele

Edit Dele
Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

n Edit Dele

Edit Dele

Edit Dele

Edit Dele

Edit Dele

Answer

C w ritten in C language

ication program interface

ermines w hether the ResultSet c ursor points to the last row of the
ion getConnecti on(String url, String name, String p

jdbc.odbc.JdbcOdbcDriver

sNotFoundException

ead only ResultS et

eparedStatement object

e w here server r uns, User ID, Passw ord

eve name of user

nvoking the executeUpdate(...) m ethod of a Statement object

ial getter metho getInds on the ResultSet: getString(...),

xecuteQuery();

databases

sNotFoundException

Datbase Connectivity

Database Connectivity

C driver, ODBC drivers


calls

C calls, netw ork protocol

ERT, UPDATE ,DELETE ONLY

n database connectivity

ompile Statement

ctured Query Language

ETE FROM CUSTOMER

jdbc.odbc.JdbcOdbcDriver

ctured Query Language(SQL)

C-ODBC Bridge Driver

ve API partly Java driver


ve Protocol Pure-Java Driver

API w ith databases

C-ODBC bridge driver

C-ODBC Bridge Driver

E_FORW ARD_ONLY

C-Native pure java

h Type 3 and Type 4

h Type 3 and Type 4

a driver

ECT, FROM, W HERE

s.forName(&quot;sun.jdbc.odbc. JdbcOdbcDriver&quot;)
rt into department values(?,?,?)

s.forName(&quot;sun.jdbc.odbc. JdbcOdbcDriver&quot;)

dlew are Application Server

meter in prepared statement

ass OracleCon{ p ublic static void main(String args[]


&quot;oracle.jdb c.JdbcOdbcDriver&quot;); Connecti
getConnection(
n:@localhost:1 521:xe&quot;,&quot;system&quot;
.createStatemen t(); ResultSet rs=stmt.executeQue
; w hile(rs.next() ) System.out.println(rs.getInt(1)+&
2)+&quot; &quo t;+rs.getString(3)); con.close(); }
); } } }

modules can be built to support specific business needs.


es cursor to the end of resultset that is after last row

cution statemen t

in w hich driver i s registerd

ation statement

ve a runtime erro rowr, because the cursor in resultSet


o move the cursor to the first row i s
the cursor to the next row in the

dlew are that provide access to d atabase.

et is an object o databf class UpdatableResultSet ,and if

aredStatement interface

dbc.odbc.JdbcO dbcDriver”);

ry)
qry)

d values(?,?,?)& quot;;

stmt = null; try { String SQL = &quot;Update Emp prep


;; pstmt = conn.
Close (); }

ct * from employee w here salary &gt;10000

ement.

s is in the w rong order.

con object of connection class in itiated w ith connection of content

dbcDriver

eStatement();
verManager.get Connection(&quot;jdbc:odbc:mcm

umn Name of 1s t column: empid Column Type Nam

er of row from t able.

ks &gt; 70 are: Rakhee Rahul Karthik


c:odbc:mystudta ble&quot;);

ble

te();

ction to DataBa se created ID : 1 name : ramesh S


y : 1111 ID : 6 n ame : Sanjay Salary : 9500
orName(&quot; sun.jdbc.odbc.JdbcOdbcDriver&quo

tmt=conn.prep areStatement(&quot;Delete from S

ction to databas e created


mp; Package St atement

e given to all the records


tement

eateStatement( );

reateStatement ();

teQuery(&quot; select * from StudTable&quot;);


s=con.prepare Statement(&quot;insert into emplo
ps.setInt(1,200) ; ps.setString(2,&quot;amol&quot;

ement

block

r in creation of Statement object


()

te w ith execute Query

ck

nnection()

d
statement.

eManager.getC onnection(url);

plete ResultSet Statement

ent
ement

ment() and semic olon missing

me
lay All the Records of StudTable

ed

d}

tatement
teStatement();

of * symbol

red

ion, SQLExcept ion

ss notfound sun :jdbc:odbc:JdbcOdbcDriver

in first column a nd 17 w ill be inserted in second co


query);

=c.createState ment();

t mentioned

database produ ct name and Database SQLkeyw or

here executeQu ery() method is called

cuting sql statement and retrievi ng results

Statement(quer y); pstmt.setInt(1, 1001);


uot;Pune&quot; );

ers are not loaded


etConnection m ethod

erManager.getC onnection(url);

ment();

epared stateme nt is created

ement

te method i.e.s. executeQuery()

name is incorre ct
mp; SetString is i ncorrect

ame is incorrect

missing

teQuery(&quot; select *from StudTable&quot;);

ry);

getConnection(u rl);

-JdbclOdbc:DSN ,String Usernam e, String Passw ord

eve name of user

o mark interme fine-gdiate points inside a transaction, in be

;sun.jdbc.odbc. JdbcOdbcDriver&quot;); Connectio ot;j


Connection(&qu
atement ps=c.pr
sultSet rs=ps.ex
ic ResultSet executeQuery( Strin g );

eateStatement() ; ResultSet rs=st.executeQuery();

setString(); set Int();

ultSet.TYPE_BACKW ORD_ONLY

an CEO

table= 3 Name of the first columnID Type of the se


rd column20
leted

ange branch cod es of all students from 'CO' to 'CM'.

ving id=33

st index position and Ratan is inserted at second in

ion getConnecti on(String url)

alues(11,'rames h')

and pstm.setStr ing(2, name1);


()

nnection(url);

x of Question mark

LETE

ication layer &amp; database la yer

ENSITIVE

n.createstateme nt() st.executeUpdate(s)

sNotFoundException

a driver

gisterDriver(Driver driver)
date()

md = rs.getMeta Data();

information abou t ResultSet Metadata

tch all the record s of emp table.

sert all values int o emp table until user press 'n' .

is missing Class .forName(&quot;sun.jdbc.odbc.Jdb


or of missing a c losing curly bracket

uteUpdate() mu st be replaced by executeQuery()

tion created Tab le created Record Inserted :: 1 Re


Record Inserted :: 4 Name : AAA Age : 12 Name :

ction to databas e created Statement object create


cord Inserted 3

.security.permission

onnection creat ed msg is displayed

ompiled SQL Statement

x.sql.ConnectionEvent

tSet
tement (&quot; SELECT COF_NAME, PRICE FROM C
ecuteQuery();

ic ResultSet executeQuery(String sql)throw s SQLException

om table w here st=coemp_id=?”; PreparedStatement ecuteU

ate(&quot;insert into stud values(5,'Sneha',67)&qu

erManager.getC onnection(url);

t ps=con.prepa reStatement(&quot;Select * from t

reateStatement ();

ITIVE

ert into if6g valu es(?,?)&quot;; PreparedStatement


ment(str);
nection con=DriverManager.getC onnection(&quot;Jdbc.odbc : DSN

uteQuery(s1);

;sun.jdbc.odbc. JdbcOdbcDriver&quot;);

ding SQL queries to the databas e

a integrity improves as multiple a pplications access the same store

n(String args[]) throw s SQLException


nnection(&quot ;jdbc:odbc:mydsn&quot;);

etString(1, 'Joh n');


C drivers,JDBC drivers

tion created stu dent information is BBB 15 Connec

xecute queries asked to databa se

le = 'Java Progr aming' w here courseId = '11111'

tSet

nt layer and tw o server layers

n = DriverManager.g ;jdbc:mysql://localhost/test&quot;

uteUpdate(&quo t;delete from student w here id=1&

c static Connection getConnection(String url)

executeQuery(&quot;select * from Address&quot;);


eCall(&quot;{call

Stock}&quot;);cs.executeQuery();

Statement(ResultSet.TYPE_S
tSet.CONCUR_UPDATABLE);

tSet sel = st.executeQuery (&quot;select * from Login&quot;);

load tw o different drivers

nect()

g url=&quot;jdbc:odbc:abc&quot;;

atement object is created to sen d sql commands to the database

table is created .

rror
row you are positioned on is del eted form the ResultSet and from t

database and JDBC resources ar e released

treated as norm execual SQL statements, and are execu a su

pes: &quot;Res ultSetMetaData rs1=con.getMetaD

n: No suitable d river found for jdbc.odbc.Samarth

n: [Microsoft] [O DBC Microsoft Access Driver] Synta


pression 'Pa_R aM000 City=Pa_RaM001 ID=Pa_Ra

n: [Microsoft][O DBC Microsoft Access Driver]COUN

undException: s un.jdbc.odbc.JdbcodbcDriver

hod w ill execute sql query and ouput is available is

type of driver, w ritten entirely in Java, communicates directly w ith t

ction to databa se created Statement Object creat

e w ill be display ed from table

ntrol Panel-&gt; User Admistrative Tool-&gt; Data Sourc

ient side, a separate driver is ne eded for each database.


d

se

n.createStateme nt();

ting salary and id as a parameter

ommit statemen t = 1 No. of row s after commit stat


d from emp

( ) method is used to retain nex t elements in a series.

ct * from information_schema.ta bles

nt value indicating how many ro w s are effected from the invocation

ic void close() throw s SQLExcept ion

ement interface provides metho ds to execute quries w ith database

ataSource is a factory of connecti ons to a physical data source

Suresh

ement.
tatement

quot;Name &qu ot;+res.getInt(1)+&quot; Roll_NO


+&quot; per &q uot;+res.getInt(3)); should be
quot;Name &qu ot;+res.getString(1)+&quot; Roll_N
+&quot; per &q uot;+res.getInt(3));

L w arning

ed

w ith name regis tration

number, student name and percentage those havi


h tw o data field i n database

: false Connecti on is closed : true

ction to databa se created Statement Object is cre

oaded connectio n established and table created

ption ii

ation error

nection w ill does not close

ys all students taking the Java Programming cours

BC database URL passed is not c onstructed properly.

YSQL database Mysql

ecuteUpdate Q uery

…. ; DatabaseMe null;taData dbmd = con.getMetaData( le =

e JDBC driver manager


ion, SQLExcept ion

UserName(). ,isReadonly()

t p=c.prepareS tatement(&quot;Select * from Emp


;

= con.prepare cs.exeCall(&quot;{call COUNTRECS}&quo

es the curtrent stmt object

plus ODBC drive alsor, also called Type 1. 2 Native-API, Jav

va driver

h Type 3 and Type 4


, Type 3 and Typ e4

h Type 3 and Type 4

-java driver

ed above

cuteUpdate(&quot;select * from MSBTE&quot;)

rt into department values(?,?,?)

ocol,subprotocol,datasource na me

ultSet executeQuery(String str)

en called as App userlication layer includes JDBC drivers r.

nection con = DriverManager. ge tConnection (”jdbc:odbc:somedb”,

&quot; select ro resuw id from Employees w here id ='12 (&


y(&quot;select* from emp&quot;);

cuteQuery(String sql)

e 4 drivers can not be used w ith NetScape.

ement si=con.createStatement( ResultSet.TYPE_SCROLL_SENSITIVE

st()

similar concept to ODBC.

eteRow ();

r object
querydel);

and variable 'if' statement

catch() Stateme nt

C stands for Java DataBase Conn ectivity

;sun.jdbc.odbc. JdbcOdbcDriver&quot;); Connectio ot;j


Connection(&qu

NSERT INTO Regi stration &quot;+&quot;VALUES (10


cuteUpdate(sql) ;

hods
;jdbc:odbc:stud dsn&quot;); Connection
getConnection(& quot;sun.jdbc.odbc.JdbcOdbcDrive

CT id, age, first F execROM Employees&quot;; ResultSet


{ int id = rs. getInt(&quot;id&quot
t= rs.getString (&quot;first&quot;)

smd=rs.getMeta Data();

e 3-JDBC-Net Pure java

ic boolean absolute(int row )

alization,persistence

s.forName(&quot;sun.jdbc.odbc. JdbcOdbcDriver&quot;)

Ed
Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

quest req, ServletResponse res) Ed

current brow ser session ends Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed
Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

n,Loading and initialization,Request Handling,Destroy Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed
Ed

Ed

Ed

, init() , destroy() Ed

Ed

sed and CGI is process based Ed

Ed

LUE=parameter_value&gt; Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

gram used for developing and executing w eb applications. Ed

Ed

Ed

Ed

Ed

Ed
Ed

Ed
Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

eType(String File),void Log(String s) Ed

Ed

Ed

Ed

Ed

Ed

session object, using cookies, using hidden fields Ed

sion&gt; Ed
Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed
Ed

q &amp; HttpServletResponse res Ed

Ed

Ed

Request request, HttpServletResponse response)


Ed
ot;); PrintW riter out =
ntln(&quot;&lt;h1&gt;&amp;quo
E

ame&quot;); E

tion=&quot;CheckPass &quot;
E

.*; import javax.servlet .http.*; E

E
E

es(); E
E

E
E

n value of request para meter. E

uest.getSession(true); E

E
E

ata); text/html E

ord then it displays &qu ot;w elcome to home E

E
E

extended E

Ed

Ed

Ed

equest, HttpServletResponse response) Ed

Ed
er(); replace this statement w ith response.getW riter(); Ed
E

sername&quot;); w her e req is E

etResponse res) E

quot;name&quot;); E

ACTION=&quot;/servle t/Hello&quot;&gt; E

Ed

Ed

Ed

Ed

show Cart.jsp&quot;); Ed
Ed

ew Cookie(&quot;username&quot;, &quot;joe&quot;)); Ed

Ed

secureapp/do/Login?name=&quot;bob&quot; Ed

%&gt; Ed

Ed

Ed

Ed

Ed

Ed

etRequest req,HttpServletResponse res) Ed

quest req, ServletResponse res) Ed

Ed

onse res) throw s IOExpection, ServletException Ed

Ed

Ed

Ed

Ed

EB-INF\classes Ed
); response.addCookie(c);

E
E

.*; import javax.servlet .http.*; E

Ed

Ed
initialization goes here } public void service(ServletRequest reqEd

ception { // actual service is provided here } public void

Ed

Ed

Ed

dependent but servlet are platform independent Ed

Ed

e instances of the Servlet. Ed

Ed

Ed

Ed

alization 3. Execution 4. Cleanup Ed

t/Test Ed

o obtain all cookies in an array Ed

ype(&quot;text/html&quot;) Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed
Ed

Ed

visited page count , session ID.

Ed

Ed

Ed

Ed

ntside w hereas HttpSession w orks at serverside. Ed

Ed

Ed
yle E

e E

on Date and the Current Date


Ed

Ed

ata in the body of the request Ed

Ed

are of Servlet Interface Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

Ed

rt javax.servlet.*; Ed

Ed

Ed

Ed

Ed

Ed
Ed

alue=&quot;foo.jsp&quot;/&gt;' /&gt; Ed

Ed

Ed

uest Ed

Ed

Ed

Ed

Ed

erValues() Ed

Ed

Ed

Ed

ession object,using cookies,using hidden fields Ed

&quot;a1&quot;);

onse.getW riter(); pw .println(&quot;Hello W orld&quot;); Ed

Ed

Ed

Ed

Ed
Ed

Ed

Ed

pable of running Java programs. Ed

You might also like