Advance Java MCQ Ch1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 91

Chapter 01 Introduction to AWT

Question Bank : Advanced Java Programming (22517)


Class : TYCM
Chapter No. 01 Introduction to AWT

Answer the following questions:


(Note: Only one answer is correct).

1. AWT Means?
a) Abstract Windows Toolkit
b) Advanced Web Toolkit
c) Abstract Web Toolkit
d) Advanced Web Technology

2. Which is the immediate super class of Applet?


a) Container
b) Component
c) Frame
d) Panel

3. The setSize( ) method is defined by this class…


a) Applet
b) Component
c) Frame
d) Panel

4. Which class encapsulates a blank window upon which we can draw?


a) Applet
b) Canvas
c) Window
d) Frame

5. What are the variables defined in ‘Dimension’ class?


a) length and width
b) height and length
c) height and width
d) len and wid

6. If we want to hide the window, we can use this method…


a) setVisible( )
b) show( )
c) setHidden( )
d) view( )
Chapter 01 Introduction to AWT

7. Color class can create object of it using which of the following color
values?
a) RGB
b) RYB
c) CMY
d) HSB

8. The setColor( ) is the method of which class?


a) Applet
b) Graphics
c) Color
d) Object

9. Which of the following style is not supported by Font class?


a) Font.UNDERLINE
b) Font.ITALIC
c) Font.PLAIN
d) Font.BOLD

10. All the AWT controls are subclasses of which class?


a) Component
b) Container
c) AWTControl
d) Window

11. How you can remove all the controls from the applet?
a) Using remove( ) method.
b) Using removeAll( ) method.
c) Using removeAllControls( ) method.
d) It is not possible to remove all controls using single method.

12. Which of the following is passive AWT control?


a) Label
b) Button
c) Checkbox
d) TextField

13. Which alignment is not supported by Label?


a) Label.RIGHT
b) Label.LEFT
c) Label.CENTER
d) Label.BASELINE

14. How can we create Radio buttons?


a) Using ButtonGroup class
Chapter 01 Introduction to AWT

b) Using CheckboxGroup class


c) Using RadioButton class
d) Using Button class

15. How to add the names in choice controls?


a) At the time of creation itself.
b) Using addName( ) method.
c) Using addItem( ) method.
d) Using add( ) method.

16. Multiple selections are allowed in…


a) Menu
b) CheckboxGroup
c) List
d) Choice

17. How can we copy the ‘List’s contents into ‘Choice’s contents
a) This is not possible.
b) Using copyInto( ) method of List
c) Directly assigning List object to Choice object.
d) Using copyFrom( ) method.

18. What is default block-increment of Scrollbar?


a) 10
b) 5
c) 1
d) We can not use block increment in scrollbars.

19. The immediate super class of TextArea is…


a) TextField
b) TextBox
c) TextComponent
d) Component

20. Is it possible to change display character of TextField? How?


a) Not possible.
b) Yes, by using setChar( ) method.
c) Yes, by using setEchoChar( ) method.
d) Yes, by using setDisplayChar( ) method.

21. Is it possible to center the text typed in TextField? How?


a) Not possible.
b) Yes, by using setAlignment( ) method.
c) Yes, by using setPosition( ) method.
d) Yes, by putting values in the constructor itself.
Chapter 01 Introduction to AWT

22. Which method is used to append the text at the end of TextArea?
a) append( )
b) add( )
c) appendAt( )
d) addAt( )

23. FlowLayout does not support this value of alignment…


a) FlowLayout.LEFT
b) FlowLayout.CENTER
c) FlowLayout.RIGHT
d) FlowLayout.BASELINE

24. The setLayout( ) is the method of which class?


a) Applet
b) Layout
c) FlowLayout
d) Graphics

25. BorderLayout does not support this value of alignment…


a) BorderLayout.WEST
b) BorderLayout.EAST
c) BorderLayout.NORTH
d) BorderLayout.MIDDLE

26. The correct constructor of Insets( ) which uses the values is…
a) Insets(int top, int left, int bottom, int right)
b) Insets(int bottom, int right, int top, int left)
c) Insets(int right, int top, int left, int bottom)
d) Insets(Dimesnion d1, Dimension d2)

27. The various controls supported by AWT are


a. Labels, push buttonss
b. Checkboxes, choice, list
c. Scroll bars, text area, text field
d. All of these

28. The concept of the menu bar canbe implemented by using three java classes—
a. MenuBar
b. Menu
c. MenuItem
d. All of these

29. The most commonly used layout managers are


a. FlowLayout
Chapter 01 Introduction to AWT

b. BorderLayout
c. GridLayout
d. CardLayout
e. All of these

30. The constructor which the Text Event class defines.


a. TextEvent(Object source, int event_type)
b. textevent (Object source, int event_type)
c. textevent (object Source, float event_type)
d. textevent (Object source, string event_type)

31. In Java an event is an _______which specifies the change of state in the source.
a. Class
b. Object
c. Int
d. String

32. The name of the event classes are


a. ActionEvent, ComponentEvent
b. ContainerEvent, FocusEvent
c. ItemEvent, KeyEvent
d. WindowListener, MouseEvent
e. TextEvent
f. All of these

33. The classes and interfaces defined in AWT are contained within the ______
package.
a. java.awt.*
b. java.sql.*
c. java.io.*
d. java.int*

34. Java packages such as ________________ support the Event handling mechanism.
a. java.util
b. java.awt
c. java.awt.event
d. All of these

35. The general form to set a specific type of layout manager is


a. void setLayout(LayoutManager lm)
b. Void setLayout(LayoutManager lm)
c. void setLayout(layoutManager lm)
d. Void setLayout(Layoutmanager lm)

36. Some of the event listener interfaces are_____________


a. ActionListener, ComponentListener
b. ContainerListener, FocusListener
c. ItemListener, KeyListener
Chapter 01 Introduction to AWT

d. WindowListener, MouseListener
e. TextListener
f. All of these

37. The AWT container is an instance of the ___________ class which holds various
components and other containers
a. Graphics
b. Container
c. Eventobj
d. None of these

38. A checkbox is a control that consists of a


a. Combination of a small box
b. A label
c. Combination of a large box and a label
d. Both a & b

39. Java applets are used to create _______________ applications


a. Graphical
b. User interactive
c. Both a & b
d. None of these

40. In Java, events are all the activities that occur between
a. The user
b. The applications
c. Both a & b
d. None of these

41. AWT means


a. Abstract Window Toolkit
b. Abstract Window Toollayout
c. Abstract Withdraw Tools
d. Abstract Window Title

42. Positions the components into five regions:east, west, north, south, center
a. BorderLayout
b. CardLayout
c. GridLayout
d. FlowLayout

43. Arranges the components as a deck of cards such that only one component is visible
at a time
a. BorderLayout
b. CardLayout
c. GridLayout
d. FlowLayout
Chapter 01 Introduction to AWT

44. Arranges the components horizontally


a. BorderLayout
b. CardLayout
c. GridLayout
d. FlowLayout

45. Arranges the componemnts into grid


a. BorderLayout
b. CardLayout
c. GridLayout
d. FlowLayout

46. __________ creates a dropdown list of textual entries


a. Choice
b. Checkbox
c. Textbox
d. TextComponent

47. The Component class and MenuComponent class are the ___________ which
represent the GUI components.
a. Subclasses
b. Superclasses
c. Both a & b
d. None of these

48. The Component class is an abstract class and so its ____________ are used to create
components.
a. Subclasses
b. Superclasses
c. Both a & b
d. None of these

49. The AWT classes can be roughly categorized into the following groups:
a. GUI Components
b. Layouts
c. Graphics Tools
d. Event Handlers
e. All of these

50. Panel is used for __________ components


a. Grouping
b. Managing
c. Deleting
d. Modifying

51. An Applet is a ________ of Panel:


a. Subclass
Chapter 01 Introduction to AWT

b. Superclass
c. Both a & b
d. None of these

52. Window is used for ____________ windows


a. Creating
b. Handling
c. Modifying
d. Both a & b

53. The subclasses of Window are


a. Dialog
b. Frame
c. Both a & b
d. None of these

54. The CardLayout class defines the following constructors:


a. CardLayout() // First
Cardlayout(int hor, int ver) //second
b. Cardlayout() // First
CardLayout(int hour, int ver) //second
c. CardLayout() // First
Cardlayout(int hor, int var)
d. CardLayout() // First
Cardlayout(int hour, int ver) //second

55. A menu bar represents


a. A list of menus which can be added to the top of a top-level window
b. A list of menus which can be deleted to the top of a top-level window
c. A list of menus which can be added to the bottom of a bottom-level window
d. None of these
56. Each menu is associated with a _________ list of menu items:
a. Checkbox
b. Drop-down
c. Choice
d. None of these
57. The two types of menus which are given as follows:
a. Pop-up menus
b. Regular menus
c. Both a & b
d. None of these
58. Regular menus are placed at the __________ of the application window within a
menu bar
a. Top
b. Bottom
c. Top-down
Chapter 01 Introduction to AWT

d. Botttom-up
59. The __________ interface is used to handle the menu events
a. ContainerListener
b. FocusListener
c. ActionListener
d. WindowListener

60. The text field and text area controls create a _________________ area respectively
a. Single-line text
b. Multi-line text
c. Both a & b
d. None of these
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 To Fig Q Mar
Question Answer
No pic ure Type ks

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

2 Which are various AWT controls from following? 1 N R 1 Labels, Push buttons, Check boxes, Choice lists.

3 Which of the following 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

A Frame's _______________ designates the area of the frame


5 1 N R 1 ContentPane
excluding the title,menu bar and the border.

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

A label is a simple control which is used to display


8 1 N R 1 Text(non-editable)
_________________on the window

9 A ScrollPane is _______________ 1 N R 1 Container

A superclass of Textfield and TextArea classes that is used to create


10 1 N R 1 Textcomponent
single-line , multiline textfields rexpectively is_____.

A _______ is a component that appears as a group of folders in a file


11 1 N R 1 JTabbedPane
cabinet.

A __________ automatically arranges the components added to a


12 1 N R 1 Layout Manager
container.

A ____________ is a passive AWT control which do not generate any


13 1 N R 1 Label
event.

A ____________________component is a display area for a short


14 1 N R 1 Jlabel
string of text, image or both.

All Component on Container can be removed by calling following


15 1 N R 1 removeAll()
method

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

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

Applet Container is used to prepare ________________output


18 1 N R 1 Both a and b
window.

19 AppletViewer tool is available in which 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 AWT hierarchy is the__________________ class. 1 N R 1 Component

22 AWT classes are contained in the __________ package 1 N R 1 java.awt

23 AWT is used for creating a GUI in Java. AWT stands for 1 N R 1 Abstract Window Toolkit

24 AWTEvent Class is define in following package 1 N R 1 java.awt

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

A____________ is component that presents a rectangular area in


26 1 N R 1 Scroll Pane
which a component may be viewed

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 flowlayout uses __________justification. 1 N R 1 Center

By default page-up and page-down increment of scrollbar


30 1 N R 1 10
is_____________.

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

32 By default which layout manager is set on applet 1 N R 1 FlowLayout

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

34 Canvas is a ________________ 1 N R 1 Window

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 Dropdown List

38 Components are added to which pane of swing 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 awt 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 FlowLayout

45 Default layout manager for Window 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

Double-buffering built in, tool tips, dockable tool bars, keyboard


48 1 N R 1 Swing
accelerators, custom cursors, etc. are new features of _______?

49 Each menu is associated with a ___________list of menu items 1 N R 1 Drop-down

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 which kind of dialog box? 1 N R 1 Modaltype

53 FlowLayout arranges components from 1 N R 1 Left to Right

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

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

56 For adding controls to a window, we use following method 1 N R 1 add()

for using Swing control one must


57 1 N R 1 import javax.swing.*
import______________________________pacakge

Frame is a standard window,which is ____________________of


58 1 N R 1 sub class
Window class from AWT hierarchy

59 getContentPane() method of which class 1 N R 1 JApplet

60 getSelectedCheckbox() mehod of which class 1 N R 1 CheckboxGroup

61 How can the Checkbox class be used to create a radio button in AWT? 1 N R 1 By associating Checkbox objects with a CheckboxGroup

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

63 How many checkboxes we 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 would you set the color of a graphics context called g to cyan? 1 N R 1 g.setColor(Color.cyan);

66 Identify the correct constructor of Font class? 1 N R 1 Font( String name, int fontstyle,int pointsize)

67 Identify wrong constructor of Checkbox 1 N R 1 None of Above

In applet, which of the following tag is used for accepting user defined
68 1 N R 1 Param
parameter?

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

70 In AWT Radio buttons are created using_____________________ 1 N R 1 CheckBoxGroup

71 In FlowLayout manager the default space between each component is 1 N R 1 5 Pixel

In Graphics class Which method is used to set the graphics current


72 1 N R 1 public abstract void setColor(Color c)
color to the specified color?

73 In how many ways we can define the scrollbar? 1 N R 1 All of the above

74 In Swing Buttons are the subclasses of which class? 1 N R 1 AbstractButton

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

In Swing ____________is a component that displays rows and


76 1 N R 1 table
columns of data.

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

78 Indentify which 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

Java supports input/output of data through the classes included in the


81 1 N R 1 Java.io
_______ package:

82 JCheckBox is _______________________Component 1 N R 1 lightweight


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

84 JTabbedPane class is present in which package? 1 N R 1 javax.swing

85 Jtree class comes under which package 1 N R 1 javax.swing

86 List can be created for multiple selection by using following 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 will always 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

Name the class used to represent a GUI application window, which is


91 1 N R 1 Frame
optionally resizable and can have a title bar, an icon, and menus

92 On which side applet always executed? 1 N R 1 Client side

93 Package of drawString() method is 1 N R 1 java.awt

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 Swing

Positions the componenets into five


97 1 N R 1 BorderLayout
regions:east,west,north,south,center

98 Program which executes applet is known as________ 1 N R 1 Appletviewer

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 which class 1 N R 1 Frame

State true of false i) AWT is an extended version of swing ii) Paint( ) of


105 1 N R 1 i-false, ii-false
Applet class cannot be overridden

106 Swing components are 1 N R 1 lightweight and platform independent

swing is the set of ____________ that provides more powerful &


107 1 N R 1 Classes
flexible components as compare to AWT.

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

The AWT container is an instance of the ___________ class which


111 1 N R 1 Container
holds various components and other containers

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

The CardLayout class manages the components in such a manner that


113 1 N R 1 Only one
____________component is visible at a time

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

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

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

The following specifies the advantages of It is lightweight. It supports


118 pluggable look and feel. It follows MVC (Model View Controller) 1 N R 1 Swing
architecture.

The method drawRect() is used to display an


119 1 N R 1 outlined rectangle
___________________________

120 The method setLabel can be used with what type of Object ? 1 N R 1 TextField.

121 The method ____gets the text of the button jtb is 1 N R 1 jtb.getText( )

122 the method _________ places a menu mu into a menu bar mb. 1 N R 1 mb.add(mu)

The method ______________ sets the foreground color to yellow in


123 1 N R 1 f.setForeground (Color.YELLOW)
Jframe

The method _______________creates a IconImage for file


124 1 N R 1 new ImageIcon("c:\image\us.gif");
c:\image\us.gif

The method ____________________gets the text (or caption) of the


125 1 N R 1 jlbl.getText()
label jlbl

The setBackground() method is part of the following class in java.awt


126 1 N R 1 Component
package:

127 The string parameter to the JButton constructor 1 N R 1 tells what text will appear on the button

The Swing component classes that are used in encapsulate a mutually


128 1 N R 1 ButtonGroup
exclusive set of buttons are?

129 The syntax for drawRect() method is 1 N R 1 drawRect(int top, int left, int width, int height)

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

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

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

The __________ arranges components in rows and columns and


133 1 N R 1 GridLayout manager
makes all components the same size.

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

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

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

These four methods commonly used in? 1)public void add(Component


137 c) 2)public void setSize(int width,int height) 3)public void 1 N R 1 Component class
setLayout(LayoutManager m) 4)public void setVisible(boolean)

138 To create window with title bar which of the following 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 drawString()

141 To draw a line in applet, we use following method 1 N R 1 drawLine()

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

To retrieve the current state of a check box,call


143 1 N R 1 getState()
___________________

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

145 We can add menus to _________________________ 1 N R 1 Frames

146 What are controls or components? 1 N R 1 Controls or components allow users to interact with application

147 What are the TextCompoent ? 1 N R 1 TextField , TextArea

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

149 What are the variables defined in Dimension 1 N R 1 height and width

150 What Checkbox method allows you to tell if a Checkbox is checked? 1 N R 1 getState()

What does the following line of code do? TextField text = new
151 1 N R 1 Creates text object that can hold 10 columns of text.
TextField(10);

152 What is API 1 N R 1 Application Programming Interface

153 What is default alignment of components using FlowLayout 1 N R 1 FlowLayout.CENTER

