0% found this document useful (0 votes)
17 views54 pages

AJP MCQ

The document consists of a series of questions and answers related to the Abstract Windowing Toolkit (AWT) and Swing in Java, covering topics such as components, layouts, and event handling. It includes multiple-choice questions with correct answers indicated for each. The content serves as a study guide or quiz for understanding AWT and Swing functionalities in Java programming.

Uploaded by

sumitshinde0088
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views54 pages

AJP MCQ

The document consists of a series of questions and answers related to the Abstract Windowing Toolkit (AWT) and Swing in Java, covering topics such as components, layouts, and event handling. It includes multiple-choice questions with correct answers indicated for each. The content serves as a study guide or quiz for understanding AWT and Swing functionalities in Java programming.

Uploaded by

sumitshinde0088
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 54

Chapter 1 : Abstract Windowing Toolkit (AWT)

01 – Abstract Windowing Toolkit (AWT)

Q. 1. Give the abbreviation of AWT ?


(a) Applet Windowing Toolkit
(b) Abstract Windowing Toolkit
(c) Absolute Windowing Toolkit
(d) None of the above
Answer: b

Q. 2 Which is the container that contain title bar and can have
MenuBars. It can have other components
like button, textfield etc.?
(a) Panel (b) Frame
(c) Window (d) Container
Answer: b

Q. 3 Which is a component in AWT that can contain another components


like buttons, textfields, labels etc.?
(a) Window (b) Container
(c) Panel (d) Frame
Answer:b

Q. 4 AWT is used for GUI programming in java?


(a) True
(b) False
Answer:a

Q. 5 Which class provides many methods for graphics programming?


(a) java.awt
(b) java.Graphics
(c) java.awt.Graphics
(d) None of the above
Answer:c
01 – Abstract Windowing Toolkit (AWT)

Q. 6 These two ways are used to create a Frame By creating the object
of Frame class (association) By
extending Frame class (inheritance)
(a) True
(b) False
Answer:a

Q. 7 Which is the container that doesn't contain titlebar and


MenuBars. It can have other components like
button, textfield etc?
(a) Window
(b) Frame
(c) Panel
(d) Container
Answer:c

Q. 8 How many types of controls does AWT supports these controls are
subclasses of component?
(a) 7
(b) 6
(c) 5
(d) 8
Answer:a

Q. 9 Which are passive controls that do not support any interaction


with the user?
(a) Choice
(b) List
(c) Labels
(d) Checkbox
Answer:c

Q. 10 By which method You can set or change the text in a Label ?


01 – Abstract Windowing Toolkit (AWT)
(a) setText()
(b) getText()
(c) Both A & B
(d) None of the above
Answer:a

Q. 11 Which class is used to create a pop‐up list of items from


which the user may choose?
(a) List
(b) Choice
(c) Labels
(d) Checkbox
Answer:b

Q. 12 Which object can be constructed to show any number of choices


in the visible window?
(a) Labels
(b) Choice
(c) List
(d) Checkbox
Answer:c

Q. 13 Which is used to store data and partial results, as well as to


perform dynamic linking, return values
for methods, and dispatch exceptions?
(a) Window
(b) Panel
(c) Frame
(d) Container
Answer:c

Q. 14 The following way is used to create a frame is by creating the


object of Frame class?
(a) inheritance
01 – Abstract Windowing Toolkit (AWT)
(b) association
(c) Both A & B
(d) None of the above
Answer: c
Q. 15 AWT more powerful components like tables, lists, scroll panes,
color chooser, tabbed pane etc.?
(a) True
(b) False
Answer: a

Q. 16 These four methods commonly used in?


(i) public void add(Component c)
(ii) public void setSize(int width,int height)
(iii) public void setLayout(LayoutManager m)
(iv) public void setVisible(boolean)
(a) Graphics class
(b) Component class
(c) Both A & B
(d) None of the above
Answer: b

Q. 17 In Graphics class which method is used to draws a rectangle


with the specified width and height?
(a) public void drawRect(int x, int y, int width, int height)
(b) public abstract void fillRect(int x, int y, int width, int
height)
(c) public abstract void drawLine(int x1, int y1, int x2, int y2)
(d) public abstract void drawOval(int x, int y, int width, int
height)
Answer: b

Q. 18 Implement the Listener interface and overrides its methods is


required to perform in event handling?
(a) True
01 – Abstract Windowing Toolkit (AWT)
(b) False
Answer: a

Q. 19 Public class MenuBar extends .


(a) MenuComponent
(b) MenuContainer
(c) ComponentMenu
(d) MenuBar
Answer: a

Q. 20. Which of the following is true about AWT and Swing components?
(a) AWT components creates a process where as swing components
creates a thread
(b) AWT components creates a thread whereas swing components creates
a process
(c) Both AWT and Swing components creates a process
(d) Both AWT and swing components creates a thread
Answer: c

Q. 21 Panel is defined as .
(a) The Panel class is a concrete subclass of Container.
(b) A Panel is a window that does not contain titlebar, menubar and
border.
(c) Panel is a superclass of Applet.
(d) All of the above.
Answer: d

Q. 22. What is API?


(a) Application Programming Interchange
(b) Application Programming Interaction
(c) Application Programming Interface
(d) None of these
Answer: c
01 – Abstract Windowing Toolkit (AWT)
Q. 23.What is default layout for Dialog?
(a) FlowLayout
(b) GridLayout
(c) CardLayout
(d) BorderLayout
Answer: a

Q. 24 Which method is used to count the number of items is the List.


(a) getItem( )
(b) getSelectedItem( )
(c) getItemCount( )
(d) getCount( )
Answer: c

Q. 25 The correct hierarchy for Panel is


(a) Component – Container – Window – Panel
(b) Component – Container – Applet – Panel
(c) Component – Container – Panel
(d) Container – Component – Panel
Answer: c

Q. 26 Which is the correct constructor of GridLayout.


