AJP Unitwise MCQ-5-14
AJP Unitwise MCQ-5-14
Unit I
Q. 1 Give the abbreviation of AWT ? Q. 8 How many types of controls does AWT supports
(a) Applet Windowing Toolkit these controls are subclasses of component?
(b) Abstract Windowing Toolkit (a) 7 (b) 6
(c) Absolute Windowing Toolkit (c) 5 (d) 8
(d) None of the above Q. 9 Which are passive controls that do not support any
Q. 2 Which is the container that contain title bar and interaction with the user?
can have MenuBars. It can have other components (a) Choice (b) List
like button, textfield etc.? (c) Labels (d) Checkbox
(a) Panel (b) Frame Q. 10 By which method You can set or change the text in
(c) Window (d) Container a Label ?
Q. 3 Which is a component in AWT that can contain (a) setText() (b) getText()
another components like buttons, textfields, labels (c) Both A & B (d) None of the above
etc.?
Q. 11 Which class is used to create a pop‐up list of items
(a) Window (b) Container from which the user may choose?
(c) Panel (d) Frame (a) List (b) Choice
Q. 4 AWT is used for GUI programming in java? (c) Labels (d) Checkbox
(a) True Q. 12 Which object can be constructed to show any
(b) False number of choices in the visible window?
Q. 5 Which class provides many methods for graphics (a) Labels (b) Choice
programming? (c) List (d) Checkbox
(a) java.awt Q. 13 Which is used to store data and partial results, as
(b) java.Graphics well as to perform dynamic linking, return values
(c) java.awt.Graphics for methods, and dispatch exceptions?
(d) None of the above (a) Window (b) Panel
Q. 6 These two ways are used to create a Frame (c) Frame (d) Container
By creating the object of Frame class (association) Q. 14 The following way is used to create a frame is by
By extending Frame class (inheritance) creating the object of Frame class?
(a) True (a) inheritance
(b) False (b) association
Q. 7 Which is the container that doesn't contain title (c) Both A & B
bar and MenuBars. It can have other components (d) None of the above
like button, textfield etc?
Q. 15 AWT more powerful components like tables, lists,
(a) Window
scroll panes, color chooser, tabbed pane etc.?
(b) Frame
(a) True (b) False
(c) Panel
(d) Container
Advanced Java Programming (MSBTE) M1-2 MCQ - Abstract Windowing Toolkit (AWT)
Q. 20 Which of the following is true about AWT and Q. 28 In the give constructor what third parameter
Swing components. indicates : ScrollBar s = new
ScrollBar(0,10,20,0,1000);
(a) AWT components creates a process where as
swing components creates a thread (a) size of thumb
(b) minimum value
(b) AWT components creates a thread where as
swing components creates a process (c) Increment value
(c) Both AWT and Swing components creates a (d) Initial Value
process Q. 29 Which class is used to represent a single line
(d) Both AWT and swing components creates a textbox with password character facility?
thread (a) TextField (b) TextArea
(c) Label (d) Checkbox
Q. 21 Panel is defined as ______________.
(a) The Panel class is a concrete subclass of Q. 30 To set the title to the Frame window ________
Container. method is used.
(b) A Panel is a window that does not contain (a) void setTitle(String str)
titlebar, menubar and border. (b) void setText(String str)
(c) Panel is a superclass of Applet. (c) void settitle(String str)
(d) All of the above. (d) None of the above
Advanced Java Programming (MSBTE) M1-3 MCQ - Abstract Windowing Toolkit (AWT)
Q. 31 Suppose a Panel is added to a Frame and a Button Q. 39 Which method is used to set password character
is added to the Panel. If the Frame’s font is set to for a TextField?
12 point Times New Roman, the panel’s font is set (a) setPasswordCharacter( )
10 points Times New Roman and the Button’s font (b) setEchoChar( )
is not set. What font will be used to display the
(c) setPassChar( )
Button’s label?
(d) setEchoCharacter( )
(a) 12 point Times New Roman
(b) 11 point Times New Roman Q. 40 The getContentPane( ) method is of which class?
(c) 10 point Times New Roman (a) JApplet
(d) 9 point Times New Roman (b) JFrame
(c) JButton
Q. 32 Which of the following is true about FlowLayout?
(d) None of these
(a) FlowLayout can use multiple rows if the
horizontal space in the container is too small Q. 41 Which class defines setSize( ) method?
to hold the component. (a) Frame
(b) FlowLayout is the default layout manager of (b) Applet
panel and applet. (c) Component
(c) It is the default layout manager for window. (d) Panel
(d) Both A & B.
Q. 42 __________ is a swing class that allows to enter a
Q. 33 Which of the method can be used to output a single line of text.
String in an Applet? (a) TextField
(a) display( ) (b) print( ) (b) JTextField
(c) drawString( ) (d) transient( ) (c) EditTextField
Q. 34 ___________ positions are the components into 5 (d) TextArea
regions east, west, south, north, center.
Q. 43 Which Text Component method is used to set a
(a) CardLayout (b) BorderLayout TextComponent to the read‐only state?
(c) GridLayout (d) FlowLayout (a) Editable
Q. 35 What is API? (b) NonEditable
(a) Application Programming Interchange (c) setEchoChar
(b) Application Programming Interaction (d) setEditable
(c) Application Programming Interface Q. 44 How would you set the color of graphics context
(d) None of these called g to cyan?
Q. 36 Panel is defined as _______. (a) g.setColor(“cyan”);
(a) Panel class is a concrete sub‐class of container (b) g.setCurrentColor(cyan);
(b) A Panel is a window that does not contain a (c) g.setColor(“Color.cyan”);
title bar, menu bar or border (d) g.setColor(Color.cyan);
(c) Panel is the superclass of Applet Q. 45 What is use of second parameter in given
(d) All of above constructor Lable(String,int)
Q. 37 Which component of AWT provides compact, (a) specifies height of label
multichoice, scrolling component? (b) specifies width of label in terms of pixel
(a) List (b) Choice (c) specifies the alignment of text in label in
(c) Panel (d) TextArea terms of pixel
(d) specifies width of label
Q. 38 When there is a switching condition like ON or
OFF, which control is used of following? Q. 46 The setBackground() method is part of which of
(a) Button (b) RadioButton the following class java.awt package?
(c) ToggleButton (d) TextField (a) Component (b) Applet
(c) Object (d) Graphics
Advanced Java Programming (MSBTE) M1-4 MCQ - Abstract Windowing Toolkit (AWT)
Q. 47 What does the following line of code do? Q. 56 Which of the following package is used for
TextField tf = new TextField(10); Graphical User Interface?
(a) will set 10 to TextField as its initial text. (a) java.applet (b) java.awt
(b) Will set the character capacity to 10 (c) java.awt.image (d) java.io
(c) Both A & B
Q. 57 What are the variables defined in Dimension?
(d) None of These (a) length and width
Q. 48 Frame is a standard window, which is __________ (b) height and length
of Window class from AWT hierarchy? (c) height and width
(a) Derived class / Subclass (d) None of these
(b) Base class / Super class
Q. 58 Which AWT component is not editable?
(c) Root class
(a) Button (b) TextField
(d) Family class
(c) FlowLayout (d) Label
Q. 49 A ____________ is a passive AWT control that do
Q. 59 Current text of Label can be obtained using
not generate any event?
__________.
(a) Button (b) RadioButton
(a) setAlignment( )
(c) Choice (d) Label
(b) getAlignment( )
Q. 50 The default layout manager of Frame is________. (c) getText( )
(a) FlowLayout (b) BorderLayout (d) setText( )
(c) GridLayout (d) CardLayout
Q. 60 The method ___________ places a Menu m into
Q. 51 Which method is used to check the status of the MenuBar mb.
checkbox? (a) mb.addMenuItem(m)
(a) getStatus( ) (b) getState( ) (b) mb.addItem(m)
(c) isChecked( ) (d) getChecked( ) (c) mb.add(m)
Q. 52 Which of the following method is used to set a (d) None of these
TextComponent to read‐only mode? Q. 61 Which of these Components cannot be added to
(a) Editable( ) (b) nonEditable( ) Frame?
(c) setEchoChar( ) (d) setEditable( ) (a) Label
Q. 53 _________ generates action events when an item (b) Button
is double‐clicked. (c) CheckboxGroup
(a) List (b) Checkbox (d) All of above
(c) MenuItem (d) TextField Q. 62 What is use of second parameter given in Label
Q. 54 Which of the following does not have its default constructor : Label(String, int)
layout as BorderLayout. (a) Specifies height of label in terms of pixels.
(a) Frame (b) specifies width of label in terms of pixels.
(b) Dialog (c) specifies the alignment of text in label in
(c) JApplet terms of pixels.
(d) All of Above (d) Specifies maximum numbers of characters in
label.
Q. 55 Which of the following statement about GUI
component is wrong? Q. 63 Which of these classes can be added to any
Container class, using the add method defined in
(a) swing exists since the version 1.2 of the JDK
Container class?
(b) AWT stands for Abstract Window Toolkit
(a) Button
(c) You cannot place AWT component on swing
(b) CheckboxMenuItem
container.
(c) Menu
(d) The AWT classes are deprecated.
(d) MenuBar
Advanced Java Programming (MSBTE) M1-5 MCQ - Abstract Windowing Toolkit (AWT)
Answers
Q.1 (b) Q.2 (b) Q.3 (b) Q.4 (a) Q.5 (c) Q.6 (a) Q.7 (c) Q.8 (a)
Q.9 (c) Q.10 (a) Q.11 (b) Q.12 (c) Q.13 (c) Q.14 (b) Q.15 (a) Q.16 (b)
Q.17 (b) Q.18 (a) Q.19 (a) Q.20 (c) Q.21 (d) Q.22 (c) Q.23 (a) Q.24 (c)
Q.25 (c) Q.26 (b) Q.27 (b) Q.28 (a) Q.29 (a) Q.30 (a) Q.31 (c) Q.32 (d)
Q.33 (c) Q.34 (b) Q.35 (c) Q.36 (d) Q.37 (a) Q.38 (c) Q.39 (b) Q.40 (d)
Q.41 (c) Q.42 (b) Q.43 (d) Q.44 (d) Q.45 (c) Q.46 (a) Q.47 (b) Q.48 (a)
Q.49 (d) Q.50 (c) Q.51 (b) Q.52 (d) Q.53 (c) Q.54 (d) Q.55 (c) Q.56 (b)
Q.57 (c) Q.58 (b) Q.59 (c) Q.60 (c) Q.61 (c) Q.62 (c) Q.63 (a) Q.64 (c)
Unit II
Q. 2 Swing is not a part of JFC (Java Foundation Classes) Q. 10 JTree class belongs to which package?
that is used to create GUI application? (a) java.awt (b) java.applet
(a) True (b) False (c) java.swing (d) javax.swing
Q. 3 The Swing Component classes that are used in Q. 11 Which component is swing represents data in row
Encapsulates a mutually exclusive set of buttons? and columns?
(a) AbstractButton (b) ButtonGroup (a) JTextArea (b) JTable
(c) JButton (d) ImageIcon (c) JPanel (d) JtabbedPane
Q. 4 The Java Foundation Classes (JF(c) is a set of GUI Q. 12 Which of the following is not constructor of JTree?
components which simplify the development of (a) JTree(TreeNode tn)
desktop applications? (b) JTree(Vector v)
(a) True (b) False (c) JTree(int x)
Q. 5 Which package is used for import the swing (d) none of the above
components? Q. 13 ____________class used to create node in tree.
(a) java.swing (b) java.awt (a) TreeNode
(c) javax.swing (d) All of the above (b) DefaultMutableNode
Q. 6 The String parameter to JButton constructor (c) DefaultMutableTreeNode
______________. (d) Node
(a) tell which region to put the JButton in.
Q. 14 JTabbedPane class is present in which package?
(b) tells the color of the JButton.
(a) java.awt (b) java.swing
(c) tells what text will appear on JButton.
(c) java.awt.swing (d) javax.swing
(d) tells what should happen when JButton is
pressed. Q. 15 What is purpose of JTree?
(a) To show data in form of parent and child
Q. 7 MVC architecture is _________
nodes.
(a) Modelling – Visual – Controller
(b) To show data in list view.
(b) Model – View – Controller
(c) To show data in tabular form.
(c) Model – Viewable – Controller
(d) To show data in menu‐bar.
(d) Many – View – Controller
Advanced Java Programming (MSBTE) M2-2 MCQ - Swings
Q. 16 What is the use of : Container getContentPane( ) Q. 19 From following list which is not Swing class?
(a) Returns Container for a JDialog. (a) JLabel
(b) Returns a ContentPane for Menu (b) JButton
(c) Returns a ContentPane for Applet (c) JImageIcon
(d) None of the above (d) JCheckBox
Q. 17 Which of the following method is not applicable Q. 20 Which component provides support for two‐state
for Button in swing. buttons?
(a) setDiableIcon( ) (b) setPressedIcon( ) (a) Button, Checkbox
(c) setSelectedIcon( ) (d) setRollOverIcon( ) (b) JCheckBox,JRadioButton
Q. 18 Which of the following method is used to retrieve (c) Button, MenuItem
icon of JButton? (d) JCheckBox, TextField
(a) Icon getIcon( )
(b) ImageIcon getImageIcon( )
(c) ImageIcon getIcon( )
(d) ImageIcon GetImageIcon( )
Answers
Q.1 (a) Q.2 (b) Q.3 (b) Q.4 (a) Q.5 (c) Q.6 (c) Q.7 (b) Q.8 (b)
Q.9 (a) Q.10 (d) Q.11 (b) Q.12 (c) Q.13 (c) Q.14 (d) Q.15 (a) Q.16 (c)
Unit III
Q. 1 The Following steps are required to perform Q. 8 In Graphics class Which method is used to set the
Implement the Listener interface and overrides its graphics current color to the specified color?
methods (a) public abstract void setFont(Font font)
Register the component with the Listener (b) public abstract void setColor(Color c)
(a) Exception Handling (b) String Handling (c) public abstract void drawString(String str, int
(c) Event Handling (d) None of the above x, int y)
Q. 2 In which places can put the event handling code (d) None of the above
(a) Same class (b) Other class Q. 9 Which of the following method is used to
(c) Annonymous class (d) All mentioned above determine the type of adjustment event?
Q. 3 Which package provides many event classes and (a) getType( )
Listener interfaces for event handling? (b) getEventType( )
(a) java.awt (b) java.awt.Graphics (c) getAdjustmentType( )
(c) java.awt.event (d) None of the above (d) getEventObjectType( )
Q. 33 Button Control implements following listener Q. 37 MouseEvent is subclass of which of the following
interface. class?
(a) ItemListener (b) ActionListener (a) ComponentEvent
(c) FlowListener (d) Adapter (b) ContainerEvent
Q. 34 Clicking the closing button on the upper right (c) ItemEvent
corner of a frame generates a (n)‐event. (d) InputEvent
(a) ItemEvent (b) WindowEvent Q. 38 The _________ is an object that is notified when
(c) MouseMotionEvent(d) ComponentEvent an event occurs.
Q. 35 Which of the following method must be (a) Listener
overridden in the order to handle KeyEvent. (b) Sources
(a) keyPressed(KeyEvent obj) (c) Event
(b) KeyReleased(KeyEvent obj) (d) None of the above
(c) KeyTyped(KeyEvent obj) Q. 39 What is the use of String getActionCommand( )
(d) All of these method of ActionEvent class?
Q. 36 Which of these methods can be used to know the (a) to obtain the label (caption) of Button
degree of adjustment made by the user? (b) to obtain the reference of Button
(a) getValue( ) (c) to obtain object of Button
(b) getAdjustmentType( ) (d) to obtain the label (caption) and object of
(c) getAdjustmentValue( ) Button
(d) getAdjustmentAmount( )
Answers
Q.1 (c) Q.2 (d) Q.3 (c) Q.4 (d) Q.5 (b) Q.6 (c) Q.7 (a) Q.8 (b)
Q.9 (c) Q.10 (b) Q.11 (a) Q.12 (d) Q.13 (d) Q.14 (d) Q.15 (b) Q.16 (d)
Q.17 (a) Q.18 (d) Q.19 (d) Q.20 (d) Q.21 (d) Q.22 (a) Q.23 (d) Q.24 (d)
Q.25 (b) Q.26 (d) Q.27 (c) Q.28 (c) Q.29 (a) Q.30 (d) Q.31 (d) Q.32 (c)
Q.33 (b) Q.34 (b) Q.35 (d) Q.36 (c) Q.37 (d) Q.38 (a) Q.39 (a)