154 what is default layout manager for panels and applets 1 N R 1 FlowLayout

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

156 What is the difference between a TextArea and a TextField? 1 N R 1 A TextArea can handle multiple lines of text

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

What is the use of following method in JDialog? Container


158 1 N R 1 This method returns,a Content Pane for the JDialog.
getContentPane()

What is use of 3rd parameter in given constructor


159 1 N R 1 Thumbsize
Scrollbar(int,int,int,int,int)

160 What is use of second parameter in given constructor Label(String,int) 1 N R 1 sepcifies the alignment of text in label in terms of pixel

what layout manager should you use so that every component


161 1 N R 1 GridLayout
occupies the same size in the container?

What letter precedes Swing component names that have a


162 1 N R 1 J
corresponding AWT component?

What method is used to prevent a user from changing the size of a


163 1 N R 1 setResizable( false )
Frame() object?

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

165 When DialogBox is closed which method gets called 1 N R 1 dispose()

When layout manager is disabled , which method is used to determine


166 1 N R 1 setBounds
the shape and position of Component?

When we invoke repaint() for a java.awt.Component object, the AWT


167 1 N R 1 update()
invokes the method:
168 which method is used to set the visibility of the frame? 1 N R 1 1.setVisible(true)

which package we need to import while writng swing JRadioButton


169 1 N R 1 import javax.swing.*;
class

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

171 Which Among the below is not an AWT class 1 N R 1 RadioButton

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

173 Which are the subclasses of the container class? 1 N R 1 Windows,Panel,ScrollPane.

174 Which AWT component is not editable? 1 N R 1 Label

175 Which AWT control is used for multi-line text entry? 1 N R 1 TextArea

Which class can be used to represent a checkbox with a textual label


176 1 N R 1 CheckboxMenuItem
that can appear in a menu.

177 Which class creates a node in Jtree? 1 N R 1 DefaultMutableTreeNode

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

179 Which class encapsulates a blank window upon which we can draw? 1 N R 1 Canvas

180 Which class is on the top of the AWT event hierarchy? 1 N R 1 java.awt.AWTEvent

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

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

Which class is used to represent a single line textbox with password


183 1 N R 1 TextField
character facility?

184 Which class provides many methods for graphics programming? 1 N R 1 java.awt.Graphics

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

Which component displays information in hierarchical manner with


186 1 N R 1 JTree
parent-child relationship?

187 Which component in swing represents data in rows and columns? 1 N R 1 JTable

Which Component of AWT provides a compact, multichoice , scrolling


188 1 N R 1 List
selection?

Which components are needed to get following shown output


Figure:-

189 1 Y1 R 1 Label,TextField

190 which Container use a Border Layout as their default layout? 1 N R 1 All of the above
191 Which containers may have a MenuBar? 1 N R 1 Frame

192 Which control is not contain in AWT Package ? 1 N R 1 Scrollpane

193 Which h costructor creates a TextArea with 10 rows and 20 columns ? 1 N R 1 new TextArea(10 , 20 )

Which is Controll in swing a combination of a text field and a dropdown


194 1 N R 1 JComboBox
list

Which is correct method for adding button component into North region
195 1 N R 1 add(b1, BorderLayout.NORTH)
of border layout? Assume b1 as button object .

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

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

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

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

200 Which is the correct constructor of GridLayout 1 N R 1 GridLayout(int numrows, int numcols)

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

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

203 Which is true about swing? 1 N R 1 All the above

204 Which is various methods of TextField control from following? 1 N R 1 getText(),setText(),setEchoChar()

Which layout arranges the components as a deck of cards such that


205 1 N R 1 CardLayout
only one component is visible at a time

Which layout should you use to organize the components of a


206 1 N R 1 GridLayout
container in a tabular form?

207 Which method exectues only once 1 N R 1 init() method

208 Which method gets the text associated with Label object jlbl? 1 N R 1 jlbl.getText()

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

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

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

212 Which method is used to change the name of a menu item 1 N R 1 void setLabel(String newName)

213 Which method is used to close a swing frame? 1 N R 1 setDefaultCloseOperation()

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

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

216 Which method is used to set the dimensions of the window. 1 N R 1 void setSize(int newWidth, int newHeight)

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

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

219 Which method will cause a Frame to be displayed? 1 N R 1 setVisible( true)

Which object can be constructed to show and select any number of


220 1 N R 1 List
choices in the visible window?

Which of the following applet tags is legal to embed an applet class


221 1 N R 1 < applet code = Test.class width = 200 height = 100></applet>
named Test into a Web page?
222 Which of the following are not swing componant? 1 N R 1 both a & b

Which of the following are passed as an argument to the paint( )


223 1 N R 1 A Graphics object
method?

224 Which of the following are subclasses of Container Class? 1 N R 1 ScrollPane,Vector,String

225 Which of the following are subclasses of java.awt.Component? 1 N R 1 Container

226 Which of the following are true? 1 N R 1 Panel extends Container.

227 which of the following class is Derived from Container Class? 1 N R 1 Panel

228 Which of the following class act as a super class in class hierachy? 1 N R 1 Component

229 Which of the following components allow multiple selections? 1 N R 1 List

230 Which of the following components does not have visible borders? 1 N R 1 Panel

231 Which of the following contain a Menubar? 1 N R 1 A Frame

232 Which of the following controls does not support interaction with user? 1 N R 1 Label

Which of the following creates a List with 5 visible items and multiple
233 1 N R 1 new List(5, true)
selection enabled?

234 which of the following is not a AWT control. 1 N R 1 ButtonGroup

235 Which of the following is not a constructor of JTree 1 N R 1 JTree(int x)

236 Which of the following is not a swing class? 1 N R 1 Canvas

237 Which of the following is not active control 1 N R 1 labels

238 Which of the following is not an AWT component 1 N R 1 Applet

239 Which of the following is not true about Dialog Boxes? 1 N R 1 Dialog boxes contains menu bars.

240 Which of the following is not true about Swing Components? 1 N R 1 Heavy weight components

241 Which of the following is not valid alignment constant for Label? 1 N R 1 MIDDLE

242 Which of the following is not valid constructor for JCheckBox? 1 N R 1 JCheckBox(String text, boolean selected, CheckboxGroup group)

243 Which of the following is not valid style constant for Font? 1 N R 1 NORMAL

244 Which of the following is passive AWT control? 1 N R 1 Label

Which of the following is the immidiate superclass of the


245 1 N R 1 Object
MenuComponent class?

246 Which of the following is true about AWT and Swing Component? 1 N R 1 AWT Components create a process where as Swing Component create a thread

Which of the following is used to interpret and execute Java Applet


247 1 N R 1 Appletviewer
Classes hosted by HTML ?

248 Which of the following layout managers need to create a Panel? 1 N R 1 CardLayout

249 Which of the following may a menu contain? 1 N R 1 menu

250 Which of the following may contain a menu bar? 1 N R 1 frame

Which of the following method is use to add a button “b” to the south
251 1 N R 1 add(b,BorderLayout.SOUTH);
of the applet using BorderLayout?

252 Which of the following method is used to change the Label caption? 1 N R 1 setText(String s)
253 Which of the following method is used to retrive icon of JButton 1 N R 1 Icon getIcon()

Which of the following methods are invoked by the AWT to support


254 1 N R 1 repaint( )
paint and repaint operations?

Which of the following methods can be used to change the size of a


255 1 N R 1 setSize()
java.awt.Component object?

Which of the following methods can be used to remove java.awt


256 1 N R 1 remove()
component object from display?

257 Which of the following statements about GUI components is wrong ? 1 N R 1 The AWT classes are deprecated

Which of the following statements is for placing the frames upper left
258 1 N R 1 frame.setLocation(200,100)
corner to (200,100)?

Which of the following swing components donot have an Icon


259 1 N R 1 JTextField
parameter in its constructor?

260 Which of the follwing is constructor of Jtable? 1 N R 1 JTable(Object data[][], Object colHeads[])

261 Which of the method can be used to output a string in an applet? 1 N R 1 drawString()

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

263 Which of the subclasses of java.awt.component? 1 N R 1 Container classes

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

265 Which of these following is not a component of swing 1 N R 1 List

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

Which of these methods can be used to obtain the reference to the


267 1 N R 1 getContainer()
container that generated a ContainerEvent?

268 Which of these methods can be used to output a string in an applet? 1 N R 1 drawString()

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

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

271 Which of these methods is used to setting the winwods dimension 1 N R 1 void setSize(Dimension new_size)

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

273 Which of these package is used for graphical user interface ? 1 N R 1 java.awt

Which of these packages contains all the classes and methods


274 1 N R 1 java.awt.event
required for event handling in Java?

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

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

277 Which package use for import the swing components? 1 N R 1 javax.swing.*;

Which TextComponent method is used to set a TextComponent to the


278 1 N R 1 setEditable
read-only state?

which type of button is belongs to a group such that only one button in
279 1 N R 1 CheckboxGroup
the group may be selected at one time?

280 Which of these events is generated when a button is pressed? 1 N R 1 B.) ActionEvent
281 Why are swing component termed as lightweight ? 1 N R 1 they do not depend on native platform

282 Why we use Applet? 1 N R 1 Option A) and B) FROM this

283 Window is super class of ____________ 1 N R 1 Frame

284 Window, 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()

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

You want to construct a text area that is 80 character-widths wide and


287 1 N R 1 new TextArea( 10,80)
10 character-heights tall. What 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

_________Positions are the components into five regions east, west,


291 1 N R 1 BorderLayout
north , south, center:

__________ is a Swing class that allows the user to enter a single line
292 1 N R 1 JTextField
of text.

__________ is a Swing layout manager that arranges components in a


293 1 N R 1 GridLayout
row or a column.

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

295 __________ method is used to add the menubar on frame window. 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

____________ class is used to create set of mutually exclusive


298 1 N R 1 CheckboxGroup
checkboxes.

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

300 ____________arranges the component in rows and columns 1 N R 1 GridLayout

301 ____________creates a dropdown list of textual entries 1 N R 1 Choice

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

303 _______________contols are platform dependant 1 N R 1 AWT

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

___________________ AWT component is used to create popup list of


305 1 N R 1 Choice
string items from which only one can be selected at a time.

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

307 ____________________class creates blank sementics free window 1 N R 1 Canvas

308 _____________________ is not a Swing Component 1 N R 1 CheckboxGroup

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

310 ______________________class encapsulates AWT events. 1 N R 1 AWTEvent


311 ________________________ Constructs a new scroll bar with the 1 N R 1 Scrollbar(int)
specified orientation.

___________________________ component may have different size


312 1 N R 1 GridLayout
rows may have different number of columns.

___________________________ method is used to append the


313 1 N R 1 append ()
string str to end of the current text.

______________________________method is used to add a tab to


314 1 N R 1 addTab ()
the pane.

315 ………….are responsible for placing components on a window 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

Most Swing components are __________ components because they


318 1 N R 1 lightweight
are rendered and drawn entirely by Java code.

Figure:-

