Advanced Java MCQ
Advanced Java MCQ
Edition 2019
Strictly as per new revised syllabus of ‘I’ Scheme w.e.f. academiic year 2018-2019
Advanced
d Java Program
mming
(Code : 22517)
Semester V - Computerr Engineering Program Group(CO
O/CM/CW)
Ravi Majithia
Free MCQ Bo
ooklet for Online Exam
mination
Features
MSBTE
More than 250 MCQ’s.
Chapterwise Multiple Cho oice Questions Given.
Specially for online Examin
nation as per ‘I’ Schemes
Index of MCQ’s
Unit - I
Unit - II
Unit - III
Unit - IV
Unit - V
Unit - VI
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)
2 Swings
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
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)
3 Event Handling
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)
4 Networking Basics
Unit IV
Q. 13 int getServerPort( ) method ____________ Q. 21 Which method of ServerSocket will wait for a
(a) returns the port number on which this request client to initiate communication and then
was received. communication with the client?
(b) returns the port name on which the request (a) wait( ) (b) connect( )
was received. (c) waitForClient( ) (d) WaitForConnect( )
(c) returns the server number on which this Q. 22 _________ method is used to retrieve file name
request was received.
specified in URL.
(d) returns the port number on which this (a) getFile( ) (b) getUrl( )
response/request was received.
(c) getFileUrl( ) (d) getLocalFile( )
Q. 14 In this constructor ServerSocket(int port, int
Q. 23 ________ is necessary to implement Datagram.
max_queue) what is the default value for
max_queue? (a) DatagramPacket (b) DatagramSocket
(a) 100 (b) 50 (c) Both A & B (d) None of A & B
(c) 75 (d) 80 Q. 24 Which is the correct syntax for getLocalHost( )
method?
Q. 15 The constructor of URL can throw an exception
called ______ (a) public static InetAddress getLocalHost( )
throws UnknownHostException
(a) MalformedUrlException
(b) public static IpAddress getLocalHost( ) throws
(b) UrlNotFoundException
UnknownHostException
(c) UrlException
(c) public static String getLocalHost( ) throws
(d) UrlSourceNotFoundException UnknownHostException
Q. 16 Which IP address is multicast IP address? (d) public static void getLocalHost( ) throws
(a) 192.168.2.32 UnknownHostException
(b) 235.55.45.2 Q. 25 Which of these method of DatagramPacket class is
(c) 12.22.1.2 used to find the destination address?
(d) None of these (a) findAddress( ) (b) getAddress( )
Q. 17 Which 5 parameters uniquely identify a (c) address( ) (d) whoIs( )
connection? Q. 26 Connection oriented communication is possible
(a) Local IP, Remote IP, Local MAC, Remote MAC using ____________ classes of Java.
and Protocol (a) Socket and ServerSocket
(b) Local IP, Local PORT, Remote MAC, Remote (b) DatagramSocket and DatagramPacket
PORT and Protocol
(c) Both of these
(c) Local MAC, Local PORT, Remote MAC, Remote (d) None of these
PORT and Protocol
(d) Local IP, Local PORT, Remote IP, Remote PORT Q. 27 A server socket can connect to ________ clients.
and Protocol (a) 1 (b) 2
(c) 10 (d) multiple
Q. 18 Select the method used to create URL connection.
(a) URL Connection (b) open Connection Q. 28 Resolver in DNS system maps __________.
(c) URL (d) URL Decoder (a) Domain name to IP address
(b) IP address to domain name
Q. 19 What value is returned by the readLine( ) method
when it reach at End of File? (c) Domain name to MAC address
(a) EOF (b) null (d) MAC address to IP address
(c) 0 (d) END Q. 29 If a program consists of three classes, then after
compilation how many class files will be created by
Q. 20 The_________class is used to create TCP server.
the compiler?
(a) Server (b) SocketServer
(a) one (b) three
(c) ServerSocket (d) Socket
(c) uncountable (d) zero
Q. 30 Which of the following is not a method of Security Q. 36 Which methods are commonly used in
class? ServerSocket class?
(a) socketPermission( ) (b) filePermission( ) (a) public OutputStream getOutputStream( )
(c) dataPermission( ) (d) None of above (b) public Socket accept( )
Q. 31 TCP does not supports Multicasting and (c) public synchronized void close( )
Broadcasting because ______________. (d) None of the above
(a) It supports full duplex communication. Q. 37 Which is the proper method to retrieve the host
(b) It provides error control. name of local machine?
(c) It provides flow control (a) static InetAddress getLocalHost( ) throws
(d) It is connection oriented protocol UnknownHostException
Q. 32 Which of the following is true about TCP protocol? (b) static InetAddress getByName(String
host_name ) throws UnknownHostException
(a) is reliable and connection oriented
(c) static InetAddress getAllByName(String
(b) is unreliable but connection oriented
host_name ) throws UnknownHostException
(c) is reliable and connectionless
(d) String getHostAddress( )
(d) None of these
Q. 33 Which class defines following methods? Q. 38 Which constructor of DatagramPacket class are
int getContentLength( ) used for receiving purpose?
long getDate( ) (a) DatagramPacket(byte data[ ], int size)
long getExpiration( ) DatagramPacket(byte data[ ], int size, int
(a) URLConnection (b) Datagram offset, int port)
(c) Client (d) None of these (b) DatagramPacket(byte data[ ], int size,
InetAddress ip, int port)
Q. 34 Name the class which is used to create a port
DatagramPacket(byte data[ ], int offset, int
where the server will listen?
size, InetAddress ip, int port)
(a) Server (b) Socket
(c) DatagramPacket(byte data[ ], int size)
(c) ServerSocket (d) SocketServer
DatagramPacket(byte data[ ], int size,
Q. 35 class Permission in java.security package is InetAddress ip, int port)
__________. (d) All of these
(a) static (b) abstract
(c) final (d) None of these
Answers
Q.1 (b) Q.2 (b) Q.3 (d) Q.4 (c) Q.5 (d) Q.6 (d) Q.7 (d) Q.8 (d)
Q.9 (c) Q.10 (c) Q.11 (a) Q.12 (c) Q.13 (d) Q.14 (b) Q.15 (a) Q.16 (d)
Q.17 (b) Q.18 (a) Q.19 (b) Q.20 (c) Q.21 (b) Q.22 (a) Q.23 (d) Q.24 (a)
Q.25 (b) Q.26 (c) Q.27 (d) Q.28 (b) Q.29 (b) Q.30 (d) Q.31 (d) Q.32 (a)
Q.33 (a) Q.34 (b) Q.35 (b) Q.36 (b) Q.37 (a) Q.38 (d)
Unit V
Q. 16 ODBC minimum SQL grammer contains______ Q. 23 Which of the following function is used to find the
(a) Stored procedure column count of the particular ResultSet.
(a) getMetadata( ) (b) metadata( )
(b) Data, Time and TimeStamp only
(c) create or drop View (c) getColumnCount( ) (d) getCount( )
(d) Insert, update, delete only Q. 24 The JDBC‐ODBC bridge supports how many
concurrent open statements per connection ?
Q. 17 Which class/interface is used for an SQL statement
(a) 1
that is executed frequently?
(b) 0
(a) Statement
(b) CallableStatement (c) Does not support connection
(c) PreparedStatement (d) None of these
(d) None of the above Q. 25 Select the correct method to create
CallableStatement.
Q. 18 What does the following code do :
smt = con.createStatement( ) (a) CallableStatement prepareCall(String sql)
(a) A PreparedStatement object is created to (b) CallableStatement prepareCall(String sql, int
resultset type, int resultset_concurrency)
send SQL commands to database.
(b) A Statement object is created to send SQL (c) CallableStatement prepareCall(String sql, int
commands to database. resultset_type, int resultset_concurrency, int
resultset_holdability)
(c) A CallableStatement is created to send SQL
commands to database. (d) All of the above
(d) A Statement object is created to execute Q. 26 Microsoft Access data in _______ file format.
parameterized SQL commands. (a) .DAT (b) .MDB
Q. 19 Which kind of driver converts JDBC calls into calls (c) .MSSQL (d) .OBJ
on the Client API for Oracle, Sybase, Informix, IBM Q. 27 Which of the following method is used for send
DB2, or other DBMS SQL statements?
(a) JDBC ODBC bridge + ODBC Driver (a) Statement (b) CallableStatement
(b) Native API partly – Java Driver (c) PreparedStatement (d) Both B & C
(c) JDBC – Net pure Java Driver
Q. 28 DELETE statement of an SQL is executed by
(d) Native Protocol Pure Java Driver
________.
Q. 20 Which method executes an SQL statement that (a) execute( ) (b) executeQuery( )
may return multiple results? (c) executeUpdate( ) (d) executeDelete( )
(a) executeUpdate( )
Q. 29 The interface to the database is handle by _____.
(b) executeQuery( )
(a) ODBC (b) JDBC
(c) execute( )
(c) JDBC & ODBC (d) APIs
(d) noExecute( )
Q. 30 DatabaseMetadata are retrieved through Q. 32 Which of the following is used generally for
___________ reading the content of the database?
(a) getDatabaseMetadata( ) (a) DabaseData
(b) getMetaData( ) (b) DabaseData
(c) getDBMetaData( ) (c) ResultSet
(d) getDatabaseMeta( ) (d) DatabaseResult
Q. 31 Which method is used to retrieve the ResultSet Q. 33 The syntax to create a table named “Course”,
created? should begin with __________.
(a) executeQuery( ) (a) create new table course
(b) getResultSet( ) (b) create table course
(c) getResultSetResult( ) (c) table course create
(d) getResult( ) (d) new table course
Answers
Q.1 (d) Q.2 (d) Q.3 (c) Q.4 (d) Q.5 (a) Q.6 (c) Q.7 (d) Q.8 (c)
Q.9 (a) Q.10 (c) Q.11 (a) Q.12 (d) Q.13 (d) Q.14 (d) Q.15 (a) Q.16 (d)
Q.17 (c) Q.18 (b) Q.19 (b) Q.20 (b) Q.21 (b) Q.22 (b) Q.23 (c) Q.24 (a)
Q.25 (d) Q.26 (b) Q.27 (d) Q.28 (c) Q.29 (b) Q.30 (a) Q.31 (a) Q.32 (c)
Q.33 (b)
6 Servlets
Unit VI
Q. 10 State true or false for following statements. Q. 19 _________ is the first Phase of Servlet Life cycle.
(i) JavaBeans slow‐down software development (a) service( ) (b) init( )
process. (c) destroy( ) (d) Both B & C
(ii) Java Servlets do not have built‐in multithreaded
Q. 20 How many copies of a JSP page can be in memory
feature.
at a time?
(a) false, false (b) false, true
(a) 1 (b) 2
(c) true, false (d) true, true
(c) 3 (d) Unlimited
Q. 11 ________ is a small piece of information that is
Q. 21 Which method is used to specify before any lines
passed back & forth in HTTP request & response.
that used the PrintWriter?
(a) Servlet (b) Applet
(a) setPageType( )
(c) Cookie (d) Session
(b) setContextType( )
Q. 12 Which life cycle method is used to process a (c) setContentType( )
client’s request? (d) setResponseType( )
(a) start( ) (b) init( )
Q. 22 _________ is used to read data from a client
(c) service( ) (d) destroy( )
request.
Q. 13 A user types the URL (a) ServletResponse (b) ServletRequest
http://www.msbte.com/result.php. Which request (c) Servlet (d) ServletConfig
gets generated?
(a) GET method (b) POST method Q. 23 The following methods belongs to the life cycle
methods of the servlet.
(c) HEAD method (d) PUT method
(a) init( ) (b) service( )
Q. 14 Apache Tomcat is ________. (c) destroy( ) (d) All of the above
(a) Servlet
Q. 24 Java servlet
(b) Java Program
(c) API (i) is a key component of the server side java
(d) Web server capable of running Java programs development.
Q. 15 What the getSession( ) method with “true” (ii) is a small pluggable extension to a server that
parameter will do? enhances functionality
(a) The session is completed (iii) runs only in windows OS
(b) The session object is passed to another
method (iv) allows developers to customize any java
enabled server
(c) Creates new session if, the session does not
exist (a) i, ii and iii are true
(d) The session is exist (b) i,iii and iv are true
(c) ii,iii and iv are true
Q. 16 A JSP page consists of which tags? (d) i,ii and iv are true
(a) HTML tags (b) JSP tags
(c) Both A & B (d) None of the above Q. 25 Servlet lifecycle has _________ states.
(a) Two (b) Three
Q. 17 Life cycle of a servlet is managed by ______ (c) Four (d) Five
(a) Servlet Context (b) Servlet Container
(c) Supporting protocol (d) All of the above Q. 26 JSP life cycle includes ________ number of phases.
(a) Two (b) Three
Q. 18 To send binary output in the response, the (c) Four (d) Five
following method of HttpServlet response many
be used to get the appropriate Writer/Stream Q. 27 How to send data in get method?
object. (a) using GET method in request
(a) getStream( ) (b) getOutputStream( ) (b) using Requesting URL
(c) getBianaryStream( ) (d) getWriter( ) (c) using Response URL
(d) using URL
Q. 28 JSP life cycle includes following Q. 31 Which class provides stream to read binary data
(a) Translation Phase such as image et(c) from the request object?
(b) Compilation Phase (a) ServletInputStream (b) ServletOutputStream
(c) Request handling phase (c) Both a & b (d) None of the above
(d) All of these Q. 32 What is the limit of data to be passed from HTML
Q. 29 JSP stands for _______. to doGet() ?
(a) Java Service Provider (a) 8kb (b) 1kb
(b) Java Server Path (c) 4kb (d) 2kb
(c) Java Server Pages Q. 33 The major difference between Servlet and CGI is
(d) Java Server Program _______.
(a) Servlets are thread based and CGI is process
Q. 30 The authentication mechanism in the servlet
based.
specification uses a technique called ?
(b) Servlet executes slower than CGI.
(a) Role Based Authentication
(c) Servlet has no platform specific API where as
(b) Form Based Authentication
CGI has.
(c) Both a & b
(d) All of these
(d) None of the above
Answers
Q.1 (d) Q.2 (a) Q.3 (d) Q.4 (b) Q.5 (b) Q.6 (b) Q.7 (b) Q.8 (b)
Q.9 (c) Q.10 (a) Q.11 (c) Q.12 (c) Q.13 (b) Q.14 (d) Q.15 (c) Q.16 (c)
Q.17 (b) Q.18 (b) Q.19 (b) Q.20 (a) Q.21 (c) Q.22 (b) Q.23 (d) Q.24 (d)
Q.25 (b) Q.26 (d) Q.27 (a) Q.28 (d) Q.29 (c) Q.30 (c) Q.31 (a) Q.32 (d)
Q.33 (d)
Note