(a) GridLayout(int a)
(b) GridLayout(int num_rows, int num_columns)
(c) GridLayout(int rows, int cols, int vert)
(d) GridLayout(int hor)
Answer: b
Q. 27 What are the types of DialogBox?
(a) Modal DialogBox
(b) Modal and Modeless DialogBox
(c) Modam
(d) None of the above
Answer: b
01 – Abstract Windowing Toolkit (AWT)

Q. 28 In the give constructor what third parameter indicates :


ScrollBar s = new ScrollBar(0,10,20,0,1000);
(a) size of thumb
(b) minimum value
(c) Increment value
(d) Initial Value
Answer: a

Q. 29 Which class is used to represent a single line textbox with


password character facility?
(a) TextField
(b) TextArea
(c) Label
(d) Checkbox
Answer: a

Q. 30 To set the title to the Frame window method is used.


(a) void setTitle(String str)
(b) void setText(String str)
(c) void settitle(String str)
(d) None of the above
Answer: a

Q. 31 Suppose a Panel is added to a Frame and a Button is added to


the Panel. If the Frame’s font is
set to 12 point Times New Roman, the panel’s font is set 10 points
Times New Roman and the
Button’s font is not set. What font will be used to display the
Button’s label?
(a) 12 point Times New Roman
(b) 11 point Times New Roman
(c) 10 point Times New Roman
(d) 9 point Times New Roman
01 – Abstract Windowing Toolkit (AWT)
Answer: c

Q. 32 Which of the following is true about FlowLayout?


(a) FlowLayout can use multiple rows if the horizontal space in the
container is too small to
hold the component.
(b) FlowLayout is the default layout manager of panel and applet.
(c) It is the default layout manager for window.

(d) Both A & B.


Answer: d
Q. 33 Which of the method can be used to output a String in an
Applet?
(a) display( )
(b) print( )
(c) drawString( )
(d) transient( )
Answer: c

Q. 34 positions are the components into 5 regions east, west, south,


north, center.
(a) CardLayout
(b) BorderLayout
(c) GridLayout
(d) FlowLayout
Answer: b

Q. 35 What is API?
(a) Application Programming Interchange
(b) Application Programming Interaction
(c) Application Programming Interface
(d) None of these
Answer: c
01 – Abstract Windowing Toolkit (AWT)
Q. 36 Panel is defined as .
(a) Panel class is a concrete sub‐class of container
(b) A Panel is a window that does not contain a title bar, menu bar
or border
(c) Panel is the superclass of Applet
(d) All of above
Answer: d

Q. 37 Which component of AWT provides compact, multichoice, scrolling


component?
(a) List
(b) Choice
(c) Panel
(d) TextArea
Answer: a

Q. 38 When there is a switching condition like ON or OFF, which


control is used of following?
(a) Button
(b) RadioButton
(c) ToggleButton
(d) TextField
Answer: c

Q. 39 Which method is used to set password characterfor a TextField?


(a) setPasswordCharacter( )
(b) setEchoChar( )
(c) setPassChar( )
(d) setEchoCharacter( )
Answer: b

Q. 40 The getContentPane( ) method is of which class?


(a) JApplet
(b) JFrame
01 – Abstract Windowing Toolkit (AWT)
(c) JButton
(d) None of these
Answer: d

Q. 41 Which class defines setSize( ) method?


(a) Frame
(b) Applet
(c) Component
(d) Panel
Answer: c

Q. 42 is a swing class that allows to enter a single line of text.


(a) TextField
(b) JTextField
(c) EditTextField
(d) TextArea
Answer: b

Q. 43 Which Text Component method is used to set a TextComponent to


the read‐only state?
(a) Editable
(b) NonEditable
(c) setEchoChar
(d) setEditable
Answer:d

Q. 44 How would you set the color of graphics context called g to


cyan?
(a) g.setColor(“cyan”);
(b) g.setCurrentColor(cyan);
(c) g.setColor(“Color.cyan”);
(d) g.setColor(Color.cyan);
Answer: d
01 – Abstract Windowing Toolkit (AWT)
Q. 45 What is use of second parameter in given constructor
Lable(String,int)
(a) specifies height of label
(b) specifies width of label in terms of pixel
(c) specifies the alignment of text in label in terms of pixel
(d) specifies width of label
Answer: c

Q. 46 The setBackground() method is part of which of the following


class java.awt package?
(a) Component
(b) Applet
(c) Object
(d) Graphics
Answer: a

Q. 47 What does the following line of code do? TextField tf = new


TextField(10);
(a) will set 10 to TextField as its initial text.
(b) Will set the character capacity to 10
(c) Both A & B
(d) None of These
Answer: b

Q. 48 Frame is a standard window, which is of Window class from AWT


hierarchy?
(a) Derived class / Subclass
(b) Base class / Super class
(c) Root class
(d) Family class
Answer: a

Q. 49 A is a passive AWT control that do not generate any event?


(a) Button
01 – Abstract Windowing Toolkit (AWT)
(b) RadioButton
(c) Choice
(d) Label
Answer: d

Q. 50 The default layout manager of Frame is .


(a) FlowLayout
(b) BorderLayout
(c) GridLayout
(d) CardLayout
Answer: c

Q. 51 Which method is used to check the status of checkbox?


(a) getStatus( )
(b) getState( )
(c) isChecked( )
(d) getChecked( )
Answer: b

Q. 52 Which of the following method is used to set a TextComponent to


read‐only mode?
(a) Editable( )
(b) nonEditable( )
(c) setEchoChar( )
(d) setEditable( )
Answer: d

Q. 53 generates action events when an item is double‐clicked.


(a) List
(b) Checkbox
(c) MenuItem
(d) TextField
Answer: c
01 – Abstract Windowing Toolkit (AWT)

Q. 54 Which of the following does not have its default layout as


BorderLayout.
(a) Frame
(b) Dialog
(c) JApplet
(d) All of Above
Answer: d

Q. 55 Which of the following statement about GUI component is wrong?


(a) swing exists since the version 1.2 of the JDK
(b) AWT stands for Abstract Window Toolkit
(c) You cannot place AWT component on swing container.
(d) The AWT classes are deprecated.
Answer: c

Q. 56 Which of the following package is used for Graphical User