public class HelloSwing { public HelloSwing() { JLabel l1 = new JLabel("User


Name"); JLabel l2 = new JLabel("Password"); JTextField t1 = new
319 1 Y1 A 2
JTextField(); JTextField t2 = new JTextField(); JButton b1 = new
JButton("Submit"); JBut

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

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

//Find out the error. import javax.swing.JFrame; import


javax.swing.JTree; import javax.swing.SwingUtilities; import
javax.swing.tree.DefaultMutableTreeNode; public class TreeExample
extends JApplet { JTree tree; public void init() {
DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root");
322 DefaultMutableTreeNode vegetableNode = new 1 N A 2 Error in statement in which JTree is created
DefaultMutableTreeNode("Vegetables"); DefaultMutableTreeNode
fruitNode = new DefaultMutableTreeNode("Fruits");
root.add(vegetableNode); root.add(fruitNode); tree = new JTree();
add(tree); } } /*<applet code=”TreeExample” width=300 height=300>
</applet>*/

//Identify the correct output for the given code. import java.awt.*;
import java.applet.*; /*<aaplet code="LabelDemo" width=300
height=200></applet>*/ public class MyApplet extends Applet { public
323 1 Y2 A 2
void init() { Label one = new Label("One"); Button submit = new
Button("Submit"); TextField enter = new TextField(); add(one);
add(submit); add(enter); } }

//Identify the error import java.awt.*; import javax.swing.*; /*<applet


code="JTableDemo" width=400 height=200></applet>*/ public class
JTableDemo extends JApplet { public void init() { Container
contentPane = getContentPane(); contentPane.setLayout(new
BorderLayout()); final String[] colHeads = { "Roll No", "Name", "Branch"
324 }; final Object[][] data = { { “11”,"Mayur", “CO” }, { “22”,"Ritesh", “IF” 1 N A 2 Error in statement in which JTable is created
}, { "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); } }

//Select the correct option for the following code. import java.awt.*;
import java.applet.*; import java.awt.event.*; /*<applet
code=scrolldemo width=200 height=300> </applet>*/ public class
scrolldemo extends Applet implements AdjustmentListener { Scrollbar
s1,s2,s3; TextField r,g,b; Color c; public void init() { s1=new
Scrollbar(Scrollbar.HORIZONTAL,0,0,0,256); s2=new
Scrollbar(Scrollbar.HORIZONTAL,0,0,0,256); s3=new
Scrollbar(Scrollbar.HORIZONTAL,0,0,0,256); r=new TextField(5); g=new
325 TextField(5); b=new TextField(5); add(s1); add(r); add(s2); add(g); 1 N A 2 background with combination of r,g and b.
add(s3); add(b); s1.addAdjustmentListener(this);
s2.addAdjustmentListener(this); s3.addAdjustmentListener(this); }
public void adjustmentValueChanged(AdjustmentEvent ae) {
r.setText(Integer.toString(s1.getValue()));
g.setText(Integer.toString(s2.getValue()));
b.setText(Integer.toString(s3.getValue())); c=new
Color(s1.getValue(),s2.getValue(),s3.getValue()); setBackground(c); }
}

1. Which components are used in the following output?


Figure:-

326 1 Y1 U 2 Label, TextField, Button

1.import java.awt.*; 2.import java.applet.*; 3.public class sample3


extends Applet 4.{ 5.public void init() 6.{ 7.Choice country=new
327 Choice(); 8.country.add("india"); 9.country.add("america");
1 N A 2 Line number 10
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;
7.c1=new Checkbox("maths",true); 8.c2=new
328 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. }

1.Which is missing statement in following program? import java.awt.*;


import java.applet.*; import java.util.*; /* <applet
code="BorderLayoutDemo" width=400 height=200> </applet> */
public class BorderLayoutDemo extends Applet { public void init() {
329 add(new Button("north."),BorderLayout.NORTH); add(new 1 N A 2 setLayout(new BorderLayout()
Button("south"),BorderLayout.SOUTH); add(new Button("Right"),
BorderLayout.EAST); add(new Button("Left"), BorderLayout.WEST);
String msg = "this is in center"; add(new TextArea(msg),
BorderLayout.CENTER); } }

2. Consider the following program. Find which statement contains


error.importjava.awt.*; import javax.swing.*; /* <applet
code="JTableDemo" width=400 height=200> </applet> */ public class
JTableDemo extends JApplet { public void init() { Container
contentPane = getContentPane(); contentPane.setLayout(new
BorderLayout()); final Object[][] data = { { "Ramesh", "111", "50000"
330 }, 15 { "Sagar", "222", "52000" }, { "Virag", "333", "40000" }, { 1 N A 2 A. Error in statement in which JTable is created
"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. What is the purpose of JTable? 1 N U 2 JTable object displays rows and columns of data.

2.What should be written in blank space. import java.awt.*; import


java.awt.event.*; import java.applet.*; /* <applet code="CBGroup"
width=250 height=200> </applet> */ public class CBGroup extends
Applet { String msg = ""; Checkbox Win98, winNT; CheckboxGroup
332 cbg; public void init() { cbg = new CheckboxGroup(); Win98 = new 1 N A 2 cbg
Checkbox("Windows 98/XP", , true); winNT = new Checkbox("Windows
NT/2000", , false); add(Win98); add(winNT);
Win98.addItemListener(this); winNT.addItemListener(this); } }

3. Observe the following code and find which statement contains


error.import java.awt.*; import javax.swing.*; import
java.awt.event.*; import java.applet.*; import javax.swing.event.*;
public class ttp extends JApplet implements ActionListener { JButton
333 jb=new JButton("click me"); JTextField text=new JTextField(20); public 1 N A 2 C.Error in adding and registering listener to the component.
void init() { Container cp=getContentPane(); cp.setLayout(new
FlowLayout()); jb.setToolTipText("this is button control"); add(jb);
add(text); text.addActionListener(this); } public void
actionPerformed(ActionEvent e) { text.setText("hello tyco"); } }

3. Select the proper command to run the following code import


java.awt.*; import java.awt.event.*; import javax.swing.*; import
java.applet.*; /* <applet code="combodemo11" width=300
height=100> </applet> */ public class combodemo11 extends JApplet
334 1 N A 2 appletviewer combodemo11.java
{ public void init() { Container co = getContentPane();
co.setLayout(new FlowLayout()); JComboBoxjc=new JComboBox();
jc.addItem("cricket"); jc.addItem("football"); jc.addItem("hockey");
jc.addItem("tennis"); co.add(jc); } }

4.To create a Following output which control is required.


Figure:-

335 1 Y1 U 2 2 Label, 1 Button

A JFrame supports three operations when the user closes the window.
336 1 N U 2 LOWER_ON_CLOSE
Which of the choices below is not one of the three:

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

A Swing component can be viewed based on what state it’s in, how it
338 looks, and what it does. This is known as the model-view- __________ 1 N U 2 Controller
model.

A toggle button looks just like a push button, but it acts differently
339 1 N U 2 it has two states: enabled and disabled
because _________________________..

. import java.awt.*; import java.applet.*; /*&lt;applet


code=&quot;Demo.class&quot;width=200 height=200&gt;*/ public class Demo
extends Applet { public void init(){ MenuBar mbr=new MenuBar(); setMenuBar(mbr);
A user want’s to create an Applet with menubar consisting three menu
340 1 N A 2 Menu m=new Menu(“File”); MenuItem i1=new MenuItem(“New”); MenuItem i2=new
items and one checkable menu item select correct coding?
MenuItem(“Run”); MenuItem i3=new MenuItem(“build”); CheckboxMenuItem i4=new
CheckboxMenuItem(&quot;hello&quot;): m.add(i1); m.add(i2); m.add(i3); m.add(i4);
mbr.add(m); add(mbr); } }

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

An Applet has its Layout Manager set to the default of FlowLayout.


342 What code would be the correct to change to another Layout 1 N A 2 setLayout(new GridLayout(2,2));
Manager?

Analyse the following code import javax.swing.*; Import


javax.swing.border.*; Import java.awt.*; Public class Test extends
JFrame { Public Test() { Border border=new TitledBorder(“My button”);
Jbutton jbt1=new JButton(“OK”); Jbutton jbt=new JButton(“Cancel”);
Jbt1.setBorder(border); Jbt2.setBorder(border);
343 1 N A 2 The program has compile error.
Add(jbt1,BorderLayout.NORTH); Add(jbt2,BorderLayout.NORTH); }
Public static void main(String[] args){ JFrame frame=new Test();
Frame.setSize(200,100);
Frame.setDefaultCloseOperation(JFrame.ExIT_ON_CLOSE);
Frame.setVisible(true); } }

Analyse the following code? import javax.swing.*; import java.awt.*;


public class Test extends JFrame { public Test() { setLayout(new
FlowLayout()); add(new JButton("Java")); add(new JButton("Java"));
add(new JButton("Java")); add(new JButton("Java")); } public static
344 1 N A 2 Four buttons are displayed with the same text &quot;Java&quot;
void main(String [] args) { JFrame frame = new Test();
frame.setSize(200,100);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true); } }

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


345 1 N U 2 B.CardLayout
component is visible at a time

Below show the figure matches with respect to output


Figure:-

import java.awt.*; import java.applet.*; /*&lt;applet code=&quot;Border.class&quot;


width=300 height=300&gt; */ public class Border extends Applet{ public void init() {
BorderLyout br=new BorderLayout(); setLayout(br); Button b1=new
Button(&quot;NORTH&quot;); Button b2=new Button(&quot;SOUTH&quot;); Button
346 1 Y1 A 2 b3=new Button(&quot;EAST&quot;); Button b4=new Button(&quot;WEST&quot;);
Button b5=new Button(&quot;CENTER&quot;); add(b1,BorderLayout.NORTH);
add(b2,BorderLayout.SOUTH); add(b3,BorderLayout.EAST);
add(b4,BorderLayout.WEST); add(b5,BorderLayout.CENTER); } }

347 Button control implements following Listener interface? 1 N A 2 ActionListener

348 By which method You can set or change the text in a Label? 1 N U 2 setText()

Choose correct sequence of code for given output


Figure:-

import java.awt.*; import java.applet.*; /*&lt;applet code=&quot;expe2.class&quot;


width=300 height=300&gt;*/ public class expe2 extends Applet { Button lbl; Button
349 1 Y1 A 2 lbl1; Button lbl2; public void init() { setLayout(new FlowLayout(FlowLayout.RIGHT));
lbl=new Button(&quot;OK&quot;); lbl1=new Button(&quot;Cancle&quot;); lbl2=new
Button(&quot;Exit&quot;); add(lbl); add(lbl1); add(lbl2); } }

Choose missing statements in following code from given options.


import java.awt.*; import java.applet.*; /* <applet code="Ellipses"
350 width=300 height=200> </applet> */ public class Ellipses extends 1 N A 2 public void paint(Graphics g)
Applet { { g.drawOval(10, 10, 50, 50); g.fillOval(100, 10, 75, 50);
g.drawOval(190, 10, 90, 30); g.fillOval(70, 90, 140, 100); } }

Choose the correct code to display the following output.


Figure:-

import javax.swing.*; import java.awt.*; /*&lt;applet


code=&quot;DemoApplet.class&quot; width=300 height=300&gt;*/ public class
DemoApplet extends JApplet { JScrollPane jsp; JTable table; Container c; public void
init() { c = this.getContentPane(); this.setLayout(new BorderLayout()); final String
colhead[]={&quot;Name&quot;,&quot;Address&quot;,&quot;Contact&quot;); final
351 1 Y1 A 2 Object data[][]={ {&quot;abc&quot;,&quot;pune&quot;,&quot;123&quot;},
{&quot;pqr&quot;,&quot;mumbai&quot;,&quot;456&quot;},
{&quot;xyz&quot;,&quot;nagpur&quot;,&quot;789&quot;}}; table=new
JTable(data,colhead); int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED; jsp=new
JScrollPane(table,v,h); c.add(jsp,BorderLayout.CENTER); } }
Choose the correct missing statement from the given code import
java.awt.*; import java.io.*; import java.awt.event.*; import
java.applet.*; class Myframe extends Frame { Myframe(String title) {
super(title); } public void paint(Graphics g) { g.drawString("This is
frame window",120,150); } } public class Myframeapplet extends
Applet //implements windowListener { public void init() { f1=new
352 1 N A 2 Myframe f1;
Myframe("Frame window"); f1.setSize(350,350);
//f1.setLocation(450,450); f1.setVisible(true);
//f1.addwindowListener(this); } public void start() { f1.setVisible(true);
} public void stop() { f1.setVisible(false); } public void paint(Graphics
g) { g.drawString("This ia a applet window",10,50); } } /*<applet
code="Myframeapplet" width=1000 height=1000> </applet>*/

Choose the correct Program for the following output


Figure:-

import java.applet.Applet; import java.awt.Color; import javax.swing.JFrame; import


javax.swing.JScrollPane; import javax.swing.JTable; public class myjtable extends
353 1 Y1 A 2
Applet { public void init() { String[] columns = new String[] {&quot;Id&quot;,
&quot;Name&quot;, &quot;Hourly Rate&quot;,&quot;Part Time&quot;}; } }

Choose the correct Program for the following output


Figure:-

import java.awt.*;import java.applet.*; //&lt;applet code=&quot;FontColor&quot;


width=200 height=200&gt; //&lt;/applet&gt; public class FontColor extends Applet {
354 1 Y1 A 2 Font f=new Font(&quot;Times New Roman&quot;,Font.ITALIC,14); public void init() {
setFont(f); } public void paint(Graphics g) { g.setColor(Color.red);
g.drawString(&quot;Hello Java&quot;,150,100); } }

Choose the correct Program for the following output import javax.swing.JFrame; import javax.swing.JTree; import
javax.swing.SwingUtilities; import javax.swing.tree.DefaultMutableTreeNode; public
Figure:-
class TreeExample extends JFrame { private JTree tree; public TreeExample() {
//create the root node DefaultMutableTreeNode root = new
DefaultMutableTreeNode(&quot;Root&quot;); //create the child nodes
DefaultMutableTreeNode vegetableNode = new
DefaultMutableTreeNode(&quot;Vegetables&quot;); DefaultMutableTreeNode
355 1 Y1 A 2
fruitNode = new DefaultMutableTreeNode(&quot;fruits&quot;); //add the child nodes
to the root node root.add(vegetableNode); root.add(fruitNode); //create the tree by
passing in the root node tree = new JTree(root); add(tree);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setTitle(&quot;JTree
Example&quot;); this.pack(); this.setVisible(true); } public static void main(String[]
args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new
TreeExample(); } }); } }

Choose the correct programto get the following output


Figure:-

import java.awt.*; import javax.swing.*; import java.applet.*; /* &lt;applet


code=&quot;ComboDemo11&quot; width=300 height=100&gt; &lt;/applet&gt; */
public class ComboDemo11 extends JApplet { public void init() { setLayout(null);
356 1 Y1 A 2
Container co = getContentPane(); String sports[]=
{&quot;cricket&quot;,&quot;football&quot;,&quot;hockey&quot;,&quot;tennis&quot;};
JComboBox cb=new JComboBox(sports); cb.setBounds(50, 50,90,20); co.add(cb); } }

Choose the correct sequence for the following output


Figure:-

import java.applet.*; import java.awt.*; public class RadioButton1 { public static void
main(String arg[]) { Frame fm=new Frame(&quot;RedioButton Group&quot;); Label
la=new Label(&quot;What is your choice:&quot;); fm.setLayout(new GridLayout(0,1));
CheckboxGroup cg1=new CheckboxGroup(); fm.add(la); Checkbox cb1=new
357 1 Y1 U 2 Checkbox(&quot;MATH&quot;,cg1,true); Checkbox cb2=new
Checkbox(&quot;PHYSICS&quot;,cg1,false); Checkbox cb3=new
Checkbox(&quot;CHEMISTRY&quot;,cg1,false); Checkbox cb4=new
Checkbox(&quot;ENGLISH&quot;,cg1,false); fm.setVisible(true); fm.add(la);
fm.add(cb1); fm.add(cb2); fm.add(cb3); fm.add(cb4); } }

Choose the correct sequence for the following output


Figure:-

import java.awt.*; import java.applet.*; /* &lt;applet code=&quot;Appl&quot;


width=200 height=200&gt; &lt;/applet&gt;*/ public class Appl extends Applet { public
358 1 Y1 A 2
void init() { Button b1=new Button(&quot;Button 1&quot;); TextField tf = new
TextField(); TextArea t1=new TextArea(3,20); Choice ch=new Choice();
ch.add(&quot;India&quot;); Checkbox c=new Checkbox(&quot;a&quot;,true);
add(b1); add(tf); add(t1); add(c); add(ch); } }

Choose the correct sequence for the following output


Figure:-

import java.awt.*; import java.applet.*; /* &lt;APPLET


Code=&quot;CheckboxTest&quot; Width=500 Height=200&gt; &lt;/APPLET&gt; */
public class CheckboxTest extends Applet { public void init( ) { Checkbox cb1=new
359 1 Y1 A 2
Checkbox(&quot;Shoes&quot;); Checkbox cb2=new
Checkbox(&quot;Socks&quot;,true); Checkbox cb3=new
Checkbox(&quot;Shirt&quot;); add(cb1); add(cb2); add(cb3); } }

Choose the correct sequence for the following output


Figure:-

import java.awt.*; import java.applet.*; /* &lt;applet code=&quot;LabelDemo&quot;


width=300 height=300&gt;&lt;/applet&gt; */ public class LabelDemo extends Applet {
360 1 Y1 A 2 public void init() { Label one = new Label(&quot;One&quot;); Label two = new
Label(&quot;Two&quot;); Label three = new Label(&quot;Three&quot;);
add(one);add(two);add(three); } }

Choose the correct sequence for the following output


Figure:-
import java.awt.*; import java.applet.*; public class appl extends Applet { public void
init() { TextField tf = new TextField(); TextArea t1=new TextArea(3,20); Checkbox
361 1 Y1 A 2 c=new Checkbox(&quot;a&quot;,true); Checkbox c1=new
Checkbox(&quot;b&quot;,false); add(tf); add(t1); add(c); add(c1); } } /*&lt;applet
code=&quot;appl&quot; width=300 height=300&gt; &lt;/applet&gt; */

Choose the correct sequence for the following output


Figure:-

import java.awt.*; import java.applet.*; public class test11 extends Applet { public
void init() { TextField t1=new TextField(20); Checkbox c=new
362 1 Y1 A 2
Checkbox(&quot;a&quot;, true); Checkbox c1=new Checkbox(&quot;b&quot; , false);
add(t1); add(c); add(c1); } }

Choose the correct sequence for the following output


Figure:-

importjava.awt.*; importjava.applet.*; public class app1 extends Applet { public void


init() { TextFieldtf = new TextField(); TextArea t1=new TextArea(3,20); Checkbox
363 1 Y1 A 2
c=new Checkbox(&quot;a&quot;,true); Checkbox c1=new
Checkbox(&quot;b&quot;,false); add(tf); add(t1); add(c); add(c1); }

Choose the correct sequence for the following output


Figure:-
364 1 Y1 A 2 Label,TextField,Label,Button

Choose the correct sequence for the following output.


Figure:-

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


width=400 height=200&gt; &lt;/applet&gt;*/ public class Login extends Applet {
TextField nm; TextField psw; public void init() { Label nml = new
365 1 Y1 A 2 Label(&quot;USername:&quot;, Label.RIGHT); Label pswl =new
Label(&quot;Password:&quot;, Label.RIGHT); nm=new TextField(12); psw = new
TextField(12); Button b=new Button(&quot;Submit&quot;); add(nml); add(nm);
add(pswl); add(psw); add(b); } }

class Fr { public static void main(String ar[]) { JFrame f = new JFrame();


366 1 N A 2 disposes frame
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);}}

class Frame{ Frame(){ } } class VFrame extends Frame { VFrame(){


367 1 N A 2 Class VFrame’s constructor includes a call to super().
super(); } } Which statement are true?

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

Consider following output. Find the missing statement in the following


program to get above output. import java.awt.*; class AWTMenu
extends Frame { public static void main(String args[]) { AWTMenu
m=new AWTMenu(); m.setVisible(true); MenuBar mb=new MenuBar();
m.setMenuBar(mb); Menu hmenu= new Menu("Help"); Menu
jmenu=new Menu("Justify"); mb.add(hmenu); MenuItem center=new
MenuItem("Center"); MenuItem left=new MenuItem("Left"); MenuItem
right=new MenuItem("Right"); jmenu.add(center); jmenu.add(left);
jmenu.add(right); } }
Figure:-
369 1 Y1 U 2 mb.add(jmenu);

Consider following output.Identify controls used.


Figure:-

370 1 Y1 U 2 Checkbox,TextArea,Button,Label

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

Consider following program and state how meny main menu and sub
menu displayed in output: import java.awt.*; public class MenuDemo {
public static void main(String args[]) { Frame f=new Frame("My
Frame"); f.setVisible(true); MenuBar mbr= new MenuBar();
f.setMenuBar(mbr); Menu filemenu=new Menu("File"); Menu
372 editmenu=new Menu("Edit"); Menu viewmenu=new Menu("View"); 1 N A 2 3 Main,3 Sub menu
mbr.add(filemenu); mbr.add(editmenu); mbr.add(viewmenu);
MenuItem new1=new MenuItem("New"); MenuItem open1=new
MenuItem("Open"); filemenu.add(new1); filemenu.add(open1);
new1.setEnabled(false); CheckboxMenuItem wordwrap=new
CheckboxMenuItem("WordWrap"); editmenu.add(wordwrap); }

Consider following program.Select the missing statement from options.


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

Consider the following program What will be displayed in the output?


import java.awt.*; import javax.swing.*; /* <applet
code="JTabbedPaneDemo" width=300 height=100> </applet> */
public class JTabbedPaneDemo extends JApplet { public void init() {
JTabbedPane jtp=new JTabbedPane(); jtp.addTab("Fruit",new
FruitPanel()); jtp.addTab("Color",new ColorPanel());
jtp.addTab("Vegitables",new VegitablePanel());
getContentPane().add(jtp); jtp.removeAll(); } } class FruitPanel
374 extends JPanel { public FruitPanel() { JButton b1=new 1 N A 2 Applet without any controls.
JButton("Apple"); add(b1); JButton b2=new JButton("Mango");
add(b2); JButton b3=new JButton("Banana"); add(b3); } } class
ColorPanel extends JPanel { public ColorPanel() { JButton b1=new
JButton("Red"); add(b1); JButton b2=new JButton("Blue"); add(b2);
JButton b3=new JButton("Green"); add(b3); } } class VegitablePanel
extends JPanel { public VegitablePanel() { JButton b1=new
JButton("Potato"); add(b1); JButton b2=new JButton("Brinjal");
add(b2); JButton b3=new JButton("Tomato"); add(b3); } }

Consider the following program Which statemnet is prepare for blank


space import java.applet.*; import java.awt.*; public class gridlayout
375 extends Applet { int n=1; public void init() { setFont(new 1 N A 2 add(new Button(&quot;&quot;+n));
Font("SansSerif",Font.BOLD,24)); for(int i=0;i<5;i++) { for(int
j=0;j<5;j++) { ______________________ n++; } } } }

Consider the following program. What should be the correction done in


the program to get correct output? import java.awt.*; import
java.swing.*; /* <applet code="JComboBoxDemo" width=300
376 height=100> </applet> */ public class JComboBoxDemo extends 1 N A 2 package not imported correctly
JApplet { JComboBox jcb; String flags[] = { "France", "Germany",
"Italy", "Japan" }; public void init() { jcb = new JComboBox(flags);
add(jcb); } }

Consider the following program. Find the error. import java.awt.*;


import java.applet.*; import java.awt.event.*; /*<applet code=demo
width=100 height=100> </applet> */ public class demo extends
377 1 N A 2 All of above
Applet { public void init() { firstlabel =new Label("Label 1");
secondlabel =new Label("Label 2"); b1=new Button("Enter"); add(l1);
add(l2); add(b1); } }

Consider the following program. Find which missing statement. import


java.awt.*; import javax.swing.*; import javax.swing.tree.*; /*<applet
code="JTreeDemo.class" width=400 height=300> </applet> */ public
class JTreeDemo extends JApplet { public void init(){ Container
contentPane = getContentPane(); contentPane.setLayout(new
BorderLayout()); DefaultMutableTreeNode a = new
DefaultMutableTreeNode("CO5G"); top.add(a);
DefaultMutableTreeNode a1 = new DefaultMutableTreeNode("JPR");
a.add(a1); DefaultMutableTreeNode a2 = new
DefaultMutableTreeNode top = new DefaultMutableTreeNode (&quot;Third Year
378 DefaultMutableTreeNode("SWE"); a.add(a2); DefaultMutableTreeNode 1 N A 2 Computer Engineering&quot;);
b = new DefaultMutableTreeNode("CO6G"); top.add(b);
DefaultMutableTreeNode b1 = new DefaultMutableTreeNode("AJP");
b.add(b1); DefaultMutableTreeNode b2 = new
DefaultMutableTreeNode("MAN"); b.add(b2); JTree tree = new
JTree(top); int v =
ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS; int h =
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS; JScrollPane
jsp = new JScrollPane(tree, v, h); contentPane.add(jsp,
BorderLayout.CENTER); } }

Consider the following program. Find which statement contains error.


import java.awt.*; import java.applet.*; /* <applet
code="CheckboxDemo" width=250 height=200> </applet> */ class
CheckboxDemo extends Applet { Checkbox winXP, winVista, solaris,
379 1 N A 2 Class should not be public.
mac; public void init() { winXP = new Checkbox("Windows XP", null,
true); winVista = new Checkbox("Windows Vista"); solaris = new
Checkbox("Solaris"); mac = new Checkbox("Mac OS"); add(winXP);
add(winVista); add(solaris); add(mac); } }

Consider the following program. Find which statement contains error.


import java.awt.*; import javax.swing.*; public class Demo { public
static void main(String args[]) { JFrame f =new JFrame("Toggle Button
Sample"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c=f.getContentPane(); c.add(new
380 JToggleButton("North"),BorderLayout.NORTH); c.add(new 1 N A 2 No error.
JToggleButton("North"),BorderLayout.EAST); c.add(new
JToggleButton("North"),BorderLayout.WEST); c.add(new
JToggleButton("North"),BorderLayout.SOUTH); c.add(new
JToggleButton("North"),BorderLayout.CENTER); f.setSize(300,300);
f.setVisible(true); } }

Consider the following program. Find which statement contains error.


import java.awt.*; import javax.swing.*; /* <applet
code="JTableDemo" width=400 height=200> </applet> */ public class
JTableDemo extends JApplet { public void init() { Container
contentPane = getContentPane(); contentPane.setLayout(new
BorderLayout()); final String[] colHeads = { "emp_Name", "emp_id",
"emp_salary" }; final Object[][] data = { { "Ramesh", "111", "50000"
381 }, { "Sagar", "222", "52000" }, { "Virag", "333", "40000" }, { "Amit", 1 N A 2 Error in statement in which JTable is created
"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); } }

Consider the following program. Find which statement contains error.


import java.applet.Applet; import java.awt.*; public class ButtonTest2
extends Applet { public void init() { String[] labelPrefixes = { "Start",
382 "Stop", "Pause","Resume" }; Panel p1 = new Panel(); for (int i=0; i<4; 1 N A 2 Error in the statement creating panel object
i++) { p1.add(new Button(labelPrefixes[i] + " Thread1")); } Panel p2 =
Panel(); for (int i=0; i<4; i++) { p2.add(new Button(labelPrefixes[i] + "
Thread2")); } add(p1); add(p2); } }

Consider the folowing code.Select the proper scrollbar constant for


blank line in code . import javax.swing.*; import java.applet.*; import
java.awt.*; /* <applet code="ScrollDemo" width=300 height=100>
</applet> */ public class ScrollDemo extends JApplet { public void init()
383 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_ALWAYS;
JScrollPane jsp=new JScrollPane(ja,v,h);
cp.add(jsp,BorderLayout.CENTER); } }

Debug the following code and find out which statement contains error.
import java.awt.*; import java.awt.event.*; public class MenuDemo
extends Frame { MenuBar mb; Menu m1,m2; MenuItem i1,i2,i3,i4,i5,i6;
MenuDemo(String s) { super(s); mb=new MenuBar(); setMenuBar();
m1=new Menu("File"); m2=new Menu("Edit"); i1=new
MenuItem("New"); i2=new MenuItem("Open"); i3=new
384 1 N A 2 statement where setMenuBar() method is invoked
MenuItem("Exit"); i4=new MenuItem("Cut"); i5=new
MenuItem("Copy"); i6=new MenuItem("Paste"); m1.add(i1);
m1.add(i2); m1.add(i3); m2.add(i4); m2.add(i5); m2.add(i6);
mb.add(m1); mb.add(m2); setSize(500,500); } public static void
main(String args[]) { MenuDemo m=new MenuDemo("MenuFrame");
m.setVisible(true); } }

Debug the following code and find which statement contains error.
import javax.swing.*; import java.awt.*; public class
JRadioButtonDemo extends JApplet { JRadioButton r1,r2,r3; Container
c; public void init() { c=getContentPane(); c.setLayout(new
FlowLayout()); r1=new JRadioButton("Red"); r2=new
385 1 N A 2 Error in statement to create button group i.e. JRadioButtonGroup
JRadioButton("Green"); r3=new JRadioButton("Blue");
JRadioButtonGroup b=new JRadioButtonGroup ();
b.add(r1);b.add(r2);b.add(r3); c.add(r1);c.add(r2);c.add(r3); } } /*
<applet code=JRadioButtonDemo.class width=500 height=500>
</applet>*/

Dectate Error in folloing code , Specify line number if any; 1. import


java.applet.*; 2. import java.awt.*; 3. import java.swing.*; 4. public
386 class S1Q 5. { 6. public static void main(String[] args) 7. { 8. JFrame 1 N A 2 Line number 10 and 3
frame = new JFrame("Hello Swing"); 9. frame.setSize(200,200); 10.
frame.setVisible(); 11. } 12. }

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

Fill in the blanks so that the following draws a Frame containing


"Hello". import java.awt.*; class HelloFrame ___________ Frame {
public void ___________( Graphics g ) { g.___________("Hello", 10,
388 1 N A 2 extends, paint, drawString
50 ); } } public class Tester { public static void main ( String[] args ) {
helloFrame frm = new helloFrame(); frm.setSize( 150, 100 );
frm.setVisible( true ); } }

Fill in the blanks so that this program displays a Frame: import


java.awt.*; public class microGUI { public static void main ( String[]
389 1 N A 2 Frame, setSize, setVisible
args ) { Frame frm = new ___________(); frm.___________( 150, 100
); frm.___________( true ); } }

Find error from following code import java.awt.*; import


java.awt.event.*; import javax.swing.*; import javax.swing.tree.*; /*
<applet code="JTreeEvents" width=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
DefaultMutableTreeNode("A"); top.add(a); DefaultMutableTreeNode a1
= new DefaultMutableTreeNode("A1"); a.add(a1);
390 DefaultMutableTreeNode a2 = new DefaultMutableTreeNode("A2"); 1 N A 2 contentPane must be object of Container class
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); }}

Find error in following code. import java.awt.*; import java.applet.*;


public class ChoiceDemo extends Applet { Choice os; String msg = "";
391 1 N A 2 applet code is missing
public void init() { os = new Choice(); // add items to os list
os.add("Windows 98/XP"); os.add("Windows NT/2000"); add(os); } }

Find missing statement from given code: public class ButtonLabelDemo


extends Applet { Label l1,l2; Button b1; public void init() { ** ** **
//Adding the controls to the applet add(l1); add(l2); add(b1); } }
Figure:-

l1=new Label(&quot;one&quot;); l2=new Label(&quot;two&quot;); b1=new


392 1 Y1 A 2
Button(&quot;OK&quot;);

find out missing line in following code. Import java.awt.*; import


java.swing.* public class demo2 extends JApplet { JRadioButton
393 b1=new JRadioButton("Buuton1') ; JRadioButton b2=new 1 N U 2 Container cp=getContentPane()
JRadioButton("Button2"); public void init() { cp.add(b1); cp.add(b2);
ButtonGroup bg=new ButtonGroup(); bg.add(b1); bg.add(b2); } }

Find out missing statement in following code: import java.awt.*; import


java.applet.*; /* <applet code=exp4.class width=200 height=200>
</applet> */ public class exp4 extends Applet { List l1,l2; public void
394 1 N A 2 add(l1); add(l2);
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"); } }

Find the error in the following code. import java.awt*; import


java.awt.event.*; import java.applet.*; public class RadioDemo
395 extends JApplet { public void init() { Container c=getContentPane(); 1 N A 2 A and B
JRadioButton b1=new JRadioButton("Red"); JRadioButton b2=new
JRadioButton("Blue"); c.add(b1); c.add(b2); } }

Find the error. /*<applet code="MyJTabbedPane" width=900


height=900> </applet>*/ import java.awt.*; import javax.swing.*;
public class MyJTabbedPane extends JApplet { public void init() {
396 Container c=getContentPane(); c.setLayout(new FlowLayout()); 1 N A 2 b)JTabPane Constructor is incorrect
JTabPane jtp=new JTabPane(); jtp.addTab("Cities",new CitiesPanel());
jtp.addTab("Colors",new ColorsPanel()); jtp.addTab("Flavours",new
FlavoursPanel()); c.add(jtp); }}

Find the missing statement from the following program. import


java.awt.*; import java.awt.event.*; import javax.swing.*; import
java.applet.*; /* <applet code="ctest" width=300 height=100>
</applet> */ public class ctest extends JApplet { public void init() {
Container co = getContentPane(); co.setLayout(new FlowLayout());
JComboBox jc=new JComboBox(); jc.addItem("cricket");
jc.addItem("football"); jc.addItem("hockey"); jc.addItem("tennis"); } }
Figure:-

397 1 Y1 U 2 Missing add statement

Find the missing statement in the following code import java.awt.*;


class MenuDemo extends Frame { MenuDemo() { MenuBar mb=new
MenuBar(); Menu file =new Menu(“File”); MenuItem open=new
398 MenuItem(“Open”); MenuItem save=new MenuItem(‘Save”); 1 N A 2 setMenuBar(mb);
file.add(open); file.add(save); mb.add(file); } public static void
main(String args[]) { MenuDemo md=new MenuDemo();
md.setSize(400,400); md.setLocation(10,10); md.setVisible(true); } }

Find the missing statement. import javax.swing.*; class MyFrame


extends JFrame { public MyFrame() { setTitle("My Empty Frame");
399 1 N U 2 public static void main(String[] args)
setSize(300,200); setLocation(10,200); } JFrame f = new MyFrame();
f.show(); }

find the ouptut of the following : import javax.swing.*; class Demo


extends JApplet { public void init() { JTabbedPane jt=new
400 1 Y2 A 2 S1Q43O1
JTabbedPane(); jt.addTab(“Tab 1”,new JButton());
getContentPane().add(jt); } }

Following program output display which type of layout manager :


import java.awt.*; import java.applet.*; import java.awt.event.*; /*
<applet code=cl.class width=200 height=200> </applet> */ public
class cl extends Applet { CardLayout cardLayout; Panel panel; Button
button1, button2, button3; public void init() { panel = new Panel();
401 1 N A 2 CardLayout
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 following outputs which program code is correct


Figure:-
import java.awt.*; class Demo3 extends Frame { Button b; Demo3() { setLayout(new
402 1 Y1 A 2
GridLayout(5,3)); for(int i=0;i&lt;15;i++) { add(new Button(String.valueOf(i))); }
setSize(800,600); } public static void main(String args[]) throws Exception { new
Demo3().setVisible(true); } }

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

404 From following list Which is not Swing class? 1 N U 2 JImageIcon

Give proper command to compile & run following program code? import
java.applet.*; import java.awt.*; /* <applet code="A1" height="300"
405 width="300"> </applet> */ public class A1 extends Applet { public void 1 N A 2 C:\javac A1.java C:\appletviewer A1.java
paint(Graphics gr) { gr.drawString("Welcome to JAVA ",50,100);
setBackground(Color.cyan); } }

Given the following code import java.awt.*; public class SetF extends
Frame { public static void main(String argv[]) { SetF s = new SetF();
406 1 N A 2 s.setBackground(Color.pink);
s.setSize(300,200); s.setVisible(true); } } How could you set the frame
surface color to pink

How many components are used for form validation i.e input username
407 1 N U 2 2 Label,1 Button,2 Textfield
and password

How many controls are shown on Applet after executing following


program import java.awt.*; import java.awt.event.*; import
java.applet.*; /* <applet code="app2.class" height=100 width=200>
</applet>*/ public class app2 extends Applet { Checkbox cb1,cb2;
408 1 N U 2 3
TextField tf1; String str,str1; public void init() { Label c=new
Label("COLORS"); cb1=new Checkbox(); cb2=new
Checkbox("WHITE"); 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 JButton(“ok”,ii);

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

Identify components used


Figure:-

411 1 Y1 A 2 JButton,ScrollPane
Identify controls used in following output
Figure:-

412 1 Y1 U 2 TextFiled and Scrollbars

Identify default output for given code import java.awt.event.*; import


java.applet.*; public class FlowLayoutDemo extends Applet implements
ItemListener { String msg = ""; Checkbox Win98, winNT, solaris, mac;
public void init() { setLayout(new FlowLayout(FlowLayout.LEFT));
Win98 = new Checkbox("Windows 98/XP", null, true); winNT = new
Checkbox("Windows NT/2000"); solaris = new Checkbox("Solaris", null,
true); mac = new Checkbox("MacOS"); add(Win98); add(winNT);
add(solaris); add(mac); Win98.addItemListener(this);
413 1 Y2 A 2 S1Q45O4
winNT.addItemListener(this); solaris.addItemListener(this);
mac.addItemListener(this); } public void itemStateChanged(ItemEvent
ie) { repaint(); } public void paint(Graphics g) { msg = "Current state:
"; g.drawString(msg, 6, 80); msg = " Windows 98/XP: " +
Win98.getState(); g.drawString(msg, 6, 100); msg = " Windows
NT/2000: " + winNT.getState(); g.drawString(msg, 6, 120); msg = "
Solaris: " + solaris.getState(); g.drawString(msg, 6, 140); msg = " Mac:
" + mac.getState(); g.drawString(msg, 6, 160); } }

Identify layout used in the output given below.


Figure:-

414 1 Y1 U 2 GridLayout

415 Identify proper syntax from following options of TextArea constructor 1 N U 2 TextArea(int numlines, int numChars)
Identify the code for the output given below.
Figure:-

import java.awt.*;import javax.swing.*;public class Demo extends JApplet{ JButton


b1,b2; JCheckBox cb1,cb2; public void init() { Container c=getContentPane();
c.setLayout(new FlowLayout()); cb1=new JCheckBox(&quot;Red&quot;, true);
416 1 Y1 A 2
cb2=new JCheckBox(&quot;Blue&quot;, false); b1=new
JButton(&quot;Submit&quot;);b2=new
JButton(&quot;Reset&quot;);c.add(cb1);c.add(cb2);c.add(b1);c.add(b2);} }

Identify the components required to design this applet window shown


in image?
Figure:-

417 1 Y1 A 2 Label, Button, TextField, Checkbox, CheckboxGroup

Identify the correct code for following output.


Figure:-

import java.awt.*; public class MenuDemo extends Frame { MenuDemo() { MenuBar


mbr = new MenuBar(); setMenuBar(mbr); Menu f = new Menu(&quot;File&quot;);
Menu e = new Menu(&quot;Edit&quot;); Menu v =new Menu(&quot;View&quot;);
418 1 Y1 A 2 MenuItem f1=new MenuItem(&quot;New&quot;); CheckboxMenuItem f2=new
CheckboxMenuItem(&quot;Open&quot;,true); f.add(f1); f.add(f2); mbr.add(f);
mbr.add(e); mbr.add(v); } public static void main(String args[]) { MenuDemo m = new
MenuDemo(); m.setVisible(true); m.setSize(400,400); } }
Identify the layout of the image .
Figure:-

419 1 Y1 A 2 Border Layout

If a progam consist of three classes,then after compilation how many


420 1 N U 2 Three
class file (s) is are created by compiler

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

import java.awt.*; class Demo extends Frame { public static void


main(String args[]){ Frame f=new Frame(); f.setVisible(true);
422 1 N A 2 using setVisible(false);
f.setSize(150,200); } } In the above program how can a user hide the
frame window

import java.awt.*; import java.applet.* /*<applet code="my.class"


423 width=300 height=300></applet>*/ public class my extends Applet { 1 N A 2 Compilation Error
public void paint(Graphics g) { g.drawString(“Hello”); } }

import java.awt.*; import java.applet.*; /*<applet


code="Choice_Demo.class" width=300 height=300></applet>*/ public
424 1 N A 2 Applet
class Choice_Demo extends ________________ { Choice c1; public
void init() { c1=new Choice(); add(c1); } }

import java.awt.*; import javax.swing.*; public class Test { public


static void main(String[] args) { JFrame frame = new JFrame("My
Frame"); frame.add(new JButton("OK")); frame.add(new
425 1 N A 2 Only button Cancel is displayed.
JButton("Cancel"));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(200, 200); frame.setVisible(true); } }

import java.awt.*; import javax.swing.*; /*<applet code="L.class"


width=200 height=200> </applet>*/ public class L extends JApplet {
426 1 N A 2 Button is created with given image
public void init() { ImageIcon i1 = new ImageIcon("Koala.jpeg");
JButton b1=new JButton(i1); getContentPane().add(b1); } }

import java.awt.*; import javax.swing.*; public class Swing_Demo


extends JApplet { public void init() { ImageIcon ii=new
ImageIcon("Sunset.jpg"); JLabel l1=new JLabel("Sunset
Image",ii,JLabel.CENTER); c.add(l1); } }
Figure:-

427 1 Y1 A 2 Container c=getContentPane();


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

In given constructor what 3rd parameter indictaes Scrollbar s=new


429 1 N A 2 Size of thumb
Scrollbar(0,10,20,0,1000)

In the applet window a user wants to arrange all component one after
430 1 N U 2 setLayout(new FlowLayout());
another Which statement will work efficiently

In the below program, why is java.awt package imported? import


javax.swing.*; import java.awt.*; public class NewMain extends
JFrame { public static void main(String[] args) { JFrame jf=new
JFrame(""My Frame""); Container cpane=jf.getContentPane(); JLabel
431 l1=new JLabel(""Name""); JButton b1=new JButton(""OK""); JButton 1 N U 2 Because Container belongs to the package java.awt
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); } }

Insert the correct code in the following program segment in order to


display following output.
Figure:-

JRadioButton b1,b2,b3; b1= new JRadioButton(&quot;Indian&quot;); b2= new


432 1 Y1 A 2 JRadioButton(&quot;American&quot;); b3= new JRadioButton(&quot;German&quot;);

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)

Matches the following Component from Figure


Figure:-

fig(a)-TextField,fig(b)-Button,fig(c)-Label,fig(d)-List,fig(e)-CheckBoxGroup,fig(f)-
435 1 Y1 U 2
checkbox,fig(g)-Choice
436 Modification of the text can be controlled by 1 N U 2 setEditable()

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

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

Observe the following code import java.awt.*; import javax.swing.*; /*


<applet code="JTableDemo.class" width=400 height=500> </applet>
*/ public class JTableDemo extends JApplet { public void init() {
Container contentPane = getContentPane();
contentPane.setLayout(new FlowLayout()); final String[] colHeads = {
"Name", "Phone", "Fax"}; final Object[][] data = { {"Prashant",
The output is obtained in table with two rows and three columns with horizontal and
439 "12345","6789"}, {"Rupesh", "12345", "23456"} }; JTable table = 1 N A 2
vertical scrollbar
new JTable(data, colHeads); int v =
ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS; int h =
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS; JScrollPane
jsp = new JScrollPane(table, v, h); contentPane.add(jsp,
BorderLayout.CENTER); } }

Observe the following code import java.awt.*; import java.applet.*;


import java.util.*; /* <applet code="BorderLayoutDemo" width=400
height=200> </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);
The output is obtained in Applet with BorderLayout placing button on
440 add(new Button("Right"), BorderLayout.EAST); add(new Button("Left"), 1 N A 2
east,west,north,south and TextArea at center
BorderLayout.WEST); String msg = "The reasonable man adapts " +
"himself to the world;\n" + "the unreasonable one persists in " +
"trying to adapt the world to himself.\n" + "Therefore all progress
depends " + "on the unreasonable man.\n\n" + " - George Bernard
Shaw\n\n"; add(new TextArea(msg), BorderLayout.CENTER); } } What
will be the output of the above program?

Observe the following code importjava.awt.*; importjava.applet.*;


public class LayoutDemo5 extends Applet { public void init() {
inti,j,k,n=4; setLayout(new BorderLayout()); Panel p1=new Panel();
Panel p2=new Panel(); p1.setLayout(new FlowLayout()); p1.add(new
TextField(20)); p1.add(new TextField(20)); p2.setLayout(new
441 1 N A 2 The output is obtained in Applet with two layouts: Border layout and Flow Layout.
GridLayout(5,3)); p2.add(new Button("OK")); p2.add(new
Button("Submit")); add(p1,BorderLayout.EAST);
add(p2,BorderLayout.WEST); } } /*<applet code=LayoutDemo5.class
width=300 height=400> </applet>*/ What will be the output of the
above program?

Observe the following code import java.awt.*; import java.applet.*; /*


<APPLET Code="TextFieldPassword" Width=500 Height=200>
</APPLET> */ public class TextFieldPassword extends Applet { public
442 void init() { Label lblName = new Label("enter name"); Label lblPasswd 1 N A 2 The output is obtained in Applet with two labels and two textfields
= new Label("enter password"); TextField txtName = new
TextField("your name here", 20); TextField txtPasswd = new
TextField(20); add(lblName); add(txtName); add(lblPasswd);
txtPasswd.setEchoChar('*'); add(txtPasswd); } }

Observe the following program and point out which statement contains
error. importjava.awt.*; importjavax.swing.*; /* <applet
code="JTableDemo" width=400 height=200> </applet> */ public class
JTableDemo extends JApplet { public void init() { Container
contentPane = getContentPane(); contentPane.setLayout(new
BorderLayout()); final String[] colHeads = { "emp_Name", "emp_id",
"emp_salary" }; final Object[][] data = { { "Ramesh", "111", "50000"
443 1 N A 2 Error in statement in which JScrollPane is created
}, { "Sagar", "222", "52000" }, { "Virag", "333", "40000" }, { "Amit",
"444", "62000" }, { "Anil", "555", "60000" }, }; JTable table = new
JTable(data,colHeads ); int v =
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED; int h =
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPanejsp = new JScrollPane(table,,h,v); contentPane.add(jsp,
BorderLayout.CENTER); } }

Observe the image shown below. S1Q42 Which AWT component will
the image as shown
Figure:-

444 1 Y1 A 2 CheckboxGroup

Picture is a ________________
Figure:-

445 1 Y1 U 2 CheckboxMenuItem
Point out missing word in syntax in given code import java.awt.*;
import java.awt.event.*; public class demo extends Frame { public
static void main(String args[]) { Button b; GridLayout cr=
GridLayout(3,4,5,10); Frame f=new Frame("GRIDLAYOUT EXAMPLE");
446 f.setLayout(cr); f.add(new Button("1")); f.add(new Button("2")); 1 N U 2 new
f.add(new Button("3")); f.add(new Button("4")); f.add(new
Button("5")); f.add(new Button("7")); f.setSize(300,400);
f.setVisible(true); } }

Positions the components into five regions:east, west, north, south,


447 1 N U 2 BorderLayout
center

Say that a Frame contains three Panels. Could each Panel have a
448 1 N U 2 Yes---each one can use setLayout() with any layout manager
different layout manager?

select correct code for display given output


Figure:-

import java.awt.*; imort java.applet.*; /*&lt;applet code=&quot;FlowTest.class&quot;


width=200 height=300&gt;&lt;/applet&gt;*/ public class FlowTest extends Applet {
449 1 Y1 A 2
public void init() { // setLayout(new FlowLayout()); Default for(int i=1; i&lt;6; i++) {
add(new Button(&quot;Button &quot; + i)); } } }

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

Select proper code for given image as shwon in below


Figure:-

import java.awt.*; import java.applet.*; public class choice11 extends Applet { public
void init() { Choice os=new Choice(); os.add(&quot;wnn18&quot;); os.add(&quot;wnn
451 1 Y1 A 2 xp&quot;); os.add(&quot;wnn nt&quot;); os.add(&quot;win 2000&quot;); add(os); }
} /*&lt;applet code=&quot;choice11&quot; height=200 width=300&gt;
&lt;/applet&gt;*/

import java.awt.*; import java.awt.event.*; import javax.swing.*; import


javax.swing.tree.*; public class JTreeEvents extends JApplet { JTree tree; JTextField
jtf; public void init() {// Get content pane Container contentPane =
getContentPane();// Set layout manager contentPane.setLayout(new
BorderLayout());// Create top node of tree DefaultMutableTreeNode top = new
DefaultMutableTreeNode(&quot;Options&quot;);// Create subtree of &quot;A&quot;
Select proper code for given output DefaultMutableTreeNode a = new DefaultMutableTreeNode(&quot;A&quot;);
Figure:- top.add(a); DefaultMutableTreeNode a1 = new
DefaultMutableTreeNode(&quot;A1&quot;); a.add(a1); DefaultMutableTreeNode a2 =
new DefaultMutableTreeNode(&quot;A2&quot;); a.add(a2);// Create subtree of
&quot;B&quot; DefaultMutableTreeNode b = new
DefaultMutableTreeNode(&quot;B&quot;); top.add(b); DefaultMutableTreeNode b1 =
452 1 Y1 A 2 new DefaultMutableTreeNode(&quot;B1&quot;); b.add(b1); DefaultMutableTreeNode
b2 = new DefaultMutableTreeNode(&quot;B2&quot;); b.add(b2);
DefaultMutableTreeNode b3 = new DefaultMutableTreeNode(&quot;B3&quot;);
b.add(b3);// Create tree tree = new JTree(top);// Add tree to a scroll pane int v =
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED; int h =
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED; JScrollPane jsp = new
JScrollPane(tree, v, h);// Add scroll pane to the content pane contentPane.add(jsp,
BorderLayout.CENTER);// Add text field to applet jtf = new JTextField(&quot;&quot;,
20); contentPane.add(jtf, BorderLayout.SOUTH);// Anonymous inner class to handle
mouse clicks 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(&quot;&quot;); } }

Select proper command for compilation and execution of program.


import java.awt.*; import java.awt.event.*; import java.applet.*;
public class square extends Applet implements ActionListener {
TextField t1,t2; Label l1,l2; Button b1; public void init() { t1=new
TextField(5); t2=new TextField(5); l1=new Label("Enter Number:");
453 l2=new Label("Result:"); b1=new Button("Square"); 1 N A 2 D. javac square.java and appletviewer square.java
b1.addActionListener(this); add(l1); add(t1); add(l2); add(t2); add(b1);
} public void actionPerformed(ActionEvent ae) { if(ae.getSource()==b1)
{ int n1=Integer.parseInt(t1.getText()); n1=n1*n1;
t2.setText(Integer.toString(n1)); } } } /*<applet code="square"
width=400 height=400> </applet>*/

select the correct code for display the given output


Figure:-

import javax.swing.*; import java.awt.*; public class ShowLayout extends JFrame {


public ShowLayout (String s) { Container c = f.getContentPane(); c.setLayout (new
FlowLayout()); for (int i = 0; i &lt; 5; i++) { c.add (new Button(&quot;NO&quot;); c.add
454 1 Y1 A 2
(new Button(&quot;Batter&quot;); } c.add(new Label(&quot;Swing&quot;)); } public
static void main (String args[]) { JFrame f = new ShowLayout(&quot;JFrame
Example&quot;); f.setVisible(true); } }

Select the correct code to get the following output:


Figure:-
import java.awt.*; import java.applet.*; public class Sample extends Applet { public
void init() { CheckboxGroup cbg=new CheckboxGroup(); Checkbox red=new
455 1 Y1 A 2 Checkbox(&quot;Red&quot;,false,cbg); Checkbox green=new
Checkbox(&quot;Green&quot;,false,cbg); Checkbox blue=new
Checkbox(&quot;Blue&quot;,false,cbg); add(red); add(green); add(blue); }}

Select the correct output of the following program: import java.awt.*;


import java.applet.*; public class Sample extends Applet { public void
init() { add(new Label("Select year and branch:")); Choice year=new
456 Choice(); Choice branch=new Choice(); year.add("First Year"); 1 Y2 A 2 .
year.add("Second Year"); year.add("Third Year"); add(year);
branch.add("CE"); branch.add("CO"); branch.add("EE");
branch.add("EJ"); branch.add("ME"); add(branch); } }

Select the missing statement in given code import java.awt.*; import


java.applet.*; import javax.swing.*; public class table extends JApplet
{ public void init() { String s[]={"srno","name","rollno"}; Object data[]
[]={{"1","abc","01"},{"2","xyz","0"}}; int
457 v=JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED; int 1 N U 2 JTable it=new JTable(data,s);
h=JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED; JScrollPane
p=new JScrollPane(it,v,h); Container co=getContentPane();
co.add(p,BorderLayout.CENTER); } } /*<applet code=table width=300
height=300></applet>*/

select the missing statement in the following code import


java.awt.FlowLayout; public class HelloWorldSwing1 extends JFrame {
public static void main(String[] args) { JFrame frame = new
JFrame("HelloWorldSwing"); JLabel label = new JLabel("Hello World");
JButton b1=new JButton("submit"); JTextField t1=new JTextField(10);
458 1 N A 2 import javax.swing.*;
frame.getContentPane().add(label); frame.getContentPane().add(t1);
frame.getContentPane().add(b1);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack(); frame.setVisible(true);
frame.getContentPane().setLayout(new FlowLayout()); } }

Select the missing statement in the following program for following


output import java.awt.*; 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 nw1=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:-
459 1 Y1 A 2 nw.add(nw1);
Select the missing statement in the program for following output
import java.awt.*; public class MenuDemo extends Frame { public
static void main(String args[]) { MenuDemo m = new MenuDemo();
m.setVisible(true); MenuBar mbr = new MenuBar();
460 m.setMenuBar(mbr); Menu filemenu = new Menu("File"); Menu 1 N A 2 mbr.add(viewmenu);
editmenu = new Menu("Edit"); Menu viewmenu = new Menu("View");
mbr.add(filemenu); mbr.add(editmenu); MenuItem new1 = new
MenuItem("New"); MenuItem open1 = new MenuItem("Open");
filemenu.add(new1); filemenu.add(open1); } }

Select the missing statement in the program to get the following


output import java.awt.*; import java.awt.event.*; import
java.applet.*; /* <applet code="ChoiceDemo" width=300 height=180>
</applet> */ public class ChoiceDemo extends Applet implements
461 ItemListener { Choice city; public void init() { city.add("Nagpur"); 1 N U 2 city = new Choice();
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.drawString(msg, 6, 120); } }

Select the missing statements in the program to get following output:


import java.awt.*; class Sample extends Frame { Sample(String title) {
super(title); MenuBar mbar = new MenuBar(); setMenuBar(mbar);
Menu font = new Menu("Font");
font.add(bold);font.add(italic);font.add(under); 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"); } }
CheckboxMenuItem bold = new CheckboxMenuItem(&quot;Bold&quot;);
Figure:-
CheckboxMenuItem italic = new CheckboxMenuItem(&quot;Italic&quot;);
462 1 Y1 A 2
CheckboxMenuItem under = new CheckboxMenuItem(&quot;Underline&quot;);
CheckboxMenuItem strike = new CheckboxMenuItem(&quot;Stikethrough&quot;);
Select the proper code for following output?
Figure:-

import java.awt.*; import java.applet.*; /*&lt;applet code=&quot;Demo&quot;


width=200 height=80&gt; &lt;/applet&gt;*/ public class Demo extends Applet { public
463 1 Y1 A 2
void init() { Label jlb1=new Label(&quot; Enter Number:&quot;); TextField jtf1=new
TextField(12); Choice ch=new Choice();

Select the proper command to run the following code import


java.awt.*; import java.applet.*; /* <applet code="textdemo25"
464 1 N A 2 appletviewer textdemo25 .java
width=300 height=100> </applet> */ public class textdemo25 extends
Applet { public void init() { TextField jt=new TextField(30); add(jt) } }

Select the proper command to run the following code import


java.awt.*; import java.awt.event.*; import javax.swing.*; import
java.applet.*; /* <applet code="combodemo" width=300 height=100>
</applet> */ public class combodemo extends JApplet { public void
465 1 N A 2 appletviewer combodemo.java
init() { Container co = getContentPane(); co.setLayout(new
FlowLayout()); JComboBoxjc=new JComboBox(); jc.addItem("pen");
jc.addItem("pencil"); jc.addItem("eraser"); jc.addItem("sharpner");
co.add(jc); } }

Select the proper command to run the following code import


java.awt.*; import java.awt.event.*; import javax.swing.*; import
java.applet.*; /* <applet code="combodemo11" width=300
height=100> </applet> */ public class combodemo11 extends JApplet
466 1 N A 2 Javac combodemo11.java &amp; appletviewer combodemo11.java
{ public void init() { Container co = getContentPane();
co.setLayout(new FlowLayout()); 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 following code import


java.awt.*; import java.awt.event.*; import javax.swing.*; import
java.applet.*; 90 /* <applet code="combodemo11" width=300
height=100> </applet> */ public class combodemo11 extends JApplet
467 1 N A 2 appletviewer combodemo11.java
{ public void init() { Container co = getContentPane();
co.setLayout(new FlowLayout()); 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 following code import


java.awt.*; import java.awt.event.*; import javax.swing.*; public class
mymenu extends JFrame { JTextField tf=new JTextField(20); JMenuBar
mb=new JMenuBar(); JMenu file = new JMenu("File"); JMenu edit=new
JMenu("Edit"); JMenuItem fnew=new JMenuItem("New"); JMenuItem
fopen=new JMenuItem("Open"); JMenuItem fsave=new
JMenuItem("Save"); JMenuItem fclose=new JMenuItem("Close");
JCheckBoxMenuItem fprint=new JCheckBoxMenuItem("Print");
JMenuItem ecut=new JMenuItem("Cut"); JMenuItem ecopy=new
JMenuItem("Copy"); JMenuItem epaste=new JMenuItem("Paste");
public mymenu(String title) { super(title); file.add(fnew);
file.add(fopen); file.add(fsave); file.addSeparator(); file.add(fclose);
468 file.add(fprint); edit.add(ecut); edit.add(ecopy); edit.add(epaste); 1 N A 2 java mymenu
mb.add(file); mb.add(edit); setJMenuBar(mb);
getContentPane().setLayout(new FlowLayout());
fnew.addActionListener(new MIHandler());
fopen.addActionListener(new MIHandler());
fsave.addActionListener(new MIHandler());
fclose.addActionListener(new MIHandler());
ecut.addActionListener(new MIHandler());
ecopy.addActionListener(new MIHandler());
epaste.addActionListener(new MIHandler());
getContentPane().add(tf); } public static void main(String args[]) {
mymenu mm=new mymenu("Editor Frame"); mm.setSize(300,300);
mm.setVisible(true); } class MIHandler implements ActionListener {
public void actionPerformed(ActionEvent ae) { String
cmd=ae.getActionCommand(); tf.setText(cmd); } } }

Select the proper command to run the following code import


java.awt.*; import javax.swing.*; 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
469 b4=new JButton("Sangali"); add(b4); } } class ColorPanel extends 1 N A 2 appletviewer tabbeddemo.java
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" width=500 height=500> </applet>*/

Select the proper command to run the following code import


javax.awt.* import javax.swing.*; public class JListDemo extends
JApplet { JTextField t1; JList jl; String data[ ]={“Red”, “Green”, “Blue”,
470 “Yellow”, “Pink”}; Public void init() { Container cp=getContentPane(); 1 N A 2 appletviewer JListDemo.java
cp.setLayout(new FlowLayout()); T1=new JList(data); cp.add(jl);
cp.add(t1); } } /*<applet code=”JListDemo” width=300 height=300>
</applet>*/

Select the proper command to run the following code import


java.awt.*; import java.applet.*; /* <applet code="TextFieldDemo"
width=380 height=150> </applet> */ public class TextFieldDemo
extends Applet { TextField name, pass; public void init() { Label namep
471 1 N A 2 appletviewer TextFieldDemo.java
= new Label("Name: ", Label.RIGHT); Label passp = new
Label("Password: ", 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 following code /*<applet


code=frameinapp width=300 height=300> </applet>*/ import
java.awt.*; import java.awt.event.*; import java.applet.*; class
framein extends Frame { String msg=" "; framein(String title) {
super(title); setSize(200,200); setVisible(true);
addWindowListener(new WindowAdapter() { public void
windowClosing(WindowEvent e) { setVisible(false); } });
addMouseListener(new MouseAdapter() { public void
mouseEntered(MouseEvent e) { msg="mouse entered in frame";
472 1 N A 2 Appletviewer frameinapp.java
repaint(); } public void mouseExited(MouseEvent e) { msg="mouse
exited from frame"; repaint(); } }); } public void paint(Graphics g) {
g.drawString(msg,50,50); } } public class frameinapp extends Applet {
framein f;String msg=" "; public void init() { f=new framein("Demo");
addMouseListener(new MouseAdapter() { public void
mouseEntered(MouseEvent e) { msg="mouse entered in Applet";
repaint(); } public void mouseExited(MouseEvent e) { msg="mouse
exited from Applet"; repaint(); } }); } public void paint(Graphics g) {
g.drawString(msg,100,100); } }

Select the proper output for following code import java.awt.*; import
java.applet.*; public class DemoBorderLayout extends Applet { Button
b1,b2,b3,b4,b5; public void init() { BorderLayout b=new
BorderLayout(20,30); setLayout(b); b1=new Button("Top"); b2=new
Button("Right"); b3=new Button("Bottom"); b4=new Button("Left");
473 1 Y2 A 2 S1Q42O2
b5=new Button("Center"); add(b1,BorderLayout.NORTH);
add(b2,BorderLayout.EAST); add(b3,BorderLayout.SOUTH);
add(b4,BorderLayout.WEST); add(b5,BorderLayout.CENTER); } } /*
<applet code="DemoBorderLayout.class" width=350 height=300>
</applet>*/

Select the suitable statement for given output


Figure:-

474 1 Y1 U 2 Buttons,FlowLaout.RIGHT

setEnabled(false); method used in menubar for


475 1 N U 2 Used to disable menu
_______________________

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

Show the output of following code. import javax.swing.*; public class


Test { public static void main(String ar[]) { JButton b1=new
477 1 N A 2 true,false
JButton("OK"); System.out.println(b1.isVisible()+" "); JFrame f1=new
JFrame(); System.out.println(f1.isVisible()+" "); } }

State the method that will be used so as to display the password as '?'
in the output shown in S1Q43
Figure:-
478 1 Y1 A 2 setEchoChar('?')

state the output and assume suitable data import java.awt.*; import
java.applet.*; class Demo extends Applet { CheckBox c1,c2; public void
479 1 N U 2 label of c2 will print
init(){ C1=new CheckBox(“awt”); C2=new CheckBox();
System.out.println(c2.getLabel()); } }

State true of false. i) AWT is an extended version of swing ii) Paint( ) of


480 1 N U 2 i-false, ii-false
Applet class cannot be overridden

1. Create a JTabbedPane object 2. Call addTab() to Add a tab to the pane 3.Repeat
481 Steps for Adding TabbedPane Control 1 N U 2
Step 2 for each Tab 4. Add the Tabbed Pane to the conte

Suppose a Panel is added to a Frame and a Button is added to the


Panel. If the Frame's font is set to 12-point TimesRoman, the Panel's
482 1 N U 2 10-point TimesRoman
font is set to 10-point TimesRoman, and the Button's font is not set,
what font will be used to display the Button's label?

483 Swing components are light weight because: 1 N A 2 Swing components are platform independent.

Swing provides a combo box (a combination of a text field and a drop-


484 down list) through the JComboBox class, which extends 1 N U 2 Jcomponent
__________________.

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

The code Code will produce how many buttons: public class
JScrollPaneDemo extends JApplet { public void init() { // Get content
pane Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout()); JPanel jp = new
JPanel(); jp.setLayout(new GridLayout(20, 20)); int b = 0; for(int i = 0; i
486 < 20; i++) { for(int j = 0; j < 20; j++) { jp.add(new JButton("Button " + 1 N A 2 400 Buttons
b)); ++b; } } // Add panel to a scroll pane int v =
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED; int h =
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane jsp = new JScrollPane(jp, v, h); // Add scroll pane to the
content pane contentPane.add(jsp, BorderLayout.CENTER); } }

487 The constructor JCheckBox(true, “YES”) suggests that – 1 N U 2 Checkbox is selected and displays the string “YES” on it.

488 The default horizontal and vertical gap in FlowLayout is….. 1 N U 2 5 Pixel

The following 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)

The following is an example of which layout?


Figure:-

490 1 Y1 U 2 BorderLayout

The follwowing is an example of which layout?


Figure:-

491 1 Y1 U 2 CardLayout

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

493 The layout manger that shows how words flow in a text editor?Use 1 N U 2 Flow

494 The main difference between model and models dialog box is 1 N U 2 When box is active input focus can not be directed to another window

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

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

To construct a text area that is 80 character-widths wide and 10


497 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 AWT/Swing which method will be used 1 N U 2 setBounds(int x,int y,int height,int width)

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

To produce following output in given program which statement should


be placed to change the background color of applet import
javax.swing.*; import java.awt.*; import java.awt.event.*; /* <applet
code=JRadioButtonDemo.class width=500 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 FlowLayout()); 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)
{ ...........................................................................
.......................................................................... if(ie.getItemSelectable()==r) cp.setBackground(Color.RED);
505 ....................................................................... } } 1 Y1 A 2 if(ie.getItemSelectable()==g) cp.setBackground(Color.GREEN);
Figure:- if(ie.getItemSelectable()==b) cp.setBackground(Color.BLUE);

To set new font object with size 48 , name: Serif , Style PLAIN, what
will be the statement from the following
Figure:-

506 1 Y1 U 2 new Font(&quot;Serif&quot;, Font.PLAIN, 48)


To set password as '******' which command should be added in the
following code import java.awt.*; import java.awt.event.*; import
java.applet.*; public class textfield extends Applet implements
ActionListener { TextField nm,psw; public void init() { Label nml=new
Label("name:",Label.RIGHT); Label psw=new
Label("Password:",Label.RIGHT); nm=new TextField(12); psw=new
507 TextField(8); add(nml); add(nm); add(pswl); add(psw); 1 N A 2 psw.setEchoChar('*');
nm.addActionListener(this); psw.addActionListener(this); } public void
actionPerformed(ActionEvent ae) { repaint(); } public void
paint(Graphics g) {g.drawString("name:"+nm.getText(),6,80);
g.drawString("Selected text in name:"+nm.getSelectedText(),6,100);
g.drawString("password:"+psw.getText(),6,120); } } /* <applet
code="textfield.class" width=200 height=200> </applet>*/

What AWT classes (components) will be needed to get following


output?
Figure:-

508 1 Y1 U 2 Label,Checkbox,checkboxGroup,FlowLayout

What code should be added so that we can get following Code? import
java.awt.*; import java.applet.*; import java.awt.event.*; /*<applet
code=SignIn.class width=400 height=400></applet>*/ public class
SignIn extends Applet implements ActionListener { TextField t1,t2;
Button b1; Label l; public void init() { t1=new TextField(20); t2=new
TextField(20); b1=new Button("Sign In"); l=new Label(""); "); add(t1);
add(t2); --------------------- add(b1); ---------------------- add(l); } public
void actionPerformed(ActionEvent ae) { if(ae.getSource()==b1) {
String msg=t1.getText(); String msg1=t2.getText();
if(msg.equals("Admin")&&msg1.equals("Admin")) { l.setText("Correct
509 Password"); } else { l.setText("Incorrect Password"); } } } }
1 Y1 A 2 Both A &amp; B
Figure:-

What code should be added so that we can get following Code? import
java.awt.*; import java.awt.event.*; class WindowCloseDemo extends
Frame { Button exit; WindowCloseDemo() { exit=new Button("Exit");
add(exit); WindowClose w=new WindowClose();
addWindowListener(w); setTitle("Window"); setSize(400,300);
setVisible(true); } public static void main(String []cd) {
WindowCloseDemo wcd=new WindowCloseDemo(); } } class
WindowClose extends WindowAdapter { public void
windowClosing(WindowEvent we) { System.exit(1); } }
Figure:-

510 1 Y1 A 2 setLayout(new FlowLayout());

511 What code would you use to construct a 24-point bold Calibri font? 1 N U 2 new Font(&quot;Calibri&quot;, Font.BOLD,24);

What Component will be displayed in output of Following Code import


java.awt.*; import java.applet.*; /* <applet code="Mydemo25"
512 width=300 height=100> </applet> */ public class Mydemo25 extends 1 N A 2 TextBox and Button
Applet { public void init() { TextField jt=new TextField(30); add(jt);
add(new Button("OK")); } }

What component will be needed to get following output?


Figure:-

513 1 Y1 U 2 D) JPanel, JTextField, JScrollPane and Constants related to scrollbars


What components will be needed to get following output?
Figure:-

514 1 Y1 U 2 Applet, TabbedPane, ComboBox

What components will be needed to get following output?


Figure:-

515 1 Y1 U 2 Button,Checkbox,RadioButton

What components will be needed to get following output?


Figure:-
516 1 Y1 U 2 Frame, MenuBar, Menu, CheckboxMenuItem

What components will be needed to get following output?


Figure:-

517 1 Y1 A 2 Icon, Button, Panel, Frame

What components will be needed to get following output?


Figure:-

518 1 Y1 U 2 JApplet, JCheckBox, JComboBox, Jbutton

What components will be needed to get following output?


Figure:-

519 1 Y1 U 2 JPasswordField,JComboBox,ToolTipText,JTextArea
What components will be needed to get following output?
Figure:-

520 1 Y1 U 2 Jtable, JScrollPane

What components will be needed to get following output?


Figure:-

521 1 Y1 U 2 Label , Button, ComboBox

What components will be needed to get following output?


Figure:-

522 1 Y1 U 2 Label, Choice


What components will be needed to get following output?
Figure:-

523 1 Y1 U 2 Label,textfield,Button

What components will be needed to get following output?


Figure:-

524 1 Y1 U 2 TextField , Label , Button

What correction is required in the following program to get output?


import java.awt.*; import java.awt.event.*; import javax.swing.*;
public class demo extends JApplet { public void init () { Container
525 co=getContentPane(); co.setLayout(new FlowLayout()); jc. 1 N A 2 JComboBox jc=new JComboBox() ;
addItem("Apple"); jc. addItem("Banana"); jc. addItem("Mango");
co.add(jc); } } }

What Correction should be done in the following program to get the


proper output? /* <applet code="JTabbedPaneDemo" width=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
526 ColorsPanel()); getContentPane().add(jtp); } } class CitiesPanel 1 N A 2 Missing package sentences
extends JPanel { public CitiesPanel() { JButton b1 = new JButton("New
York"); add(b1); JButton b2 = new JButton("London"); add(b2); } }
class ColorsPanel extends JPanel { public ColorsPanel() { JCheckBox
cb1 = new JCheckBox("Red"); add(cb1); JCheckBox cb2 = new
JCheckBox("Green"); add(cb2); } }

What is output of follwing programmissing statement? import


java.awt.*; import javax.swing.*; 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(); } }
527 Figure:- 1 Y1 A 2 Buttons are displayed in 3 rows and 3 columns

What is an event in delegation event model used by Java programming


528 1 N U 2 An event is an object that describes a state change in processing.
language?

What is mising statement in following code? import


java.awt.Container; import java.awt.Font; import java.awt.GridLayout;
import javax.swing.JButton; import javax.swing.JFrame; public class
GridSizeTest extends JFrame { public static void main(String[] args) {
GridSizeTest gst = new GridSizeTest();
529 gst.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); gst.pack(); } 1 N U 2 Both a &amp; b
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"); } }

What is output of following program? import javax.swing.*; import


java.awt.event.*; import java.awt.*; class Login extends JFrame {
JLabel lblName,lblPass; JTextField txtName; JButton btnOk;
JPasswordField txtPass; Login() { setTitle("Login"); setLayout(null);
lblName=new JLabel("UserName"); lblPass=new JLabel("Password");
lblPass.setForeground(new Color(255,0,0));
lblName.setForeground(new Color(255,0,0)); txtName=new
JTextField(); txtPass=new JPasswordField(); setLocation(250,80);
setSize(500,250); lblName.setBounds(10,10,200,50);
lblPass.setBounds(10,100,200,50);
txtName.setBounds(220,10,200,50);
530 1 Y2 A 2
txtPass.setBounds(220,100,200,50); lblName.setFont(new Font("Times
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 What is Purpose of Jtree ? 1 N U 2 A tree is a component that presents a hierarchical view of data

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

533 what is Runnable from following? 1 N U 2 interface

What is the code for following output S1Q27.jpg


Figure:-

import java.applet.Applet; import java.awt.Button; /* &lt;applet


code=&quot;CreateAWTButtonExample&quot; width=200 height=200&gt;
534 1 Y1 U 2
&lt;/applet&gt; */ public class CreateAWTButtonExample extends Applet { public void
init() { Button b = new Button(); b.setLabel(&quot;My Button 1&quot;

What is the correct code for given output?


Figure:-

import javax.swing.JFrame; import javax.swing.JLabel; public class HelloWorldFrame


extends JFrame { public static void main(String args[]) { HelloWorldFrame hw= new
535 1 Y1 A 2
HelloWorldFrame(); hw.setVisible(true); } HelloWorldFrame() { JLabel jlbHelloWorld =
new JLabel(&quot;Hello World&quot;); hw.add(jlbHelloWorld); this.setSi

What is the correct code to get the ouput shown in figure?


Figure:-

import java.awt.*; import java.applet.Applet; public class buttonDir extends Applet {


public void init() { setLayout(new BorderLayout()); add(&quot;North&quot;, new
Button(&quot;North&quot;)); add(&quot;South&quot;, new
536 1 Y1 A 2
Button(&quot;South&quot;)); add(&quot;East&quot;, new Button(&quot;East&quot;));
add(&quot;West&quot;, new Button(&quot;West&quot;)); add(&quot;Center&quot;,
new Button(&quot;Center&quot;)); } }
The object issuing the call to wait() will halt until another object sends a notify() or
537 What is the effect of issuing a wait() method on an object ? 1 N A 2 notifyAll() method

What is the layout of the given output


Figure:-

538 1 Y1 U 2 FlowLayout

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

What is the output of following program: import java.awt.*; import


java.awt.event.*; import java.applet.*; public class app3 extends
Frame { public static void main(String m[]) { Frame f=new
540 1 N A 2 doesn't show frame
Frame("BUTTON FRAME"); Button b=new Button("save"); f.add(b);
f.setSize(100,200); f.setLayout(new FlowLayout()); f.setVisible(false);
}}

What is the output of the following code: import java.awt.*; import


java.applet.*; /* <applet code="GridLayoutDemo" width=300
height=200> </applet> */ public class GridLayoutDemo extends Applet
541 1 Y2 A 2 A
{ 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")); } } } }

What is the output of this program?


Figure:-

542 1 Y1 A 2 Two coincided lines


What is the output of this program?
Figure:-

543 1 Y1 A 2 Will display list

What is the output of this program?


Figure:-

544 1 Y1 A 2 will not display any output

What is the purpose of following code? JTextField jtf=new


545 1 N U 2 Defining Textfield
JTextField(15)

546 What is the purpose of JTabbedPane? 1 N U 2 JTabbedPane manages a set of components of linking them with tabs.

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

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

549
What is the purpose of ToggleButton? 1 N U 2 On or Off Switch
What is the result of executing the following Java class: import java
.awt.*; public class FrameTest extends Frame { public Frame Test() {
550 add (new Button("First")); add ( new Button( "Second")); add (new 1 N A 2 Only the third button is diplayed .
Button ("Third")); pack() ; setVisible(true); } public static void main (
String args [] { new Frame Test ();}}

What is the use of panel in the program given below import


java.awt.*; import java.applet.*; public class Demo5 extends Applet {
public void init() { setLayout(new BorderLayout()); Panel p1=new
Panel(); Panel p2=new Panel(); p1.setLayout(new FlowLayout());
The appletviewer window is divided into two parts using two panels so that different
551 p1.add(new TextField(20)); p1.add(new TextField(20)); 1 N U 2
layouts can be assigned to the two parts.
p2.setLayout(new GridLayout(5,3)); p2.add(new Button("OK"));
p2.add(new Button("Submit")); add(p1,BorderLayout.EAST);
add(p2,BorderLayout.WEST); } } /*<applet code=Demo5.class
width=300 height=400> </applet> */

552 What is the use of setEchoChar() method? 1 N U 2 to create password in symbol form

553 What is the use of setLayout() method 1 N U 2 To install a new layout manager

What is the use of String getActionCommand( ) method of ActionEvent


554 1 N U 2 To obtain the label(caption) of Button
class?

555 What is use of GridLayout Manager ? 1 N U 2 lays out components in a two-dimensional grid

What layout manager should you use so that every component


556 1 N A 2 GridLayout
occupies the same size in the container?

What pattern does the FlowLayout layout manager use to add


557 1 N U 2 Left to right, top to bottom
components to container?

what should you use to position a button within an application Frame


558 1 N U 2 FlowLayout
so that the size of Button is NOT affected by frame size?

What will be output for following program: import java.awt.*; import


javax.swing.*; import javax.swing.tree.*; public class feee extends
JApplet { JTree t1; DefaultMutableTreeNode d1,d2,d3; public void init()
{ d1=new DefaultMutableTreeNode("FY"); d2=new
559 1 Y2 A 2 S1Q44O3
DefaultMutableTreeNode("SY"); d3=new
DefaultMutableTreeNode("TY"); t1=new JTree(d2); d2.add(d3);
d3.add(d1); add(t1); } } /* <applet code="feee.java" width=200
height=100> </applet> */

What will be output of following code. Import javax.swing>*; Public


class Test { Public static void main(String[] args) { JButtonjbtOK=new
560 1 N A 2 true,false
JButton(“OK”); System.out.print(jbtOK.isVisible()) + “,”); JFrame frame
=new JFrame(); System.out.println(frame.isVisible()); } }

What will be the error in following code? import java.awt.*; import


java.applet.*; public class Demo extends Applet { List l; public void
561 init(){ l=new List(2); l.add(“Satara”); l.add(“Akola”); l.add(“Pune”,2); 1 N A 2 the return type of method getItem () is not match
int x=getItem(2); } }

What will be the correct code for following output?


Figure:-
import java.awt.*; import java.awt.event.*; class ChoiceAction extends Frame {
Choice c; Label l; public ChoiceAction() { // Set frame properties setTitle(&quot;Choice
with ItemListener Demo&quot;); setSize(400,400); setLayout(new FlowLayout());
setLocationRelativeTo(null); setVisible(true); // Create choice c=new Choice(); //
Create label l=new Label(); // Add items c.add(&quot;Window98&quot;);
562 1 Y1 A 2
c.add(&quot;Window NT&quot;); c.add(&quot;Solari&quot;);
c.add(&quot;Maco&quot;); // Add choice add(c); // Add label add(l); // Add item listener
c.addItemListener(new ItemListener(){ public void itemStateChanged(ItemEvent ie) {
l.setText(&quot;You selected &quot;+c.getSelectedItem()); } }); } public static void
main(String args[]) { new ChoiceAction(); } }

What will be the order of four items added Choice c1 = new Choice();
563 c1.add("First"); c1.addItem("Second"); c1.add("Third"); 1 N U 2 First,Second,Lastadded,Third
c1.insert("Lastadded",2);

When the size of componant is change___________event is


564 1 N A 2 ComponantEvent
generated.

When there is a switching condition like on or off, which control is used


565 1 N U 2 toggle button
of following?

When we create a Dialog box using the Constructor Dialog (Frame


566 1 N U 2 Modal
f,true) the dialog box is of which type ?

When we invoke repaint() for a java.awt.Component object, the AWT


567 1 N U 2 update()
invokes the method:

Where g is a graphics instance what will the following code draw on An arc bounded by a box of height 50, width 50, with a centre point of 45,90 starting
568 1 N A 2
the screengfillArc(45,90,50,50,90,180); at an angle of 90 degrees traversing through 180 degrees clockwise

Where the panel add on frame? import java.awt.*; public class


CompLay extends Frame{ CompLay(){ Panel p = new Panel();
p.add(new Button("One")); p.add(new Button("Two")); p.add(new
569 1 N A 2 A.On left side of Frame
Button("Three")); add("South",p); setLayout(new FlowLayout());
setSize(300,300); setVisible(true); } public static void main(String
argv[]){ CompLay cl = new CompLay(); } }

Whether the code is correct to generate the given output? /*<applet


code="MyJRadioButton" width=900 height=900> </applet>*/ import
java.awt.*; import javax.swing.*; public class MyJRadioButton extends
JApplet { public void init() { Container c=getContentPane();
c.setLayout(new FlowLayout()); 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:-

570 1 Y1 A 2 Yes

571 which abstract class is the super class of all menu related classes? 1 N U 2 MenuComponent
Which among the below is not the method applicable for Button in
572 1 N U 2 setDisableIcon()
swing

573 Which among the following is not correct regarding dialog? 1 N U 2 Use of Dialog effects the working of Application

574 Which among the following is the feature of Jtable 1 N U 2 all of these

575 Which are the valid ways to create DataInputStream streams? 1 N A 2 new DataInputStream(new FileInputStream(&quot;in.dat&quot;);

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

577 which AWT complonents are used to produce given output? 1 N U 2 Button, Label, TextField, TextArea

Which AWT control is uesd to produce given output


Figure:-

578 1 Y1 U 2 GridLayout, Label, TextField, Button

Which checkbox will be selected in the following code ( Assume with


main and added to a Frame) Frame myFrame = new Frame("Test");
CheckboxGroup cbg = new CheckboxGroup(); Checkbox cb1 = new
579 Checkbox("First",true,cbg); Checkbox cb2 = new 1 N U 2 cb3
Checkbox("Scond",true,cbg); Checkbox cb3 = new
Checkbox("THird",false,cbg); cbg.setSelectedCheckbox(cb3);
myFrame.add(cb1); myFrame.add(cb2); myFrame.add(cb3);

Which class can be used to represent a checkbox with a textual label


580 1 N U 2 Checkbox MenuItem
that can appear in a menu?

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

Which classes are used to generate following output as shown in


figure.
Figure:-

582 1 Y1 U 2 Both options i and iii correct.


Which code is correct to generate the following output?
Figure:-

a) Scrollbar vert = new Scrollbar(Scrollbar.VERTICAL,0, 1, 0, 100); Scrollbar horz = new


583 1 Y1 A 2
Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, 100);

Which code will produce the out shown in figure


Figure:-

f=new Font(&quot;Times New Roman&quot;,Font.ITALIC,14); setFont(f); //setting the


584 1 Y1 U 2
new font setForeground(Color.red);

Which componenet is needed to get the following output?


Figure:-

585 1 Y1 U 2 JScrollPane,Icon
Which Componenets and layout manager are used in following output
Figure:-

586 1 Y1 U 2 Buttons,Borderlayout

Which Component are present in following image


Figure:-

587 1 Y1 U 2 JButton, JLabel, JTable, JProgressBar

Which component is display area for a short string of text, image or


588 1 N U 2 Jlabel
both?

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

Which component required to get folowing output


Figure:-
590 1 Y1 U 2 Label,TextArea,Button

591 Which Component subclass is used for drawing and painting? 1 N U 2 Canvas

Which components are needed to get above shown output


Figure:-

592 1 Y1 U 2 List, Button

Which components are needed to get below shown output?


Figure:-

593 1 Y1 U 2 JComboBox, Button

Which components are needed to get below shown output?


Figure:-
594 1 Y1 A 2 Button, Textfield,List

Which components are needed to get below shown output?


Figure:-

595 1 Y1 A 2 Choice, Button

Which components are needed to get below shown output?


Figure:-

596 1 Y1 A 2 Label,Choice

Which components are required to display following output?


Figure:-
597 1 Y1 U 2 Frame, Label, CheckboxGroup, Button

Which components are required to get following output?


Figure:-

598 1 Y1 U 2 Applet, Choice, Button, Label, List

Which components are reuired to get following output (S1Q28)


Figure:-

599 1 Y1 U 2 List and Button

which components are used in following diagram


Figure:-
600 1 Y1 U 2 JRadioButton,JTextField

Which components are used in following output


Figure:-

601 1 Y1 U 2 Label,TextArea,Button

Which Components are used in Following output?


Figure:-

602 1 Y1 U 2 JRadioButton ,JTextField

Which components are used in the following output?


Figure:-
603 1 Y1 U 2 Applet,Label,TextField,Button

Which components are used in the following output?


Figure:-

604 1 Y1 U 2 Checkbox,Label

Which components are used in the following output?


Figure:-

605 1 Y1 U 2 JButton,JTextField

Which components are used in the following output?


Figure:-
606 1 Y1 U 2 Label, Button, TextField

Which components are used in the following output?


Figure:-

607 1 Y1 U 2 Label, TextField, Button

Which components are used in the following output?


Figure:-

608 1 Y1 U 2 Label, TextField, Button

Which components are used in the following output?


Figure:-

609 1 Y1 U 2 Label,TextField,Button
Which components are used in the following output?
Figure:-

610 1 Y1 U 2 Label,TextField,Button

Which components are used in the following output?


Figure:-

611 1 Y1 U 2 Scrollbar, Label, Choice

Which components are used in this code? import javax.swing.*; import


java.awt.*; 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");
1 N U 2 Button and ImageIcon
612 JPanel panel = new JPanel(); button.setIcon(imgicon);
panel.add(button); frame.add(panel, BorderLayout.NORTH);
frame.setSize(400, 400); frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }

Which components are used to devlope followin window


Figure:-

613 1 Y1 U 2 Label, TextField, Button

Which Components need to be used to produce this output


Figure:-

614 1 Y1 A 2 JtabbedPane,JLabel and ImageIcon

615 Which components provide support for two-state buttons? 1 N U 2 JCheckBox, JRadioButton

616 Which constructor creates a TextArea with 10 rows and 20 columns? 1 N U 2 new TextArea(10, 20);

Which constructor was correct to get output


Figure:-

617 1 Y1 U 2 Jtable(2,3)

618 Which control is a combination of text field and dropdown list? 1 N U 2 combo boxes

619 Which Gridlayout class constructor creates single column grid Layout? 1 N U 2 GridLayout()
620 Which is componant in AWT which contain another componant? 1 N U 2 Container

which is correct code for following image


Figure:-

621 1 Y1 A 2 import java.awt.*; import java.applet.*;

Which is the layout manger that occupies the same size on the
622 1 N A 2 Grid
window?

Which is the correct code for the following output


Figure:-

import java.awt.*; import java.applet.*; public class LayDemo extends Applet {


public void init() { Button b1=new Button (&quot;OK&quot;); Button
623 1 Y1 A 2
b2=new Button(&quot;Cancel&quot;); FlowLayout f=new
FlowLayout(FlowLayout.RIGHT); setLayout(f); add(

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

Which layout example is this?


Figure:-

625 1 Y1 U 2 FlowLayout

Which Layout is used in following o/p


Figure:-

626 1 Y1 U 2 GridBagLayout

Which layout is used in the following output?


Figure:-

627 1 Y1 U 2 BorderLayout

Which Layout is used to obtain the following output


Figure:-

628 1 Y1 U 2 GridLayout

Which layout manager can be used to get the following output?


Figure:-

629 1 Y1 U 2 BorderLayout
Which layout manager can be used to get the following output?
Figure:-

630 1 Y1 U 2 GridLayout

Which layout manager is shown in the output?


Figure:-

631 1 Y1 U 2 GridLayout

Which Layout Manager places compenent inone of the five region


632 1 N A 2 BorderLayout
NORTH,SOUTH,WEST,EAST,CENTER.

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


634 Which method is incorrect while creating menubar 1 N U 2 MenuItem.add(MenuItem)

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

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

Which method is used to translate a mouse click on a specific point of


637 1 N U 2 getPathForLocation()
the tree to a tree?

Which method of Graphics class is to display "HelloWorld" on the


Applet shown in figure.
Figure:-

638 1 Y1 U 2 drawString(&quot;HelloWorld&quot;,30,30)

Which method of the component class is used to set the position and
639 1 N U 2 setBounds()
the size of a component?

Which method shows the complete process in percent on the progress


640 1 N U 2 setStringPainted(boolean)
bar?

Which method specifies that the text and icon are horizontally aligned
641 1 N U 2 jbt.setHorizontalTextPosition(JButton.RIGHT)
to the right in the button jbt.

Which methods are used to draw the following output?


Figure:-

642 1 Y1 U 2 a)drawPolygon(),fillPolygon()

All the methods in the JButton class are inherited from the javax.swing.AbstractButton
643 Which of following is true? 1 N U 2
class

Which of the following applet tags is legal to embed an applet class


644 named Test into a Web Pages ? < appletclass = Test width = 200 1 N A 2 B.&lt;applet code = Test. Class width = 200 height = 100&gt;
height = 100 >

Which of the following are container classes?


Figure:-
645 1 Y1 U 2 Frame and Panel

Which of the following commands will set a layout manager that


646 1 N U 2 setLayout( new GridLayout(4, 3) )
divides the container into 3 Columns & 4 Rows?

647 Which of the following constructor creates a Checkbox? 1 N U 2 Checkbox(String str, boolean s, null)

Which of the following create a list with five visible items and multiple
648 1 N U 2 new List(5,true)
selection enabled?

Which of the following creates a List with 3 visible items and multiple
649 1 N U 2 new List(3,false)
mode selection disabled?

650 Which of the following is not a AWT control 1 N U 2 Panel

651 Which of the following is not a constructor of FileDialog? 1 N U 2 FileDialog()

652 Which of the following is not a constructor of Jtree? 1 N U 2 JTree(int x)

Which of the following layout mangers honours the preferred size of


653 1 N U 2 FlowLayout
component( Multiple)

Which of the following method adds item "I" to the List with
654 1 N U 2 addItem(“I”)
deprecation warnings at the end of List?

Which of the following method use to check whether the JCheckBox


655 1 N U 2 jchk.isSelected()
jchk is selected?

Which of the following method use to get the text or caption of the
656 1 N U 2 jbt.getText()
button jbt?

Which of the following methods can be used to change the size of a


657 java.awt.Component object? (A) dimension() (B) setSize() (C) area() 1 N A 2 (B) &amp; (E)
(D) size() (E) resize()

Which of the following methods can be used to change the size of a


658 1 N U 2 setSize()
java.awt.Component object?

659 Which of the following methods create a LineBorder? 1 N U 2 B AND C

660 Which of the following options is correct about Layout Manager 1 N U 2 Both B and C

Which of the following statement is for placing the frames upper left
661 1 N A 2 frame.setLocation(200,100)
corner to (200,100)

Which of the following statement is used to create GridLayout in the


output shown below?
Figure:-
662 1 Y1 U 2 GridLayout g=new GridLayout(3,2);

Which of the following statements are true i) Scrollbar is a component


663 but not a Container ii)ScrollPane is a Container and performs its own 1 N U 2 i and ii both are true
scrolling

664 Which of the following statements are true? 1 N A 2 ALL

665 Which of the follwing is true about FlowLayout 1 N U 2 both A and B

Which of these classes can be added to any Container class, using the
666 1 N U 2 Button
add method defined in Container class ?

667 Which of these events will be notified if scroll bar is manipulated? 1 N U 2 AdjustmentEvent

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

Which of these methods are used to register a keyboard event


669 1 N U 2 addKeyListener()
listener?

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

671 Which of these methods can be used to know which key is pressed 1 N U 2 getModifier()

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

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

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

Create a Jtree Object, Create a JScrollPane object, Add the tree to the scrollpane and
675 Which option is correct to adding Jtree in an Applet? 1 N U 2
Add the scroll pane to the content pane of the applet.

676 which package contains color class? 1 N U 2 java.awt

677 Which package is used to add progress bar in an application? 1 N U 2 javax.swing.JProgrssBar

Which part of program Below will show an error: import java.awt.*;


import java.aaplet.*; import java.awt.event.*; public class Button1
extends Applet { MyButton b1; static int i=0; public void init() {
b1=new MyButton("My Button "); add(b1); } class MyButton extends
678 Button { public MyButton(String label) { super(); 1 N A 2 super();
enableEvents(AWTEvent.ACTION_EVENT_MASK); } protected void
processActionEvent(ActionEvent ae) { showStatus("Action Event : "+
i++); super.processActionEvent(ae); } } }

which statement is required for following output? import java.awt.*;


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)

Which Statement is required to obtain given output by using following


code public 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("FlowLayout");
setVisible(true); } public static void main(String arg[]) { fldemo f=new
fldemo(); } }
Figure:-

680 1 Y1 A 2 setLayout(new FlowLayout());

Which statement should be added to display button. import


java.awt.*; import javax.swing.*; /* <applet code="JButtonDemo"
width=250 height=300> </applet> */ public class JButtonDemo
681 extends JApplet { public void init() { Container contentPane = 1 N A 2 contentPane.add(jb);
getContentPane(); contentPane.setLayout(new FlowLayout());
ImageIcon img= new ImageIcon("jpgIcon.jpg"); JButton jb = new
JButton(img); } }

Which statements are missing in following program to get the output


as shown in fig /*<applet code=GridBagDemo width=300 height=300>
</applet>*/ import java.awt.*; import java.applet.*; public class
GridBagDemo extends Applet { GridBagLayout gdb=new
GridBagLayout(); GridBagConstraints c
______________________________: Button b1=new Button("One");
Button b2=new Button("Two"); 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.weightx=0.5;
c.weighty=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.gridwidth=3;
c.ipady=20; c.fill=GridBagConstraints.BOTH; gdb.setConstraints(b4,c);
c.gridx=0;c.gridy=3; c.ipady=0; c.insets=new Insets(20,20,20,20);
682 c.fill=GridBagConstraints.NONE; 1 Y1 A 2 both a&amp; b
c.anchor=GridBagConstraints.PAGE_START;
c.fill=GridBagConstraints.HORIZONTAL; gdb.setConstraints(b5,c);
add(b1);add(b2);add(b3);add(b4);add(b5); } }
Figure:-

Which statements are missing in the given code below. import


java.awt.*: Import java.awt.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);
683 1 N A 2 t= new TextArea ( 5,20);
b.addActionListener(this); } public void actionPerformed
(ActionEventae) { if (ae.getSource()==b) { repaint(); } } public void
paint ( Graphics gr ) { s=t.getText(0); gr.drawString ("User Address is :
" +s,150,150); } } /*<applet code = Pral width = 400 height = 300 >
</applet>*/

Which statements is missing in the given code below. import


java.awt.*; import java.awt. Event.*; import javax.swing.*; /*<applet
code = Colur width = 500 height = 500 ></applet>*/ public class Colur
extends J Applet implements ActionListener { Container cp =
getContentPane (); public void init () { cp.setLayout (new
FlowLayout()); JRadioButton b1= new JRadioButton("Red");
684 b1.addActionListener(this); cp.add(b1); JRadioButton b2 = new 1 N A 2 ButtonGroup bg= new ButtonGroup()
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.); } }

Which statements is missing in the given code below. import


javax.swing.*; public class FirstSwingExample { public static void main
( String [] args) { Jframe f =new Jframe();//creating instance of Jframe
685 Jbutton b = new Jbutton ("click") ;// creating instance of Jbutton b. 1 N A 2 f.SetVisible(true);
setBounds( 130,100,100,40);//x axis ,y axis , width,height f.
add(b);//adding button in JFrame f.seSize(400,500);//400 width and
500 height f.setLayout (null);//using no layout manager }}

Which statemnet is missing where ******* 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);
CP.add(l2);CP.add(t2); CP.add(b1);CP.add(b2); } }
Figure:-
686 1 Y1 A 2 l2=new JLabel(&quot;Password :: &quot;);

Which statemnet is missing in following code which will generate given


output:: 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("Word Count"));
Help.add(item6=new MenuItem("Help Topics")); //Adding menus to the
687 1 Y1 A 2 MenuBar mbar=new MenuBar();
menu bar mbar.add(format); mbar.add(Tool); mbar.add(Help); } }
Figure:-

Which swing component is shown in output?


Figure:-

688 1 Y1 U 2 c)Jtree

Which swing components use ListSelectionModel 1 N U 2 Jlist and Jtable


689

Which will be correct line of code at line no 16 1. Application level 2.


Import java.awt.*; 3. Import javax.swing.*; 4. /* 5. <applet
code=”JTextField1” width=300 height=50> 6. </applet> 7. */ 8. Public
690 class JTextField 1 extends JApplet 9. { 10. JTextField jtf; 11. Public void 1 N A 2 Container contentPane=getContentPane();
init() 12. { 13. JTextField jtf; 14. Public void init() 15. { 16. …………………
17. contentPane.setLayout(new FlowLayout()); 18. jtf=new
JTextField(15); 19. contentPane.add(jtf); 20. } 21. }

691 Why we need to write static keyword to main method ? 1 N U 2 To create single copy

Write a java program for following Output?


Figure:-

import java.awt.*; public class Butt extends Frame { public static void main(String
argv[]) { Butt MyBut=new Butt(); } Butt() { setLayout(new
692 1 Y1 A 2 FlowLayout(FlowLayout.CENTER)); Button HelloBut=new Button(&quot;Hello&quot;);
Button ByeBut=new Button(&quot;Bye&quot;); add(HelloBut); add(ByeBut);
setSize(300,300); setVisible(true); } }

write the command to compile the following code import java.awt.*;


import java.applet.*; import java.awt.event.*; public class Paneldemo
693 extends Frame { public void paneldemo() { Panel p=new Panel(); 1 N A 2 javac Paneldemo.java
p.setBackground(Color.black); add(p); } public static void main(String
args[]) { Paneldemo pd=new Paneldemo(); pd.setVisible(true);
pd.setSize(500,500); } }

Write the missing code? import javax.swing.*; public class Radio {


JFrame f; 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);
694 1 N A 2 f.add(r1); f.add(r2);
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(); } }

Write the sequence of component to be added on applet ? import


java.awt.*; import java.applet.*; /*<html><body> <applet
code=Demo height=500 width=500></applet> </body></html>*/
695 public class Demo extends Applet { Label l1,l2; Button b1; TextField 1 N U 2 Label, TextField, TextField, Label, Button
t1,t2; public void init() { l1=new Label("ID"); add(l1); l2=new
Label("Pass"); b1=new Button("Save"); t1=new TextField(10);
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

you can use methods___________________on any instance of


697 1 N U 2 setBackground
java.awt.Component

698 ______is a platform dependant. 1 N U 2 AWT

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

__________ is a Swing layout manager that arranges components in a


701 1 N U 2 BoxLayout
row & a column.

__________ is a widget that displays progress of a lengthy task, for


702 1 N U 2 Progressbar
instance file download or transfer.

___________ is a Swing layout manager that arranges components


703 1 N A 2 CardLayout
on top of each other in a deck.

______________ displays a message that alerts the user and waits


704 1 N A 2 Message dialog box
for the user to click the OK button to close the dialog.

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

___________________is a superclass of TextField and TextArea


706 classes that is used to create single-line or multiline textfields 1 N A 2 TextComponent
respectively:

C opyright © 2014 - 2015. All rights reserved.


MARATHAWADA MITRAMANDAL’S POLYTECHNIC, THERGAON, PUNE-33
Academic Year 2019-2020

Program: CO5I Course: Advanced Java Programming (22517) Course Co-ordinator: Mrs.Chavan P.P.
Unit I- Abstract Window Toolkit
Question Bank

Sr.No. Question Option A Option B Option C Option D

1 Give the Abbreviation of AWT : Applet WindowingToolkit Abstract Window Toolkit Absolute Windowing Toolkit None of these

Which is a component in AWT that can contain another components like


2 Window Container Panel Frame
buttons, textfields, labels etc.?

Which class provides many methods for


3 java.awt java.Graphics java.awt.Graphics None of these
graphics programming?
Which is the container that doesn't contain title
4 bar and MenuBars. It can have other components Window Frame Panel Container
like button, textfield etc ?
Which object can be constructed to show any
5 Choice Menu List Checkbox
number of choices in the visible window?

By which method we can set or change the text


6 setText() getText() addText() all of these
in a Label in AWT?

Which method of the Applet class displays the


7 run() method paint() method drawString() method main() method
result of applet code on screen ?

8 Applet can be embedded in _____________. HTML document word document gif file rtf file

Applets must run under The user I/O is not


Applets do not have mairu)
9 Which of the following is true about applet ? appletviewer or web performed using Java's all of these
method
browser stream I/O class

Creates text object that can


What does the following line of code do ? Creates text object that can Creates the object text and
10 hold 20 columns of This is invalid code
Textfield text = new Textfield(20); hold 20 rows oftext. initializes it with the value 20
text.

11 Executable applet is _________ .applet file .java html .java file .class file
12 Java applet are used to create_________applications. graphical user interactive both (a) and (b) none of the above

Which of these functions is called to display the


13 display() paint() display Applet() Show()
output of an applet ?

Which of these methods is a part of Abstract


14 display() paint() Show() all of the above
Window Toolkit (AWT) ?

Which object can be constructed to show any number of choices in the


15 Labels choice List Checkbox
visible window?

16 Which of the following class is derived from the container class? Component Panel MenuComponent List

When we invoke repaint() for a java.awt.Compdnent object, the AWT


17 draw() update() Show() paint()
invokes the method:

18 Which method executes only once? start() stop() init() destroy()

Which of these classes can be added to any Container class, using the add
19 Button CheckboxMenuItem Menu MenuBar
method defined in Container class?

Which of the following methods can be used to


20 dimension() setSize() area() size()
change the size of a java.awt.Component object ?

Which of the following methods can be used to remove a


21 disappear() delete() remove() hide()
java.awt.Component object from the display?

These two ways are used to create a Frame 1. By creating the object of
22 TRUE FALSE
Frame class (association) 2. By extending'Prame class (inheritance)

23 The title of the frame can be set in AWT using the method. setHeading setTitle CreateTitle Settitle

Which are passive controls that do not support any interaction with the
24 Choice List Label Checkbox
user?

25 How many ways can we align the label in a container? 1 2 3 4

Scroll bars, text area, text


26 The various controls supported by AWT are Labels, push buttons Checkboxes, choice, list All of these
field

Which layout manager places components in one of five regions: north,


27 AbsoluteLayout GridLayout BorderLayout FlowLayout
south, east, west, and center?
28 __________layout arranges the components horizontally: BorderLayout CardLayout GridLayout FlowLayout

29 The most commonly used layout managers are_____ FlowLayout GridLayout BorderLayout All of these

30 The subclasses of Window are Dialog Frame Both a & b None of these

31 Default layout manager for subclasses of window is _ cardlayout GridBaglayout Frame BorderLayout

32 Each menu is associated with a _________ list of menu items: Checkbox Drop-down Choice None of these

Which class can be used to represent a checkbox with a textual label that
33 MenuBar MenuItem CheckboxMenuItem Menu
can appear in a menu ?

34 Which abstract class is the super class of all menu related classes? MenuComponent MenuBar MenuItem CheckboxMenuItem

35 Menu items are added to ______ Menus MenuBar Frame Both a & b

36 Dialog box does not have minimize and maximize button TRUE FALSE

A dialog box is referred to as modeless if the user does not have to close it
37 TRUE FALSE
in order to continue using the application that owns the dialog box.

38 The __ class displays a dialog window from which the user can select a file. Dialog FileDialog File None of these

The setBackground() method is part of the following class in java.awt


39 Graphics Applet Container Component
package:

new TextArea(new
40 Which constructor creates a TextArea with 10 rows and 20 columns? Rows(10), new new TextArea(20, 10). new TextArea(10, 20). new TextArea(200).
columns(20)).

Which of the following creates a List with 5 visible items and multiple
41 new List(true, 5). new List(5, true). new List(5, false). new List(false,5).
selection enabled?

A Frame's background color is set to Color.Yellow, and a Button's


background color is to Color.Blue.Suppose the Button is added to a Panel,
42 Color.Yellow. Color.Blue. Color.Green. Color.White
which is added to the Frame. What background color will be used with the
Panel?
43 Which method will cause a Frame to be displayed? paint( ) setVisible( ) display( ) displayFrame( )

44 Which of the following components allow multiple selections? Combo box. Radio buttons. Choice. List.

45 Which method is method to set the layout of a container? startLayout( ). initLayout( ). layoutContainer( ). setLayout( ).

Which layout should you use to organize the components of a container in


46 CardLayout. BorderLayout. FlowLayout. GridLayout
a tabular form?

Pass a X/Y percentage


How do you indicate where a component will be positioned using Assign a row/column grid Do nothing, the FlowLayout
47 North, South,East,West. parameter to the add
Flowlayout? reference will position the component.
method.

48 Which of the following may contain a menu bar? A panel. .A frame. An applet. A menu bar.

A MenuItem can be added to .A Dialog can be added to a


49 Which of the following are true? A Dialog can have a MenuBar. MenuItem extends Menu.
a Menu. Menu.

Which of the following would create a text field able to display 10


50 new TextField("hello", 10); new TextField("hello"); new textField(10); new TextField();
characters (assuming a fixed size font) displaying the initial string "hello":

Using a FlowLayout manager, which is the correct way to add elements to a


51 add(x, y, component); set(component); add(component); add("Center", component);
container

52 Which object is needed to group Checkboxes to make them exclusive? RadiobuttonGroup. CheckboxGroup. ControlGroup. GroupCheckbox

A MenuItem can be added to A Menu can be added to a


53 Which of the following are true? A Dialog can have a MenuBar. MenuItem extends Menu.
a MenuItem Menu.

Arranges the components as a deck of cards such that only one component
54 BorderLayout CardLayout GridLayout FlowLayout
is visible at a time

55 __________ creates a dropdown list of textual entries Choice Checkbox Textbox TextComponent

56 Panel is used for __________ components Grouping Managing Deleting Modifying

_____________ is a superclass of TextField and TextArea classes that is used to


57 TextBox CheckBox TextComponent Choice
create single-line or multiline textfields respectively

You might also like