AJP - MCQ (All Units) PDF Past Paper

Summary

This is a multiple-choice question paper for Advanced Java Programming. It covers topics on AWT and Swing components, including Layout Managers, panels, and various Java controls such as labels, buttons, checkboxes, etc.

Full Transcript

Maharashtra State Board of Technical Education (A utonomous) (ISO 9001:2008) (ISO/IEC 27001:2005) Welcome M1001 [117....

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); } } //Identify the correct output for the given code. import java.awt.*; import java.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.*; 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.*; 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.*; 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.*; 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.*; 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.*; 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.*; 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("hello"): 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 "Java" 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.*; public class Border extends Applet{ public void init() { BorderLyout br=new BorderLayout(); setLayout(br); Button b1=new Button("NORTH"); Button b2=new Button("SOUTH"); Button 346 1 Y1 A 2 b3=new Button("EAST"); Button b4=new Button("WEST"); Button b5=new Button("CENTER"); 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.*; 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("OK"); lbl1=new Button("Cancle"); lbl2=new Button("Exit"); add(lbl); add(lbl1); add(lbl2); } } Choose missing statements in following code from given options. import java.awt.*; import java.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.*; public class DemoApplet extends JApplet { JScrollPane jsp; JTable table; Container c; public void init() { c = this.getContentPane(); this.setLayout(new BorderLayout()); final String colhead[]={"Name","Address","Contact"); final 351 1 Y1 A 2 Object data[][]={ {"abc","pune","123"}, {"pqr","mumbai","456"}, {"xyz","nagpur","789"}}; 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); } } 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[] {"Id", "Name", "Hourly Rate","Part Time"}; } } Choose the correct Program for the following output Figure:- import java.awt.*;import java.applet.*; //<applet code="FontColor" width=200 height=200> //</applet> public class FontColor extends Applet { 354 1 Y1 A 2 Font f=new Font("Times New Roman",Font.ITALIC,14); public void init() { setFont(f); } public void paint(Graphics g) { g.setColor(Color.red); g.drawString("Hello Java",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("Root"); //create the child nodes DefaultMutableTreeNode vegetableNode = new DefaultMutableTreeNode("Vegetables"); DefaultMutableTreeNode 355 1 Y1 A 2 fruitNode = new DefaultMutableTreeNode("fruits"); //add the child nodes to the root node root.add(vegetableNode); root.add(fruitNode); //create the tree by passing in the root node tree = new JTree(root); add(tree); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setTitle("JTree Example"); 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.*; public class ComboDemo11 extends JApplet { public void init() { setLayout(null); 356 1 Y1 A 2 Container co = getContentPane(); String sports[]= {"cricket","football","hockey","tennis"}; 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("RedioButton Group"); Label la=new Label("What is your choice:"); fm.setLayout(new GridLayout(0,1)); CheckboxGroup cg1=new CheckboxGroup(); fm.add(la); Checkbox cb1=new 357 1 Y1 U 2 Checkbox("MATH",cg1,true); Checkbox cb2=new Checkbox("PHYSICS",cg1,false); Checkbox cb3=new Checkbox("CHEMISTRY",cg1,false); Checkbox cb4=new Checkbox("ENGLISH",cg1,false); fm.setVisible(true); fm.add(la); fm.add(cb1); fm.add(cb2); fm.add(cb3); fm.add(cb4); } } Choose the correct sequence for the following output Figure:- import java.awt.*; import java.applet.*; public class Appl extends Applet { public 358 1 Y1 A 2 void init() { Button b1=new Button("Button 1"); TextField tf = new TextField(); TextArea t1=new TextArea(3,20); Choice ch=new Choice(); ch.add("India"); Checkbox c=new Checkbox("a",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.*; public class CheckboxTest extends Applet { public void init( ) { Checkbox cb1=new 359 1 Y1 A 2 Checkbox("Shoes"); Checkbox cb2=new Checkbox("Socks",true); Checkbox cb3=new Checkbox("Shirt"); add(cb1); add(cb2); add(cb3); } } Choose the correct sequence for the following output Figure:- import java.awt.*; import java.applet.*; public class LabelDemo extends Applet { 360 1 Y1 A 2 public void init() { Label one = new Label("One"); Label two = new Label("Two"); Label three = new Label("Three"); 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("a",true); Checkbox c1=new Checkbox("b",false); add(tf); add(t1); add(c); add(c1); } } 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("a", true); Checkbox c1=new Checkbox("b" , 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("a",true); Checkbox c1=new Checkbox("b",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.*; public class Login extends Applet { TextField nm; TextField psw; public void init() { Label nml = new 365 1 Y1 A 2 Label("USername:", Label.RIGHT); Label pswl =new Label("Password:", Label.RIGHT); nm=new TextField(12); psw = new TextField(12); Button b=new Button("Submit"); 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.*; 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.*; 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.*; 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(""+n)); Font("SansSerif",Font.BOLD,24)); for(int i=0;i 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) & (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.*; 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 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& 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); } } Which statements is missing in the given code below. import java.awt.*; import java.awt. Event.*; import javax.swing.*; 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("Password :: "); 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. 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("Hello"); Button ByeBut=new Button("Bye"); 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.*; 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. Maharashtra State Board of Technical Education (A utonomous) (ISO 9001:2008) (ISO/IEC 27001:2005) Welcome M2001 [117.239.186.68] My Home Log Out e-Exam Manage Questions for Advanced Java Programming (17625) for topic 2 Go Back to Subjects Q To Fig Q Mar Question Answer No

Use Quizgecko on...
Browser
Browser