Interface?
(a) java.applet
(b) java.awt
(c) java.awt.image
(d) java.io
Answer: b

Q. 57 What are the variables defined in Dimension?


(a) length and width
(b) height and length
(c) height and width
(d) None of these
Answer: c

Q. 58 Which AWT component is not editable?


(a) Button
(b) TextField
01 – Abstract Windowing Toolkit (AWT)
(c) FlowLayout
(d) Label
Answer: b

Q. 59 Current text of Label can be obtained using .


(a) setAlignment( )
(b) getAlignment( )
(c) getText( )
(d) setText( )
Answer: c

Q. 60 The method places a Menu m into the MenuBar mb.


(a) mb.addMenuItem(m)
(b) mb.addItem(m)
(c) mb.add(m)
(d) None of these
Answer: c

Chapter 2 : Swings

02 – Swings

Q. 1 The following specifies the


advantages of It is lightweight.
It supports pluggable look and feel.
It follows MVC (Model View
Controller) architecture.
(a) Swing
(b) AWT
(c) Both A & B
02 – Swings
(d) None of the above
Answer: a

Q. 2 Swing is not a part of JFC (Java Foundation Classes) that is


used to create GUI application?
(a) True (b) False
Answer:b

Q. 3 The Swing Component classes that are used in Encapsulates a


mutually exclusive set of buttons?
(a) AbstractButton
(b) ButtonGroup
(c) JButton
(d) ImageIcon
Answer: b

Q. 4 The Java Foundation Classes (JF(c) is a set of GUI components


which simplify the
development of desktop applications?
(a) True (b) False
Answer: a

Q. 5 Which package is used for import the swing components?


(a) java.swing
(b) java.awt
(c) javax.swing
(d) All of the above
Answer: c

Q. 6 The String parameter to JButton constructor .


(a) tell which region to put the JButton in.
(b) tells the color of the JButton.
(c) tells what text will appear on JButton.
(d) tells what should happen when JButton is pressed.
02 – Swings
Answer: c

Q. 7 MVC architecture is
(a) Modelling – Visual – Controller
(b) Model – View – Controller
(c) Model – Viewable – Controller
(d) Many – View – Controller
Answer: b

Q. 8 Alignment constants of JLabel are the part of


a) SwingConstants interface
b) SwingConstants class
c) Swing class
d) Graphics class
Answer: a
Q. 9 In swing, Buttons are subclasses of which class?
(a) AbstractButton
(b) JButton
(c) Button
(d) JRadioButton
Answer: a

Q. 10 JTree class belongs to which package?


(a) java.awt
(b) java.applet
(c) java.swing
(d) javax.swing
Answer: d

Q. 11 Which component is swing represents data in row and columns?


(a) JTextArea
(b) JTable
(c) JPanel
02 – Swings
(d) JtabbedPane
Answer: b

Q. 12 Which of the following is not constructor of JTree?


(a) JTree(TreeNode tn)
(b) JTree(Vector v)
(c) JTree(int x)
(d) none of the above
Answer: c

Q. 13 class used to create node in tree.


(a) TreeNode
(b) DefaultMutableNode
(c) DefaultMutableTreeNode
(d) Node
Answer: c

Q. 14 JTabbedPane class is present in which package?


(a) java.awt
(b) java.swing
(c) java.awt.swing
(d) javax.swing
Answer: d

Q. 15 What is purpose of JTree?


(a) To show data in form of parent and child nodes.
(b) To show data in list view.
(c) To show data in tabular form.
(d) To show data in menu‐bar.
Answer: a

Q. 16 What is the use of : Container getContentPane( )


02 – Swings
(a) Returns Container for a JDialog.
(b) Returns a ContentPane for Menu
(c) Returns a ContentPane for Applet
(d) None of the above
Answer: c

Q. 17 Which of the following method is not applicable for Button in


swing.
(a) setDiableIcon( )
(b) setPressedIcon( )
(c) setSelectedIcon( )
(d) setRollOverIcon( )
Answer: c

Q. 18 Which of the following method is used to retrieve icon of


JButton?
(a) Icon getIcon( )
(b) ImageIcon getImageIcon( )
(c) ImageIcon getIcon( )
(d) ImageIcon GetImageIcon( )
Answer: c

Q. 19. Which method is used to display icon on a Button?


a) setImage(ImageIcon i)
b) setIcon(ImageIcon i)
c) setPicture(ImageIcon i)
d) setImageIcon(ImageIcon i)
Answer: b

Q. 20. How will you set icon for the Jlabel?


a) Using Icon class directly
b) Using setIcon( ) method
c) Using makeIcon( ) method
d) It is not possible to set icon for JLabel
02 – Swings
Answer: b

Q. 21. What is the return type of getText( ) method of JButton class?


a) void
b) String
c) Character array
d) There is no such method
Answer: b

Q. 22. The constructor JCheckBox(true, “YES”) suggests that


a) Checkbox is selected and displays the string “YES” on it.
b) Checkbox is deselected and displays the string “YES” on it.
c) Checkbox is selected and it shows the tick always on it.
d) There is no such constructor
Answer: d

Explanation: No explanation Available


Q. 23. How to make the group of Radio buttons?
a) Using ButtonGroup class
b) Using JButtonGroup class
c) Using JRadioButton
d) Using AbstractButton class
Answer: a

Q. 24. How to contents of whole vector into the JComboBox?


a) Use the constructor of JComboBox
b) Use method addItem( )
c) Use method addVector( )
d) Use method addValues( )
Answer: a

Q. 25. The scroll bar constants for scroll pane are defined in
a) Scrollbar class
02 – Swings
b) ScrollPane class
c) ScrollPaneConstants interface
d) Component class
Answer: c

Q. 26. Which of the following constants shows scroll bars always?


a) HORIZONTAL_SCROLLBAR_ALWAYS
b) HORIZONTAL_SCROLLBAR_AS_NEEDED
c) HORIZONTAL_SCROLLBARS
d) HORIZONTAL_ALWAYS
Answer: a

Q. 27. Is it possible to add array of objects to trees? How?


