Full Transcript

Q.N Question optiona optionb optionc optiond correctanswer Correct Option 1 Model is the _________ of the MVC architecture....

Q.N Question optiona optionb optionc optiond correctanswer Correct Option 1 Model is the _________ of the MVC architecture. middle level top most level bottom most level none of these bottom most level optionc void void 2 Which method is used to change the name of a menu item String getLabel() setLabel(String boolean isEnabled() none of the above setLabel(String optionb newName) newName) 3 getContentPane() method of which class JApplet JFrame JButton None of this JApplet optiona 4 JTabbedPane class is present in which package? java.awt java.awt.event javax.swing javax.swing.table javax.swing optionc 5 How many checkboxes we can check at a time: 1 2 3 multiple multiple optiond Frame is a standard window,which is ____________________of Window class 6 sub class main class parent class super class sub class optiona from AWT hierarchy void void void 7 Which is/are the methods used in AbstractButton class setDisabledIcon(Ico setPressedIcon(Ico setRolloverIcon(Ico all of the above all of the above optiond n di) n pi) n ri) new TextArea(new new TextArea(10, new TextArea(20, new TextArea(10, 8 8. Which constructor creates a TextArea with 10 rows and 20 columns? Rows(10), new new TextArea(200) optiona 20) 10) 20) columns(20)) 9 Which of the following is not a swing class? JApplet JButton Canvas JLabel Canvas optionc new ImageIcon(&q new ImageIcon("c: new Icon("c: new ImageIcon("c:\ new Icon("c:\ 10 The method _______________creates a IconImage for file c:\image\us.gif uot;c: optiona \image\us.gif"); \image\us.gif"); \image\\us.gif"); \image\\us.gif"); \image\us.gif& quot;); 11 Which is Controll in swing a combination of a text field and a dropdown list Table ToolTip JComboBox JScrollPane JComboBox optionc 12 Default layout manager for Window is GridLayout CardLayout GridBaglayout Borderlayout Borderlayout optiond Which class is used to create a pop-up list of items from which the user may 13 List Choice Labels Checkbox Choice optionb choose? 14 getSelectedCheckbox() mehod of which class CheckboxGroup Checkbox Choice List CheckboxGroup optiona 15 The default layout manager of Frame is _____________ GridLayout GridBagLayout FlowLayout BorderLayout BorderLayout optiond 16 Which class is on the top of the AWT event hierarchy? java.awt.Event java.util.eventObjec javax.swing.Object optiona java.awt.AWTEvent java.awt.AWTEvent t 17 In AWT Radio buttons are created using_____________________ CheckBox RadioButton List CheckBoxGroup CheckBoxGroup optiond 18 __________ method is used to add the menubar on frame window. add() setMenubar() setMenuBar() addMenuBar( ) setMenuBar() optionc 19 Which method is used to check the status of checkbox setState() getState() setLabel() getLabel() getState() optionb ___________________ AWT component is used to create popup list of string items 20 List Choice MenuBar Scrollbar Choice optionb from which only one can be selected at a time. 21 __________ arranges the component in rows and column. BorderLayout FlowLayout GridLayout CardLayout GridLayout optionc 22 Which is the class responsible for handling key press activity. EventObject ActionEvent ObjectEvent KeyEvent KeyEvent optiond 23 Event Class library is define in following package Java.io java.util java.awt java.net java.util optionb Void void Void void void 24 The general form to set a specific type of layout manager is setLayout(Layoutm setLayout(layoutMa setLayout(LayoutM setLayout(LayoutM setLayout(LayoutM optiond anager lm) nager lm) anager lm) anager lm) anager lm) 25 To fetch caption of button___________ method is used. getText( ) getCaption( ) getLabel( ) None of these getLabel( ) optionc 26 To create a multiline ediitable control ________ class is used TextField TextArea Choice Button TextArea optionb 27 Which of the following controls does not support interaction with user? Label Button List Scroll bar Label optiona 28 A ____________ is a passive AWT control which do not generate any event. Button Label Checkbox List Label optionb When layout manager is disabled , which method is used to determine the 29 setPosition setSize SetDimension setBounds setBounds optiond shape and position of Component? 30 The _____________ class is used to create radio button in AWT RadioButton Button CheckboxGroup Chechbox CheckboxGroup optionc getsSelectedIndex 31 Which method returns the string of item which is currently selected. getSelectedItem ( ) select( int index) getItem (int index) getSelectedItem ( ) optiona () 32 To make the group of radio button______________ is used. ButtonGroup GroupButton GroupModel None of these ButtonGroup optiona Resizing Panel,Radiobutton, Titlebar,borders,res Titlebar,borders,res 33 By default the Frame has a ________________________________ Menubar,,borders. corners,borders,ch optionc button. izing corners izing corners eckbox You an determine which check box is currently selected by calling getSelectedCheckbo getSelectedcheckBo getSelectedCheckbo getSelectedCheckbo 34 getCheckBox() optiona _________method. x() x() xIndex() x() CheckboxMenuIte 35 Which abstract class is super class of menu related classes? MenuBar MenuItem MenuComponent MenuComponent optionc m DefaultMutableTre DefaultMutableTre 36 ________ class used to create node in tree. MutableTreeNode TreeNode Node optionc eNode eNode 37 What 'C' specifies in MVC architecture? Counting Checking Control cache Control optionc 38 Which is immediate super class for TextField? TextArea TextComponent JComponent Container TextComponent optionb JLabel (String 39 Which of the following is the constructor of JLabel. JLabel( ) JLabel(String str) All of the above All of the above optiond str,ImageIcon i) It can show It is a Only one item can It is a multiple selected 40 Following is true about List class multiple-choice be selected from All of these multiple-choice optiona items in the visible scrolling list. the list. scrolling list. window. new TextArea(new new TextArea(20 , new TextArea(10 , new TextArea(10 , 41 Which h costructor creates a TextArea with 10 rows and 20 columns ? Rows(10),new new TextArea(200 ) optionc 10 ) 20 ) 20 ) columns(20)). Creates the object Creates text object Creates text object Creates text object 42 1.What does the following line of code do? TextField text = new TextField(10); text and initializes that can hold 10 that can hold 10 The code is illegal that can hold 10 optionb it with the value 10 columns of text rows of text columns of text import import import import 43 Which package used for import the swing components? None of these optionb java.swing.*; javax.swing.*; java.awt.swing.*; javax.swing.*; 44 The default orientation of JProgressBar is ______________ Horizontal Vertical Both A and B None of the above Horizontal optiona 45 Which of the following may a menu contain? check box menu button panel menu optionb Which of these packages contains all the classes and methods required for 46 java.applet java.awt java.awt.event java.event java.awt.event optionc event handling in Java? 47 Which method is method to set the layout of a container? startLayout( ) initLayout( ) layoutContainer( ) setLayout( ) setLayout( ) optiond new new new 48 You can construct a JTabbedPane using ____________. new JTabbedPane() JTabbedPane(Comp JTabbedPane(Comp JTabbedPane(Comp new JTabbedPane() optiona onent) onent[]) onent, Component) 49 Which Listener handles all List related Events MouseListener ItemListener FocusListener ButtonListener ItemListener optionb Change in the state Change in the state Change in the state Change in the state Change in the state 50 Event is called as ______________ optiona of object. of Component of Textbox of Button of object. A. A listener is a A listener is a C. A listener is a A listener is a variable that is object that is method that is D. None of the object that is 51 What is a listener in context to event handling? optionb notified when an notified when an notified when an mentioned. notified when an event occurs. event occurs. event occurs. event occurs. ActionListener, ItemListener, WindowListener, 52 Some of the event listener interfaces are_____________ All of these All of these optiond ComponentListener KeyListener MouseListener 53 Which of these interfaces define a method actionperformed()? ComponentListener ContainerListener ActionListener InputListener ActionListener optionc 54 Which of these interfaces define a method itemStateChanged()? ComponentListener ContentListener ActionListener ItemListener ItemListener optiond If a class extends the ActionListener interface, it must contain a method called 55 actionPerformed() ActionEvent() Componentadded() None Of The Above actionPerformed() optiona __________. An event is an An event is an An event is an An event is a class An event is an object that object that  What is an event in delegation event model used by Java programming object that used for defining object that 56 describes a state describes any optiona language? describes a state object, to create describes a state change in change by the user change in a source. events. change in a source. processing. and system. 57 EventObject is in ______________package. java.applet java.util java.io none of the above java.util optionb 58 What is the return type of getItem() Object int String All of these Object optiona 59 FocusEvent is subclass of which of these calsses ? ComponenEvent ContainerEvent ItemEvent InputEvent ComponenEvent optiona 60 ComponenetEvent is the superclass of _______________. FocusEvent MouseEvent WindowEvent All of the above All of the above optiond 61 The ________ interface is used to handle button events: ContainerListener ItemListener ActionListener WindowListener ActionListener optionc TEXT_VALUE_CHA TEXT_CHANGED_V TEXT_VALUE_CHA 62 TextEvent defines the integer constant__________________ text_value_changed text_changed_value optiona NGED ALUE NGED 63 Focus events are fired whenever a component _____________________the focus gains or loses ideal gains loses gains or loses optiona Using Using Using Using Using getAction( ) 64 How to obtain the command name for invoking ActionEvent? getActionCommand getCommand( ) obtainAction( ) getActionCommand optiona method. ( ) method. method. method. ( ) method. 65 Interface used to handle menu events is ContainerListner ActionListner FocusListner WindowListner ActionListner optionb 66 Which of these is superclass of all Adapter classes? Applet ComponenetEvent Event InputEvent Applet optiona all of the all of the 67 Which of these methods will respond when you click any button by mouse? mouseClicked() mouseEntered() mousePressed() optiond mentioned mentioned Which of these packages contains all the classes and methods required for 68 javapplet java.awt java.event java.awt.event java.awt.event optiond even handling in Java? 69 ___________is the abstract superclass for all component input event classes InputEvent ItemEvent AdjustmentEvent WindowEvent InputEvent optiona AdjustmentValueCh 70 Method of ActionListener Interface which need to overide actionPerformed() itemStateChanged() None of Above actionPerformed() optiona anged() when we need to use check boxes or item from the list or use a checkable 71 ActionEvent ItemEvent AdjustmentEvent ComponentEvent ItemEvent optionb menu,an _________________is generated. 72 The KeyEvent class does not defines the _____________integer constant. KEY_PRESSED KEY_ENTERED KEY_RELEASED KEY_TYPED KEY_ENTERED optionb displayTitle(String showTitle(String addTitle(String 73 Which method is used to display title on titlebar of Frame? setTitle(String title) setTitle(String title) optionb title) title) title) 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"); Button and Button CheckBox and Button and 74 Applet And Panel optiona ImageIcon andRadioButton ImageIcon ImageIcon 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); } } rollOverIcon(Image setIcon(ImageIcon displayIcon(ImageI removeIcon setIcon(ImageIcon 75 Which method is used to display icon on a JButton component? optionb Icon i) i) con i) (ImageIcon i ) i) Which of the following creates a List with 5 visible items and multiple 76 new List(5, true) new List(true, 5) new List(5, false) new List(false, 5) new List(5, true) optiona selection enabled? 1. Create a 1. Create a JTabbedPane object JTabbedPane object 1. Create a 1. Create a 1.Add the Tabbed JTabbedPane object 2. Call addTab() to JTabbedPane object Pane to the content 2. Call addTab() to 2. Call addTab() to Add a tab to the 2.Repeat Step 2 for Pane of the Applet Add a tab to the Add a tab to the 77 Steps for Adding TabbedPane Control pane each Tab 2.Repeat Step 2 for pane optiona pane 3.Repeat Step 2 for 3. Call addTab() to each Tab 3.Repeat Step 2 for 3. Add the Tabbed each Tab Add a tab to the 3.Create a each Tab Pane to the content 4. Add the Tabbed pane JTabbedPane object 4. Add the Tabbed Pane of the Applet Pane to the content Pane to the content pane pane Write the sequence of component to be added on applet ? import java.awt.*; import java.applet.*; public class Demo extends Applet { Label l1,l2; Button b1; TextField t1,t2; Label, Label, Label, TextField, Label, TextField, Label, TextField, Label, TextField, public void init() 78 TextField, TextField, Label, Label, TextField, TextField, Button, TextField, Label, optionb { TextField, Button Button Button Label Button 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); } } JRadioButton ,JText JRadioButton ,JText Jcheckbox,JTextFiel JRadioButton ,JText 79 Which Components are used in Following output? CheckBox,TextArea optionb Area Field d Field ScrollPanel displays ScrollPane displays ScrollPane Displays ScrollPane Displays 80 What is the purpose of ScrollPane component in component in Tree component in a None component in a optionc Tabular form form rectangular area rectangular area MOUSE_ENTERED 81 Which method is used to processes mouse click? MouseClicked() Mouse_CLICKED() MOUSE_PRESSED() MouseClicked() optiona () setLayout( new Which of the following commands will set a layout manager that divides the setLayout( new setLayout( new setLayout( new setLayout( new 82 GridBagLayout(4, optiond container into 3 Columns & 4 Rows? GridLayout(3, 4) ) FlowLayout(4, 3) ) GridLayout(4, 3) ) GridLayout(4, 3) ) 3 )) Consider the following output. Find the missing statement in the program. import java.awt.*: import java.awt.event.*; import javax.swing.*; public class JCheckBoxDemo extends JApplet implements ItemListener { JTextField jtf; public void init() { Container contentPane = getContentPane(); contentPane.setLayout(new FlowLayout()); JCheckBox cb = new JCheckBox("C", true); cb.addItemListener(this); contentPane.add(cb); cb = new JCheckBox("C++", false); cb.addActionListen cb.addItemListener contentPane.addIte contentPane.add(jc cb.addItemListener 83 optionb contentPane.add(cb); er(this) (this); mListener(this); b); (this); cb = new JCheckBox("Java", false); cb.addItemListener(this); contentPane.add(cb); cb = new JCheckBox("Perl", false); cb.addItemListener(this); contentPane.add(cb); jtf = new JTextField(15); contentPane.add(jtf); } public void itemStateChanged(ItemEvent ie) { JCheckBox cb = (JCheckBox)ie.getItem(); jtf.setText(cb.getText()); } } To obtain the To obtain the To obtain the To obtain the To obtain the object label(caption) 84 What is the use of String getActionCommand( ) method of ActionEvent class? label(caption) of label(caption) of optiona reference of Button of Button & object of Button Button Button 85 The follwowing is an example of which layout? CardLayout null Layout BorderLayout GridLayout CardLayout optiona 86 Which among the below is not the method applicable for Button in swing setDisableIcon() setPressedIcon() setSelectedIcon() setRollovericon() setDisableIcon() optiona 87 In CardLayout we are going to add components for every card to Panel Window Frame Applet Panel optiona The concept of the menu bar canbe implemented by using three java 88 MenuBar Menu MenuItem All of these All of these optiond classes— A tree is a A tree is a component that component that Tree is used to Tree is used display Tree is used for 89 What is Purpose of Jtree ? presents a presents a optiona display icon button Label hierarchical view hierarchical view of data of data 90 _______method to specify the text for a standard tooltip. setToolTipText() JToolTip() getToolTipText() createTooltip() setToolTipText() optiona Applet , Button , Frame,Button,Flow Label,Button, Label,Button, Label , Button, 91 Which components are used in the following output? FlowLayout ,Radio Layout ,RadioButto TextField, TextField, optiond TextArea, Checkbox Button n Checkbox Checkbox Used to disable Used to disable Used to invisible Used to disable 92 setEnabled(false); method used in menuitem for _______________________ None of the above optiona menu item menu menuitem menu item What will be displayed when you run the following code. import java.awt.*; import javax.swing.*; public class Demo2 extends JFrame { Demo2() { JButton b1=new JButton("Hello"); JButton b2=new JButton("Welcome"); 93 add(b1); S1Q28O1.jpeg S1Q28O2.jpeg S1Q28O3.jpeg S1Q28O4.jpeg S1Q28O4.jpeg optiond add(b2); setSize(300,300); setVisible(true); } public static void main(String argv[]) { Demo2 d=new Demo2(); } } ScrollPane, Label, Scrollbar, Label, Scrollbar, Label, ScrollPane, Label, Scrollbar, Label, 94 Which components are used in the following output? optionc List List Choice Choice Choice Find out missing statement from following code import java.awt.*; import java.awt.event.*; import java.applet.*; public class choice extends Applet { { 95 public void init() add(choice) import java.event.*; None of the above public void init() optiona Choice c=new Choice(); c.add("red"); c.add("yellow"); add(c); } } Swing provides a combo box (a combination of a text field and a drop-down 96 list) Component Container Jcomponent java.swing Jcomponent optionc through the JComboBox class, which extends __________________. What will be output of following program import java.awt.*; import java.applet.*; import java.awt.event.*; public class tbutton extends Applet implements ActionListener { Button b; One Button will be public void init() One Button will be One Button will be One Button will be One Button will be displayed with { Displayed and Displayed and Displayed and 97 Displayed with caption start and optionc b=new Button("Start"); Event will be event will not be event will not be caption stop event will be add(b); handled handled handled handled } public void actionPerformed(ActionEvent ae) { String s=b.getLabel(); if(s.equals("Start")) b.setLabel("Stop"); else b.setLabel("Start");}} Applet,Frame,Menu Applet,Frame,Menu Applet,Menu,MenuI Frame,Menu,MenuI 98 Identify the components in the given output ,MenuItems,MenuB Frame,Menu ,MenuItems,MenuB optiona tems tem,MenuBar ar ar select the missing statement in the program for the following output import java.awt.*; import java.awt.event.*; import java.applet.*; public class ColorChange extends Applet implements ActionListener { Button red; public void init() addActionListener(t red.addActionListe red.addActionListe red.addActionListe red.addActionListe 99 optionb { his); ner(this); ner(); ner(this) ner(this); red=new Button("RED"); add(red); } public void actionPerformed(ActionEvent e) { setBackground(Color.red); repaint(); } } Which of the following is not one of the seven methods for handling window 100 windowClosing windowClosed windowOpened windowOpening windowOpening optiond events? Button b1=new Choose correct statement from following which implements "create button Button b1=new Button b1=new Button b1= button b1=new 101 Button(" optiona with caption 'ok' " Button("ok"); Button(); Button("ok"); button("ok"); ok"); import java.applet.Applet; import java.awt.Button; import java.awt.Graphics; import import java.awt.event.Acti java.applet.Applet; import onEvent; import import java.applet.Applet; import java.applet.Applet; import java.awt.Button; import java.awt.event.Acti import java.applet.Applet; import java.awt.Button; onListener; java.awt.Button; import java.awt.Graphics; import import java.awt.Button; import java.awt.Graphics; Example extends height=200/> */ Applet implements */ public class ActionListener */ HandleActionEvent public class { public class Example extends HandleActionEvent String HandleActionEvent public class Applet implements Example extends actionMessage=&a Example extends HandleActionEvent ActionListener Applet implements mp;quot;&quo Applet implements Example extends { ActionListener{ t;; ActionListener Applet implements String String { ActionListener actionMessage=""; actionMessage=""; public void init() String { { actionMessage; String public void init() public void init(){ actionMessage=""; { Button Button1 = public void init() Button Button1 = new { public void init() Button Button1 = new Button("Ok"); Button(" { new Button("Ok"); Button Button2 = Ok"); Button Button1 = 102 Which is the correct code for following output Button Button2 = new Button Button2 = optiona new Button("Ok"); Button Button1 = new Button("Cancel"); new Button Button2 = new Button("Ok"); Button("Cancel"); Button(" new add(Button1); Cancel"); Button("Cancel"); add(Button1); add(Button2); add(Button1); add(Button1); add(Button2); Button1.addAction add(Button2); add(Button2); Button1.addAction Listener(this); Listener(this); Button2.addAction Button1.addAction Button1.addAction } Button2.addAction Listener(this); Listener(this); Listener(this); Listener(this); } Button2.addAction Button2.addAction public void } Listener(this); Listener(this); paint(Graphics g){ public void } } g.drawString(action public void paint(Graphics g){ Message,10,50); paint(Graphics g){ g.drawString(action public void public void } g.drawString(action Message,10,50); paint(Graphics g){ paint(Graphics g){ public void Message,10,50); } g.drawString(action g.drawString(action actionPerformed(A Which of following constants is not defined in WindowEvent class? a)WINDOW_ACTIVATED 103 b) WINDOW_CLOSED a and c c b d d optiond c) WINDOW_DEICONIFIED d) none of the above True,False,True,Fal False,True,False,Tr False,False,True,Tr True,True,False,Fal True,False,True,Fal 104 Identify correct sequence of states of following controls optiona se ue ue se se Which of these interfaces handles the event when a component is added to a 105 ComponentListener ContainerListener FocusListener InputListener ContainerListener optionb container? mouseDragged, mouseExited,mous mouseExited,mous mouseDragged,mo mouseExited,mous mousePressed,mou eEntered,mousePre eEntered,mousePre usePressed,mouseC eEntered,mousePre 106 MouseListener interface belongs which of the following methods? seReleased,mouseCl optionb ssed,mouseClicked, ssed,mouseClicked, licked,mouseMoved ssed,mouseClicked, icked,mouseMoved mouseMoved,mous mouseReleased ,mouseReleased mouseReleased eReleased Select the missing statement in given code import java.awt.*; import java.awt.event.*; import java.applet.*; public class SimpleKey extends Applet { String msg = ""; int X = 10, Y = 20; // output coordinates public void init() { addKeyListener(this); requestFocus(); // request input focus } implements implements implements extends implements 107 public void keyPressed(KeyEvent ke) optionb MouseListener KeyListener keylistener KeyListener KeyListener { showStatus("Key Down"); } public void keyReleased(KeyEvent ke) { showStatus("Key Up"); } public void keyTyped(KeyEvent ke) { msg += ke.getKeyChar(); repaint(); } // Display keystrokes. public void paint(Graphics g) { g.drawString(msg, X, Y); } } Checkbox, Choice, Button, TextField, Button, TextField, 108 Action event is applied on Frame Scrollbar optiond List List, Menu List, Menu Which of following purpose of the enableEvents() method is true? A)The enableEvents() method is used to enable an event for a particular object. 109 A and B only A Only B None of these A and B optiona B)The enableEvents() method is used by objects that handle events by overriding their event-dispatch methods. Which of the following statements registers a panel object p as a listener for a addActionListener( jbt.addActionListen jbt.addActionEvent jbt.addEventListene jbt.addActionListen 110 optionb button variable jbt? p) er(p) Listener(p) r(p) er(p) ActionListener and ActionListener and ItemListener and ActionListener and 111 To handle JRadiobutton which Listener and Event Class is Required? None of the Above optiona ActionEvent ItemEvent ItemEvent ActionEvent public String Select the method used to determine the event ID that represents the natures public object 112 public int getID() getActionCommand none of above public int getID() optiona of the event getSource() () The AWT container is an instance of the ___________ class which holds various 113 Graphics Container Eventobj None of these Container optionb components and other containers 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"); b1.addActionListener(this); cp.add(b1); JRadioButton b2 = new JRadioButton("Green"); b2.addActionListener(this); cp.add(b2); JRadioButton("Green"); ButtonGroup bg= ButtonGroup bg= Button bg = new ButtonGroup = new ButtonGroup bg= 114 b3.addActionListener(this); new ButtonGroup optionb new ButtonGroup() ButtonGroup () ButtonGroup() new ButtonGroup() cp.add(b3); (this) bg.add(b1); bg.add(b2); bg.add(b3); } public void action Performed(ActionEvent ae ) { String s; s= ae.getActionCommand(); if (s=="Red") cp.setBackground(Color.red); else if (s=="Green") cp.setBackground(Color.green); else if (s=="Blue") cp.setBackground (Color.blue.); } } 115 Which is the layout manger that occupies the same size on the window? Grid Card Flow Border Grid optiona // What will be output for following program: import java.applet.*; import java.awt.*; public class sample extends Applet { public void init() { Label l1=new Label(" MSBTE"); List l2=new List(3,true); 116 l2.addItem("1"); S1Q43O1.jpeg S1Q43O2.jpeg S1Q43O3.jpeg Error S1Q43O3.jpeg optionc l2.addItem("2"); l2.addItem("3"); TextArea t1=new TextArea(3,4); add(t1); add(l1); add(l2); } } 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 MenuItem("Exit"); statement where statement where statement where statement where statement where 117 i4=new MenuItem("Cut"); File menu is New menu item is New menu item is setMenuBar() setMenuBar() optiond i5=new MenuItem("Copy"); created created added to File menu method is invoked method is invoked 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); } } Analyze the following code : import java.awt.*; import javax.swing.*; public class Test { Both button OK and Both button OK and public static void main(String[] args) { button Cancel are button Cancel are JFrame frame = new JFrame("My Frame"); displayed and displayed and Only button OK is Only button Cancel Only button Cancel 118 frame.add(new JButton("OK")); button OK is button OK is optionb displayed. is displayed. is displayed. frame.add(new JButton("Cancel")); displayed on the displayed on the frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); left side of button right side of button frame.setSize(200, 200); OK. OK. frame.setVisible(true); } } An arc bounded by An arc bounded by An arc bounded by An arc bounded by An arc starting at a box of height 45, a box of height 50, a box of height 50, a box of height 50, 45 degrees, width 90 with a width 50, with a width 50, with a top width 50, with a top traversing through centre point of centre point of left at coordinates left at coordinates Where g is a graphics instance what will the following code draw on the 90 degrees 50,50, starting at an 45,90 starting at an of 45, 90, starting at of 45, 90, starting at 119 screen clockwise bounded optionc angle of angle of 90 90 g.fillArc(45,90,50,50,90,180); by a box of height 90 degrees 90 degrees degrees and degrees and 50, width 50 with a traversing through traversing through traversing through traversing through centre point of 90, 180 degrees 180 degrees 180 degrees 180 degrees 180 counter clockwise clockwise counter clockwise counter clockwise 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 b4=new JButton("Sangali"); add(b4); } Javac appletviewer appletviewer 120 } java tabbeddemo All of above optionc tabbeddemo.java tabbeddemo.java tabbeddemo.java class ColorPanel extends JPanel { public ColorPanel() { JRadioButton rb1=new JRadioButton("Red"); add(rb1); JRadioButton rb2=new JRadioButton("Green"); add(rb2); JRadioButton rb3=new JRadioButton("Blue"); add(rb3); JRadioButton rb4=new JRadioButton("Pink"); add(rb4); } } class FlavoursPanel extends JPanel { public FlavoursPanel() { JComboBox jc=new JComboBox(); jc.addItem("Vanilla"); jc.addItem("Chocalate"); jc.addItem("Straberry"); add(jc); } } Scrollbar vert = Scrollbar vert = Scrollbar vert = new Scrollbar vert = Scrollbar vert = new new Scrollbar(Scrollbar. new new Scrollbar(SCROLLB Scrollbar(Scrollbar. VERTICAL,0, 1, 0, Scrollbar(Scrollbar. Scrollbar(Scrollbar. AR.VERTICAL, 1, 0, VERTICAL,0, 1, 0, 100); VERTICAL,0, 1,); VERT,0, 1, 0, 100); 100); 100); 121 Which code is correct to generate the following output? optiona Scrollbar horz = Scrollbar horz = Scrollbar horz = Scrollbar horz = Scrollbar horz = new new new new new Scrollbar(Scrollbar. Scrollbar(Scrollbar. Scrollbar(Scrollbar. Scrollbar(SCROLLB Scrollbar(Scrollbar. HORIZONTAL, 0, 1, HORIZONTAL, 0, 1); HOR, 0, 1, 0, 100); AR.HORIZONTAL, 1, HORIZONTAL, 0, 1, 0, 100); 0, 100); 0, 100); import java.awt.*; class Demo extends Frame { public static void main(String args[]){ using void using Void using using 122 Frame f=new Frame(); using hide(false); optionc setHide(); makeHidden(1); setVisible(false); setVisible(false); f.setVisible(true); f.setSize(150,200); } } In the above program how can a user hide the frame window if user use following statements in given order on CheckBox B1(“asd†,true) what will happen.... RadioButton c will RadioButton c will RadioButton c will 1. B1.setState(true); created with Checkbox is created Checkbox created created with created with 123 optiona 2. B1.setState(false); checkbox asd with selected with deselected checkbox asd checkbox asd 3. CheckBoxGroup c=new CheckBoxGroup(); deselected selected deselected 4. B1.setCheckBoxGroup(c); import java.awt.*; import java.awt.*; public class Butt import java.awt.*; import java.awt.*; public class Butt extends Frame import java.awt.*; public class Butt public class Butt extends Frame { public class Butt extends Frame extends Frame { public static void extends Frame { { public static void main(String argv[]) { public static void public static void main(String argv[]) { public static void main(String argv[]) main(String argv[]) { Butt MyBut=new main(String argv[]) { { Butt MyBut=new Butt(); { Butt MyBut=new Butt MyBut=new Butt(); } Butt MyBut=new Butt(); Butt(); } Butt() Butt(); } } Butt() { } Butt() Butt() { setLayout(new Butt() { { setLayout(new FlowLayout(FlowLa { setLayout(new setLayout(new 124 Write a java program for following Output? FlowLayout(FlowLa yout.CENTER)); optiond Button GridLayout(1,2)); GridLayout(2,1)); yout.CENTER)); Button HelloBut=new Button Button Button HelloBut=new Button("Hello"); HelloBut=new HelloBut=new HelloBut=new Button(" Button Button("Hello"); Button("Hello"); Button("Hello"); Hello"); ByeBut=new Button Button Button Button Button("Bye"); ByeBut=new ByeBut=new ByeBut=new ByeBut=new add(HelloBut); Button("Bye"); Button("Bye"); Button("Bye"); Button(" add(ByeBut); add(HelloBut); add(HelloBut); add(HelloBut); Bye"); setSize(300,300); add(ByeBut); add(ByeBut); add(ByeBut); add(HelloBut); setVisible(true); setSize(300,300); setSize(300,300); setSize(300,300); add(ByeBut); } setVisible(true); setVisible(true); setVisible(true); setSize(300,300); } } } } setVisible(true); } } } } } 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", "Stop", "Pause","Resume" }; Panel p1 = new Panel(); for (int i=0; i

Use Quizgecko on...
Browser
Browser