a) Not possible
b) Yes, using its one of the forms of constructor
c) Yes, using the add( ) method
d) Yes, using the addItem( ) method
Answer: b

Q. 28. Find an error of following program


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");
02 – Swings
DefaultMutableTreeNode vegetableNode = new
DefaultMutableTreeNode("Vegetables"); DefaultMutableTreeNode
fruitNode =
new DefaultMutableTreeNode("Fruits"); root.add(vegetableNode);
root.add(fruit
Node); tree =
new JTree();
add(tree);
} }
/*

*/ a) Error in statement in which JTree is created b) Error in Applet


code c) No error d) Error in Frame Answer: a Q. 30. The default
orientation to display the progress bar is? a) CENTER b) TOP c)
HORIZONTAL d) VERTICAL Answer: c Q. 31. MutableTreeNode is
extends ................... interface a) TreePath b) TreeNode c)
DefaultMutableTreeNode d) MutableTreeNode Answer: b Q. 32. Which two
parameters are required for JTree constructor to create a tree? a)
Data array and Row Headings b) Data array and Column Headings c)
Single data element and Column heading d) Single data element and Row
heading Answer: b
Chapter 3 : Event Handling
03 – Event Handling

Q. 1. The Following steps are required to perform Implement the


Listener interface and overrides
its methods Register the component with the Listener
(a) Exception Handling
(b) String Handling
(c) Event Handling
(d) None of the above
Answer: c

Q. 2 In which places can put the event handling code


(a) Same class
(b) Other class
03 – Event Handling
(c) Annonymous class
(d) All mentioned above
Answer: d

Q. 3 Which package provides many event classes and Listener


interfaces for event handling?
(a) java.awt
(b) java.awt.Graphics
(c) java.awt.event
(d) None of the above
Answer: c

Q. 4 To use the ActionListener interface it must be implemented by a


class there are several ways
to do that find in the following?
(a) Creating a new class
(b) using the class the graphical component
(c) an anonymous inner class
(d) All mentioned above
Answer: d

Q. 5 The ActionListener interface is not used for handling action


events?
(a) True
(b) False
Answer: b

Q. 6 The ActionListener interface is used for handling action events,


For example, it's used by a
(a) JButton
(b) JCheckbox
(c) All of these
(d) JMenuItem
03 – Event Handling
Answer: c

Q. 7 Which class is used for this Processing Method


processActionEvent( )?
(a) Button,List,MenuItem
(b) Button,Checkbox,Choice
(c) Scrollbar,Component,Button
(d) None of the above
Answer: a

Q. 8 In Graphics class Which method is used to set the graphics


current color to the specified color?
(a) public abstract void setFont(Font font)
(b) public abstract void setColor(Color c)
(c) public abstract void drawString(String str, int x, int y)
(d) None of the above
Answer: b

Q. 9 Which of the following method is used to determine the type of


adjustment event?
(a) getType( )
(b) getEventType( )
(c) getAdjustmentType( )
(d) getEventObjectType( )
Answer: c

Q. 10 TextField generates event.


(a) ActionEvent,ItemEvent
(b) ActionEvent, TextEvent
(c) ScrollEvent,TextEvent
(d) ActionEvent, ScrollEvent
Answer: b

Q. 11 void keyTyped(KeyEvent ke) called when a key on the keyboard


03 – Event Handling
is .
(a) pressed and then released.
(b) pressed
(c) released
(d) none of the above
Answer: a

Q. 12 Which event is generated when the position of scrollbar is


changed?
(a) KeyEvent
(b) MouseEvent
(c) ItemEvent
(d) AdjustmentEvent
Answer: d

Q. 13 The signature for the registration method for a ActionEvent


should be .
(a) public void addActionListener(ActionEvent L)
(b) public void setAction(ActionListener L)
(c) public void setActionListener(ActionListener L)
(d) public void addActionListener(ActionListener L)
Answer: d

Q. 14 Which of the following component generates ActionEvent?


(a) Window
(b) RadioButton
(c) ScrollBar
(d) None
Answer: d

Q. 15 method is used to register a keyboard event listener.


(a) KeyListener( )
(b) addKeyListener( )
(c) addKeyListenerEvent( )
03 – Event Handling
(d) eventKeyboardListener( )
Answer: b

Q. 16 Name the method defined in EventObject class that returns the


object generated from the event.
(a) getEvent( )
(b) getObject( )
(c) getId( )
(d) getSource( )
Answer: d

Q. 17 The MouseListener interface is used to make mouse handling.


(a) True
(b) False
Answer: a

Q. 18 ActionEvent is applied on
(a) Frame
(b) Checkbox, Choice, List
(c) Scrollbar
(d) Button, TextField, List, Menu
Answer: d

Q. 19 ComponentEvent is the super class of .


(a) FocusEvent
(b) MouseEvent
(c) WindowEvent
(d) All of the above
Answer: d

Q. 20 If we close an applet window events will be generated.


(a) ActionEvent
(b) ComponentEvent
03 – Event Handling
(c) AdjustmentEvent
(d) WindowEvent
Answer: d

Q. 21 Which of the following component generate ActionEvent?


(a) ScrollBar
(b) Window
(c) RadioButton
(d) None of these
Answer: d

Q. 22 Which Listener handles all List related Events?


(a) ItemListener
(b) InputEvent
(c) SelectEvent
(d) ListEvent
Answer: a

Q. 23 How to obtain the command name for invoking ActionEvent?


(a) getCommandName( )
(b) getActionEventCommand( )
(c) getActionCmd( )
(d) getActionCommand( )
Answer: d

Q. 24 ComponentEvent is the superclass of


(a) ActionEvent
(b) ItemEvent
(c) TextEvent
(d) All of above
Answer: d

Q. 25 When we need to use Checkbox or Item from the list or use a


03 – Event Handling
checkable Menu an is generated.
(a) ActionEvent
(b) ItemEvent
(c) MenuEvent
(d) ClickEvent
Answer: b

Q. 26 Which of the following constant is not defined in WindowEvent


class?
(a) WINDOW_ACTIVATED
(b) WINDOW_CLOSED
(c) WINDOW_DEICONIFIED
(d) None of these
Answer: d

Q. 27 Which of the following is not the method of handling window


event?
(a) void windowClosed(WindowEvent we)
(b) void windowClosing(WindowEvent we)
(c) void windowAfterClosing(WindowEvent we)
(d) All of these
Answer: c

Q. 28 Which method is used to process mouse click?


(a) public void mouseClicked(MouseListener m)
(b) public void mouseIsClicked(MouseEvent m)
(c) public void mouseClicked(MouseEvent m)
(d) public void mouseClick(MouseEvent m)
Answer: c

Q. 29 Which class is used for this processing method


processActionEvent( ) method?
(a) Button, List, MenuItem
(b) Button,Checkbox,Choice
03 – Event Handling
(c) ScrollBar, Component, Button
(d) None of the above.
Answer: a

Q. 30 Which of this package contains all the classes and methods


required for event handling in Java.
(a) java.applet
(b) java.awt
(c) java.event
(d) java.awt.event
Answer: d

Q. 31 Name the method defined in EvenObject class that returns the


object generated from the event.
(a) getEvent( )
(b) getObject( )
(c) getId( )
(d) getSource( )
Answer: d

Q. 32 Which of these interfaces define a method actionPerformed()


(a) ComponentListener
(b) ContainerListener
(c) ActionListener
(d) InputListener
Answer: c

Q. 33 Button Control implements following listener interface.


(a) ItemListener
(b) ActionListener
(c) FlowListener
(d) Adapter
Answer: b
03 – Event Handling

Q. 34 Clicking the closing button on the upper right corner of a


frame generates a (n)‐event.
(a) ItemEvent
(b) WindowEvent
(c) MouseMotionEvent
(d) ComponentEvent
Answer: b

Q. 35 Which of the following method must be overridden in the order


to handle KeyEvent.
(a) keyPressed(KeyEvent obj)
(b) KeyReleased(KeyEvent obj)
(c) KeyTyped(KeyEvent obj)
(d) All of these
Answer: d

Q. 36 Which of these methods can be used to know the degree of


adjustment made by the user?
(a) getValue( )
(b) getAdjustmentType( )
(c) getAdjustmentValue( )
(d) getAdjustmentAmount( )
Answer: c

Q. 37 MouseEvent is subclass of which of the following class?


(a) ComponentEvent
(b) ContainerEvent
(c) ItemEvent
(d) InputEvent
Answer: d
Q. 38 The is an object that is notified when an event occurs.
(a) Listener
(b) Sources
03 – Event Handling
(c) Event
(d) None of the above
Answer: a
Q. 39 What is the use of String getActionCommand( ) method of
ActionEvent class?
(a) to obtain the label (caption) of Button
(b) to obtain the reference of Button
(c) to obtain object of Button
(d) to obtain the label (caption) and object of Button
Answer: a
Chapter 4 : Networking Basics
04 – Networking Basics

Q. 1 UDP stands for


(a) User Data Port
(b) User Datagram Protocol
(c) Used Data Provider
(d) User Data Protocol
Answer: b

Q. 2 Name the class which is used to create a port where the server
will listen.
(a) Server
(b) Socket
(c) ServerSocket
(d) SocketServer
Answer: b

Q. 3 Communication using TCP protocol is and .


(a) Connection less, Iterative
(b) Collection less, concurrent
(c) Connection oriented, Iterative
(d) Connection oriented, concurrent
Answer: d
04 – Networking Basics

Q. 4 Which of these is a not a factory method of InetAddress class?


(a) static InetAddress getLocalHost( )
(b) static InetAddress getByName(String hostname)
(c) static InetAddress getAllName(String hostname)
(d) static InetAddress[ ] getAllByName(String hostname)
Answer: c

Q. 5 Which from the below use “Middle tier”.


(a) 3 tier
(b) 4 tier
(c) n – tier
(d) all of the above
Answer: d

Q. 6 java.net package consists of interface


(a) ContentHandlerFactory
(b) SocketImplFactory
(c) FileNameMap and URLStreamHandlerFactory
(d) All of the above
Answer: d

Q. 7 IPv6 uses .
(a) 4 groups of 8 bits each
(b) 4 group of 8 hexa‐decimal digits
(c) 8 groups of 4 digits each
(d) 8 groups of 4 hexa‐decimal digits each
Answer: d

Q. 8 Select full form of DNS.


(a) Data Network System
(b) Domain Name System
(c) Domain Name Server
04 – Networking Basics
(d) Domain Naming Service
Answer: d

Q. 9 What is the use of WriteUTF( ) method?


(a) This method writes a string into underlying output stream.
(b) This method reads a sting from underlying input stream.
(c) This method writes a byte array into underlying output stream.
(d) This method writes a character array into underlying output
stream.
Answer: c

Q. 10 Which of these is a bundle of information passed


between machines?
(a) MIME
(b) Cache
(c) Datagram
(d) Socket
Answer: c

Q. 11 Port number for FTP is


(a) 21
(b) 23
(c) 25
(d) 80
Answer: a

Q. 12 The class which encapsulates both the numerical IP address and


the domain name for that address
is .
(a) DatagramPacket
(b) DatagramSocket
(c) InetAddress
(d) ServerSocket
Answer: c
04 – Networking Basics

Q. 13 int getServerPort( ) method


(a) returns the port number on which this request was received.
(b) returns the port name on which the request was received.
(c) returns the server number on which this request was received.
(d) returns the port number on which this response/request was
received.
Answer: d

Q. 14 In this constructor ServerSocket(int port, int max_queue) what


is the default value for max_queue?
(a) 100
(b) 50
(c) 75
(d) 80
Answer: b

Q. 15 The constructor of URL can throw an exception called


(a) MalformedUrlException
(b) UrlNotFoundException
(c) UrlException
(d) UrlSourceNotFoundException
Answer: a
Q. 16 Which IP address is multicast IP address?
(a) 192.168.2.32
(b) 235.55.45.2
(c) 12.22.1.2
(d) None of these
Answer: d

Q. 17 Which 5 parameters uniquely identify a connection?


(a) Local IP, Remote IP, Local MAC, Remote MAC and Protocol
(b) Local IP, Local PORT, Remote MAC, Remote PORT and Protocol
(c) Local MAC, Local PORT, Remote MAC, Remote PORT and Protocol
04 – Networking Basics
(d) Local IP, Local PORT, Remote IP, Remote PORT and Protocol
Answer: b

Q. 18 Select the method used to create URL connection.


(a) URL Connection
(b) open Connection
(c) URL
(d) URL Decoder

Answer: a
Q. 19 What value is returned by the readLine( ) method when it reach
at End of File?
(a) EOF
(b) null
(c) 0
(d) END
Answer: b

Q. 20 The class is used to create TCP server.


(a) Server
(b) SocketServer
(c) ServerSocket
(d) Socket
Answer: c

Q. 21 Which method of ServerSocket will wait for a client to initiate


communication and then
communication with the client?
(a) wait( )
(b) connect( )
(c) waitForClient( )
(d) WaitForConnect( )
Answer: b
04 – Networking Basics
Q. 22 method is used to retrieve file name specified in URL.
(a) getFile( )
(b) getUrl( )
(c) getFileUrl( )
(d) getLocalFile( )
Answer: a

Q. 23 is necessary to implement Datagram.


(a) DatagramPacket
(b) DatagramSocket
(c) Both A & B
(d) None of A & B
Answer: d

Q. 24 Which is the correct syntax for getLocalHost( ) method?


(a) public static InetAddress getLocalHost( ) throws
UnknownHostException
(b) public static IpAddress getLocalHost( ) throws
UnknownHostException
(c) public static String getLocalHost( ) throws UnknownHostException
(d) public static void getLocalHost( ) throws UnknownHostException
Answer: a

Q. 25 Which of these method of DatagramPacket class is used to find


the destination address?
(a) findAddress( )
(b) getAddress( )
(c) address( )
(d) whoIs( )
Answer: b

Q. 26 Connection oriented communication is possible using classes of


Java.
(a) Socket and ServerSocket
04 – Networking Basics
(b) DatagramSocket and DatagramPacket
(c) Both of these
(d) None of these
Answer: c

Q. 27 A server socket can connect to clients.


(a) 1
(b) 2
(c) 10
(d) multiple
Answer: d

Q. 28 Resolver in DNS system maps .


(a) Domain name to IP address
(b) IP address to domain name
(c) Domain name to MAC address
(d) MAC address to IP address
Answer: b

Q. 29 If a program consists of three classes, then after compilation


how many class files will be created
by the compiler?
(a) one
(b) three
(c) uncountable
(d) zero
Answer: b

Q. 30 Which of the following is not a method of Security class?


(a) socketPermission( )
(b) filePermission( )
(c) dataPermission( )
(d) None of above
04 – Networking Basics
Answer: d

Q. 31 TCP does not supports Multicasting and Broadcasting because .


(a) It supports full duplex communication.
(b) It provides error control.
(c) It provides flow control
(d) It is connection oriented protocol
Answer: d

Q. 32 Which of the following is true about TCP protocol?


(a) is reliable and connection oriented
(b) is unreliable but connection oriented
(c) is reliable and connectionless
(d) None of these
Answer: a

Q. 33 Which class defines following methods?


int getContentLength( )
long getDate( )
long getExpiration( )
(a) URLConnection
(b) Datagram
(c) Client
(d) None of these
Answer: a

Q. 34 Name the class which is used to create a port where the server
will listen?
(a) Server
(b) Socket
(c) ServerSocket
(d) SocketServer
Answer: b
04 – Networking Basics

Q. 35 class Permission in java.security package is .


(a) static
(b) abstract
(c) final
(d) None of these
Answer: b

Q. 36 Which methods are commonly used in ServerSocket class?


(a) public OutputStream getOutputStream( )
(b) public Socket accept( )
(c) public synchronized void close( )
(d) None of the above
Answer: b

Q. 37 Which is the proper method to retrieve the host name of local


machine?
(a) static InetAddress getLocalHost( ) throws UnknownHostException
(b) static InetAddress getByName(String host_name ) throws
UnknownHostException
(c) static InetAddress getAllByName(String host_name ) throws
UnknownHostException
(d) String getHostAddress( )
Answer: a

Q. 38 Which constructor of DatagramPacket class are used for


receiving purpose?
(a) DatagramPacket(byte data[ ], int size) DatagramPacket(byte
data[ ], int size, int offset, int port)
(b) DatagramPacket(byte data[ ], int size,InetAddress ip, int port)
DatagramPacket(byte data[ ], int offset, int size, InetAddress ip,
int port)
(c) DatagramPacket(byte data[ ], int size) DatagramPacket(byte
data[ ], int size,InetAddress ip, int port)
(d) All of these
04 – Networking Basics
Answer: d

Chapter 5 : Interacting with Database


05 – Interacting with Database

Q. 1 The package contains classes that help in connecting to a


database, sending SQL
statements to the database and process the query request.
(a) connection.sql
(b) db.sql
(c) pkg.sql
(d) java.sql
Answer: a

Q. 2 Which of the following is not a type of JDBC driver?


(a) 100% pure Java Driver
(b) JDBC – net pure Java Driver
(c) JDBC – Native API driver
(d) JDBC – Native pure Java Driver
Answer: d

Q. 3 In JDBC imports all Java classes that are concern with Database
connectivity.
(a) javax.sql
(b) java.mysql
(c) java.sql
(d) com.sql
Answer: c

Q. 4 Database programming using Java throws which of the following


exception?
(a) SQLException
(b) ClassNotFoundException
(c) None of these
05 – Interacting with Database
(d) Both of these
Answer: d

Q. 5 In the below statement, which type of query can be used with


executeUpdate( ) method.
statement.executeUpdate(query here)
(a) Insert, Update, Delete
(b) Insert, Select, Delete
(c) Only Select
(d) Any Query
Answer: a

Q. 6 What is purpose of next( ) method?


(a) to retain the next element in a series.
(b) to retain next table.
(c) to retain next record in a series.
(d) None of the above
Answer: c

Q. 7 Native – protocol pure Java Driver converts into the directly.


(a) JDBC calls, network protocol
(b) ODBC class, network protocol
(c) ODBC class, user calls
(d) JDBC calls, user calls
Answer: d

Q. 8 Choose the correct syntax for getConnection( ) method.


(a) public static Connection getConnection(String url, String
password) throws SQLException
(b) public static Connection getConnection(String name, String
password) throws SQLException
(c) public static Connection getConnection(String url, String name,
String password) throws SQLException
(d) public static Connection getConnection(String url, String name)
05 – Interacting with Database
throws SQLException
Answer: c

Q. 9 SQL stands for .


(a) Structured Query Language
(b) Sequential Query Language
(c) Structured Question Language
(d) Sequential Question Language
Answer: a

Q. 10 is a table of data which represents a data from table.


(a) MetaData
(b) ResultSetMetaData
(c) ResultSet
(d) Statement
Answer: c

Q. 11 Public class DriverManager extends


(a) Object
(b) String
(c) Connection
(d) Statement
Answer: a

Q. 12 Which of the following method is supported by Statement


interface?
(a) public boolean execute(String query)
(b) public ResultSet executeQuery(String query)
(c) public int executeUpdate(String query)
(d) All of above
Answer: d

Q. 13 In following statement rs is an object of interface of JDBC


API.
05 – Interacting with Database
System.out.println(rs.getString(3));
(a) RowSet
(b) Statement
(c) Connection
(d) ResultSet
Answer: d

Q. 14 Which is main component of JDBC API?


(a) DriverManager
(b) Driver
(c) Connection
(d) All of these
Answer: d

Q. 15 How many steps are used to connect any java application with
the database using JDBC ?
(a) 5
(b) 4
(c) 3
(d) 6
Answer: a

Q. 16 ODBC minimum SQL grammer contains


(a) Stored procedure
(b) Data, Time and TimeStamp only
(c) create or drop View
(d) Insert, update, delete only
Answer: d

Q. 17 Which class/interface is used for an SQL statement that is


executed frequently?
(a) Statement
(b) CallableStatement
(c) PreparedStatement
05 – Interacting with Database
(d) None of the above
Answer: c

Q. 18 What does the following code do : smt = con.createStatement( )


(a) A PreparedStatement object is created to send SQL commands to
database.
(b) A Statement object is created to send SQL commands to database.
(c) A CallableStatement is created to send SQL commands to database.
(d) A Statement object is created to execute parameterized SQL
commands.
Answer: b

Q. 19 Which kind of driver converts JDBC calls into calls on the


Client API for Oracle, Sybase, Informix, BM
DB2, or other DBMS
(a) JDBC ODBC bridge + ODBC Driver
(b) Native API partly – Java Driver
(c) JDBC – Net pure Java Driver
(d) Native Protocol Pure Java Driver
Answer: b

Q. 20 Which method executes an SQL statement that may return multiple


results?
(a) executeUpdate( )
(b) executeQuery( )
(c) execute( )
(d) noExecute( )
Answer: b

Q. 21 Identify correct syntax of executeQuery( ) of Statement


interface.
(a) public static ResultSet executeQuery( )
(b) public ResultSet executeQuery(String q)
(c) public void executeQuery(String q)
05 – Interacting with Database
(d) public int executeQuery(String q)
Answer: b

Q. 22 Native API converts into the used by DBMS.


(a) JDBC API, Network Protocol
(b) JDBC API, Native API calls
(c) JDBC API, use calls
(d) JDBC API, ODBC API calls
Answer: b

Q. 23 Which of the following function is used to find the column


count of the particular ResultSet.
(a) getMetadata( )
(b) metadata( )
(c) getColumnCount( )
(d) getCount( )
Answer: c

Q. 24 The JDBC‐ODBC bridge supports how many concurrent open


statements per connection ?
(a) 1
(b) 0
(c) Does not support connection
(d) None of these
Answer: a

Q. 26 Microsoft Access data in file format.


(a) .DAT
(b) .MDB
(c) .MSSQL
(d) .OBJ
Answer: b

Q. 27 Which of the following method is used for send SQL statements?


05 – Interacting with Database
(a) Statement
(b) CallableStatement
(c) PreparedStatement
(d) Both B & C
Answer: d

Q. 28 DELETE statement of an SQL is executed by .


(a) execute( )
(b) executeQuery( )
(c) executeUpdate( )
(d) executeDelete( )
Answer: c

Q. 29 The interface to the databasee is handle by .


(a) ODBC
(b) JDBC
(c) JDBC & ODBC
(d) APIs
Answer: b

Q. 30 DatabaseMetadata are retrieved through


(a) getDatabaseMetadata( )
(b) getMetaData( )
(c) getDBMetaData( )
(d) getDatabaseMeta( )
Answer: a

Q. 31 Which method is used to retrieve the ResultSet created?


(a) executeQuery( )
(b) getResultSet( )
(c) getResultSetResult( )
(d) getResult( )
Answer: a
05 – Interacting with Database

Q. 32 Which of the following is used generally for reading the


content of the database?
(a) DabaseData
(b) DabaseData
(c) ResultSet
(d) DatabaseResult
Answer: c

06 – Servlets Marks:-14
Content of Chapter:-
6.1 Servlet Type of Servlet, Servlet life cycle
6.2 Creating Simple Servlet: The Servlet API, javax.servlet Package,
Servlet Interface, Servlet
Config Interface, ServletContext
Interface,ServletRequest ,ServletResponse,GenericServlet
Class
6.3 The Javax,servlet.httppPackage:HttpServletRequest Interface,
HttpServletResponse
Interface, HttpSession Interface, Cookie Class, HttpServlet
Class,HttpSessionEvent Class,
HttpSessionBindingEvent Class
6.4 Handling Http Request and Responses, Handling HTTP GETRequest,
Handling Http POSTRequest
6.5 Cookies and Session Tracking

Chapter 6 : Servlets

06 – Servlets

Q. 1 JSP embeds in .

(a) Servlet, HTML

(b) HTML, Java

(c) HTML, Servlet

(d) Java, HTML


Answer: d

Q. 2 Which of the following is the default HttpRequest method?

(a) doGet( )

(b) doPost( )

(c) doTrace( )

(d) doPut( )

Answer: a

Q. 3 Which are true about tag libraries in web application?

(a) packaged in the /WEB‐INF directory or subdirectory of the WAR


file

(b) If a tag is implemented as a tag file and packaged in


/WEB‐INF/tags/ or a subdirectory,

a TLD will be generated automatically by the web container, though,


you can provide one if you wish

(c) packaged in the /META‐INF/ directory or subdirectoryof a tag


library packaged in a jar.

(d) All of the above.

Answer: d

Q. 4 Name the http method used to send resources to the server.

(a) FTP method

(b) PUT method

(c) WRITE method

(d) COPY method

Answer: b

Q. 5 Identify the proper syntax of doGet( ).

(a) void doGet(HttpResponse res,HttpRequest req) throws IOException,


ServletException

(b) void doGet(HttpRequest req,HttpResponse res) throws IOException,


ServletException
(c) void doGet(HttpResponse res) throws IOException, ServletException

(d) void doGet(HttpRequest req) throws IOException, ServletException

Answer: b

Q. 6 Given an HttpServletRequest request and HttpServletResponse


response instances. Which sets a

cookie “username” with the value “joe” in a servlet?

(a) request.addCookie(new Cookie(“username” ,“joe));

(b) response.addCookie(new Cookie(“username” ,“joe”))

(c) request.addCookie(“username” , “joe);

(d) request.addCookie(“username” , “joe);

Answer: b

Q. 7 Which JSP tag is used to transfer for processing another JSP


page?

(a)

(b)

(c)

(d)

Answer: b

Q. 8 An application wants to invalidate the session both


programmatically and declaratively. Select the

best match to do this.

(a) httpRequest.getSession( ).end( )

time_in_minutes

(b) httpRequest.getSession( ).invalidate( )

time_in_minutes

(c) httpRequest.getSession( ).close( )

time_in_minutes

(d) httpRequest.getSession( ).invalidate( )


time_in_minutes

Answer: b

Q. 9 The include( ) method in RequestDispatcher .

(a) sends a request to another resource like servlet, JSP or html.

(b) includes resources of file like servlet, JSP or html.

(c) appends the request and response objects to the current servlet.

(d) None of these Servlets

Answer: c

Q. 10 State true or false for following statements.

(i) JavaBeans slow‐down software development process.

(ii) Java Servlets do not have built‐in multithreaded feature.

(a) false, false

(b) false, true

(c) true, false

(d) true, true

Answer: a

Q. 11 is a small piece of information that is passed back & forth in


HTTP request & response.

(a) Servlet

(b) Applet

(c) Cookie

(d) Session

Answer: c

Q. 12 Which life cycle method is used to process a client’s request?

(a) start( )

(b) init( )
(c) service( )

(d) destroy( )

Answer: c

Q. 13 A user types the URL http://www.msbte.com/result.php. Which


request gets generated?

(a) GET method

(b) POST method

(c) HEAD method

(d) PUT method

Answer: b

Q. 14 Apache Tomcat is .

(a) Servlet

(b) Java Program

(c) API

(d) Web server capable of running Java programs

Answer: d

Q. 15 What the getSession( ) method with “true” parameter will do?

(a) The session is completed

(b) The session object is passed to another method

(c) Creates new session if, the session does not exist

(d) The session is exist

Answer: c

Q. 16 A JSP page consists of which tags?

(a) HTML tags

(b) JSP tags

(c) Both A & B

(d) None of the above


Answer: c

Q. 17 Life cycle of a servlet is managed by

(a) Servlet Context

(b) Servlet Container

(c) Supporting protocol

(d) All of the above

Answer: b

Q. 18 To send binary output in the response, the following method of

HttpServlet response many be used to get the appropriate


Writer/Stream object.

(a) getStream( )

(b) getOutputStream( )

(c) getBianaryStream( )

(d) getWriter( )

Answer: b

Q. 19 is the first Phase of Servlet Life cycle.

(a) service( )

(b) init( )

(c) destroy( )

(d) Both B & C

Answer: b

Q. 20 How many copies of a JSP page can be in memory at a time?

(a) 1

(b) 2

(c) 3

(d) Unlimited

Answer: a
Q. 21 Which method is used to specify before any lines that used the
PrintWriter?

(a) setPageType( )

(b) setContextType( )

(c) setContentType( )

(d) setResponseType( )

Answer: c

Q. 22 is used to read data from a client request.

(a) ServletResponse

(b) ServletRequest

(c) Servlet

(d) ServletConfig

Answer: b

Q. 23 The following methods belongs to the life cycle methods of the


servlet.

(a) init( )

(b) service( )

(c) destroy( )

(d) All of the above

Answer: d

Q. 24 Java servlet

(i) is a key component of the server side java development.

(ii) is a small pluggable extension to a server that enhances


functionality

(iii) runs only in windows OS

(iv) allows developers to customize any java enabled server

(a) i, ii and iii are true

(b) i,iii and iv are true


(c) ii,iii and iv are true

(d) i,ii and iv are true

Answer: d

Q. 25 Servlet lifecycle has states.

(a) Two

(b) Three

(c) Four

(d) Five

Answer: b

Q. 26 JSP life cycle includes number of phases.

(a) Two

(b) Three

(c) Four

(d) Five

Answer: d

Q. 27 How to send data in get method?

(a) using GET method in request

(b) using Requesting URL

(c) using Response URL

(d) using URL

Answer: a

Q. 28 JSP life cycle includes following

(a) Translation Phase

(b) Compilation Phase

(c) Request handling phase

(d) All of these

Answer: d
Q. 29 JSP stands for .

(a) Java Service Provider

(b) Java Server Path

(c) Java Server Pages

(d) Java Server Program

Answer: c

Q. 30 The authentication mechanism in the servlet specification uses


a technique called ?

(a) Role Based Authentication

(b) Form Based Authentication

(c) Both a & b

(d) None of the above

Answer: c

You might also like