Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
6 views

Adv. Java (1)

Uploaded by

Nawaz Wariya
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Adv. Java (1)

Uploaded by

Nawaz Wariya
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 39

1/1/2021 MCQ QUESTIONS

ADVANCED JAVA PROGRAMMING

Tour2Tech
Page 1 of 38

UNIT - 1

1. AWT components are

a. Platform dependent

b. Platform Independent

c. Both A & B

d. None of Above

2. AWT components are


a. lightweight

b. heavyweight

c. equal weight

d. None of Above

3. State true or false: AWT is used for GUI programming in java.


a. true
b. false

4. AWT components are available in


a. java.util package

b. java.io package

c. javax.awt package

d. java.awt package

5. Which of the following class is derived from the container class?

a. Component

b. List

c. Panel
d. MenuComponent

MCQ QUESTIONS TOUR2TECH


Page 2 of 38

6. Which swing component is source of ItemEvent?


a. JPopupMenu

b. Jlabel

c. JTextField

d. JComboBox

7. Which of following is/are constants defined in WindowEvent class?


a. WINDOW_ACTIVATED

b. WINDOW_CLOSED

c. WINDOW_DEICONIFIED

d. All of Above

8. Which class is super class of all the events?

a. EventObject

b. EventClass

c. ActionEvent

d. ItemEvent

9. What is listener in context to event handling?


a. A listener is a variable that is notified when an event occurs

b. A listener is an object that is notified when an event occurs

c. A listener is a method that is notified when an event occurs

d. None of Above

10. What is an event in delegation event model used by Java programming


language?
a. An event is an object that describes a state change in processing

b. An event is an object that describes any change by the user and system

c. An event is a class used for defining object, to create events


d. An event is an object that describes a state change in a source

MCQ QUESTIONS TOUR2TECH


Page 3 of 38

11. Which of following interface define a method itemStateChanged ()?


a. Action Listener

b. Item Listener

c. Mouse Listener

d. Component Listener

12. Which of following interfaces define a method actionPerformed()?

a. ContainerListener
b. ItemListener

c. ActionListener

d. MouseListener

13. Which class is used to implement radiobutton using swing?

a. RadioButton

b. JRadioButton

c. JCheckBox with CheckboxGroup

d. None of the above

14. Which of following class is used to implement frame in swing?

a. JFrame
b. Jwindow

c. Frame

d. SwingFrame

15. State true or false: Swing have more components than AWT.
a. False

b. True

MCQ QUESTIONS TOUR2TECH


Page 4 of 38

16. Which of the following is not type of look & feel?


a. Metal Look & Feel

b. Motive Look & Feel

c. Motif Look & Feel

d. Windows Look & Feel

17. Which package needs to import to implement swing program?

a. None of Above
b. java.awt

c. java.swing

d. javax.swing

18. Which method can set or change the text in a Label?

a. setText()
b. find()

c. getText()

d. Both a & c

19. Which of following components that do not support any interaction with the user?

a. Button

b. Checkbox

c. Labels

d. List

20. Which abstract class is the super class of all menu related classes?

a. CheckboxMenuItem
b. MenuBar

c. MenuComponent

d. MenuItem

MCQ QUESTIONS TOUR2TECH


Page 5 of 38

21. Which can be used to represent a checkbox with a textual label that can
appear in a menu?

a. Menu

b. MenuBar

c. CheckboxMenuItem

d. MenuItem

22. Layout manager is used to

a. Arrange components in particular manner

b. Add component to Layout

c. Both A & B

d. None of Above

23. setBackground() method to set the background color for ____?

a. Component
b. JComponent

c. Container

d. None of Above

24. How many types of controls does AWT supports these controls are
subclasses of component?
a. 7

b. 5

c. 6

d. 8

25. Which method is used to set color?

a. public abstract void setColor(Color c)

b. public abstract void putColor(Color c)

c. public abstract void getColor(Color c)

d. None of Above

MCQ QUESTIONS TOUR2TECH


Page 6 of 38

26. What does the following line of code do?


Textfield text = new Textfield(10);
a. Creates TextField object that can hold 10 columns of text.

b. Creates TextField object that can hold 10 rows of text

c. Creates the object TextField and initializes it with the value 10.

d. All of Above

27. Which statement creates a Text Area with 10 rows and 20 columns?
a. TextArea text = new TextArea(200);

b. TextArea text = new TextArea(20,10);

c. TextArea text = new TextArea(10,20);

d. None of Above

28. To make dropdown menu of choice which component is used in AWT?

a. Choice

b. Checkbox

c. Combobox
d. List

29. State true or False: User can edit information displayed in Label at runtime.

a. False
b. True

30. How many line input takes from user in Text Field in AWT.

a. 1 c. 9
b. 3 d. None of above

MCQ QUESTIONS TOUR2TECH


Page 7 of 38

UNIT - 2

31. Implement the Listener interface and overrides its methods is required to
perform in event handling

a. True
b. False

32. Which is the container that doesn't contain title bar and MenuBars
but it can have other components like button, textfield etc?

a. Window

b. Frame

c. Container

d. Panel

33. Give the abbreviation of AWT?

a. Absolute Windowing Toolkit

b. Applet Windowing Toolkit

c. Abstract Windowing Toolkit

d. None of the above

34. Package of drawstring() method is

a. java.applet

b. java.awt

c. java.io

d. javax.swing

35. Which method is used for getting the language in internationalization?


a. GetdisplayLanguage()

b. GetDisplayLanguage()

MCQ QUESTIONS TOUR2TECH


Page 8 of 38

c. getDisplayLanguage()

d. None

36. 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

d. None of the above

37. Swing is not a part of JFC (Java Foundation Classes) that is used to create
GUI application?

a. True

b. False

38. Which class provides many methods for graphics programming?

a. java.awt

b. java.Graphics

c. java.awt.Graphics

d. None of the above

39. 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

40. Which method executes only once?


a. init() method

b. stop() method

c. destroy() method

d. start() method

MCQ QUESTIONS TOUR2TECH


Page 9 of 38

41. The Following steps are required to perform


1) Implement the Listener interface and overrides its methods
2) Register the component with the Listener
a. Event Handling

b. Exception Handling

c. String Handling

d. None of the above

42. In which places can put the event handling code


a. Same class

b. Other class

c. Anonymous class

d. All mentioned above

43. Which package provides many event classes and Listener


interfaces for event handling?
a. java.awt

b. java.awt.Graphic

c. java.awt.event

d. None of the above

44. 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

45. The ActionListener interface is not used for handling action events?
a. True

b. False

MCQ QUESTIONS TOUR2TECH


Page 10 of 38

46. The ActionListener interface is used for handling action events,For


example,it's used by a
a. JMenuItem

b. JCheckbox

c. JButton

d. All of these

47. The Java Foundation Classes (JFC) is a set of GUI components


which simplify the development of desktop applications.
a. True

b. False

48. In Graphics class which method is used to draws a rectangle with the
specified width and height?

a. public abstract void drawOval(int x, int y, int width, int height)

b. public abstract void drawLine(int x1, int y1, int x2, int y2)

c. public abstract void fillRect(int x, int y, int width, int height)

d. public void drawRect(int x, int y, int width, int height)

49. Which object can be constructed to show any number of choices in


the visible window?
a. Labels

b. Choice

c. Checkbox

d. List

50. 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. Pane

c. Container

d. Frame

MCQ QUESTIONS TOUR2TECH


Page 11 of 38

51. Where are the following four methods commonly used?

1) public void add(Component c)


2) public void setSize(int width,int height)
3) public void setLayout(LayoutManager m)
4) public void setVisible(boolean)

a. Graphics class

b. Component class

c. Both A & B

d. None of the above

52. Java Is known as TWO stage language.

a. True

b. False

53. We cannot access private class outside the package.

a. True

b. False

54. Which class is used for this Processing Method processActionEvent( )?

a. Scrollbar,Component,Button

b. Button,Checkbox,Choice

c. Button,List,MenuItem

d. None of the above

55. AWT has more powerful components like tables, lists, scroll panes,
color chooser, tabbed pane etc.

a. True

b. False

MCQ QUESTIONS TOUR2TECH


Page 12 of 38

56. _____ allows java code to run in the JVM to call and be called by native
applications.

a. NIJ

b. JNI

c. FJI

d. JFI

57. AWT is used for GUI programming in java

a. False

b. True

58. What are the names of the list layout managers in Java?

a. Flow Layout Manager

b. Box Layout Manager

c. Grid Layout Manager

d. All of the above

59. The size of a frame on the screen is measured in:

a. Pixels

b. Nits

c. Inches

d. Dots

60. What is the name of the Swing class that is used for frames?

a. Window

b. Frame

c. SwingFrame

d. JFrame

61. Multitasking in iOS was introduced in which version?

a. iOS 6.0 b. iOS 7.0

c. iOS 2.0 d. iOS 4.0

MCQ QUESTIONS TOUR2TECH


Page 13 of 38

UNIT – 3

62. Which of these packages contains all the classes and methods required
for even handling in Java?

a. java.awt.event

b. java.awt

c. java.event

d. java.applet

63. Which of these events will be generated if we close an applet’s window?

a. ComponentEvent
b. WindowEvent

c. AdjustmentEvent

d. ActionEvent

64. Which of these events will be notified if scroll bar is manipulated ?

a. WindowEvent

b. ActionEvent

c. ComponentEvent

d. AdjustmentEvent

65. Which of these class is super class of all the events?

a. ItemEvent

b. ActionEvent

c. EventClass

d. EventObject

66. Which of these methods can be used to determine the type of event?
a. getEventObject()

b. getEvent()

c. getID( )

d. getSource()

MCQ QUESTIONS TOUR2TECH


Page 14 of 38

67. Event class is defined in which of these libraries?

a. java.util

b. java.net

c. java.lang

d. java.io

68. What is a listener in context to event handling?

a. A listener is a method that is notified when an event occurs

b. A listener is a variable that is notified when an event occurs

c. A listener is a object that is notified when an event occurs

d. All of above

69. Which of these methods are used to register a mouse motion listener?

a. addMouseMotionListner()

b. addMouse()

c. addMouseListener()

d. eventMouseMotionListener()

70. Which of these methods are used to register a keyboard event listener?

a. addKeyListener()

b. eventKeyboardListener()

c. addKistener()

d. KeyListener()

71. What is an event in delegation event model used by Java programming


language?

a. An event is an object that describes a state change in a source

b. An event is an object that describes a state change in processing

c. An event is an object that describes any change by the user and system

d. An event is a class used for defining object, to create events

MCQ QUESTIONS TOUR2TECH


Page 15 of 38

72. Which of these events is generated when a button is pressed?

a. ActionEvent

b. KeyEvent

c. WindowEvent

d. AdjustmentEvent

73. Which of these are integer constants defined in ActionEvent class?

a. ALT_MASK

b. CTRL_MASK

c. SHIFT_MASK

d. All of the mentioned

74. Which of these events is generated by scroll bar?

a. ActionEvent

b. KeyEvent

c. WindowEvent

d. AdjustmentEvent

75. 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()

76. Which of these constant value will change when the button at the end of
scroll bar was clicked to increase its value?

a. BLOCK_DECREMENT

b. BLOCK_INCREMENT

c. UNIT_DECREMENT

d. UNIT_INCREMENT

MCQ QUESTIONS TOUR2TECH


Page 16 of 38

77. Which of these methods can be used to determine the type of adjustment
event?

a. getType()

b. getEventType()

c. getAdjustmentType()

d. getEventObjectType()

78. Which of these methods can be used to know which key is pressed?

a. getKey()

b. getModifier()

c. getActionKey()

d. getActionEvent()

79. Which of these methods can be used to obtain the command name for
invoking ActionEvent object?

a. getCommand()

b. getActionCommand()

c. getActionEvent()

d. getActionEventCommand()

80. Which of these events is generated when the component is added or


removed?

a. ComponentEvent

b. ContainerEvent

c. FocusEvent

d. InputEvent

81. Which of these methods can be used to get reference to a


component that was removed from a container?

a. getComponent()

b. getchild()

MCQ QUESTIONS TOUR2TECH


Page 17 of 38

c. getContainerComponent()

d. getComponentChild()

82. Which of these events is generated when computer gains or loses


input focus?

a. ComponentEvent

b. ContainerEvent

c. FocusEvent

d. InputEvent

83. Which of these methods can be used to know the type of focus change?

a. typeFocus()

b. typeEventFocus()

c. isTemporary()

d. isPermanent()

84. Which of these is superclass of ContainerEvent class?

a. WindowEvent

b. ComponentEvent

c. ItemEvent

d. InputEvent

85. FocusEvent is subclass of which of these classes?

a. ComponentEvent

b. ContainerEvent

c. ItemEvent

d. InputEvent

86. Which of these are integer constants of ComponentEvent class?

a. COMPONENT_HIDDEN

b. COMPONENT_MOVED

MCQ QUESTIONS TOUR2TECH


Page 18 of 38

c. COMPONENT_RESIZE

d. All of the mentioned

87. Which of these methods can be used to obtain the reference to the
container that generated a ContainerEvent?

a. getContainer()

b. getContainerCommand()

c. getActionEvent()

d. getContainerEvent()

88. Which of these events is generated when the size of an event is


changed?

a. ComponentEvent

b. ContainerEvent

c. FocusEvent

d. InputEvent

89. Which of these is superclass of WindowEvent class?

a. WindowEvent

b. ComponentEvent

c. ItemEvent

d. InputEvent

90. which of these are constants defined in WindowEvent class?


a. WINDOW_ACTIVATED

b. WINDOW_CLOSED

c. WINDOW_DEICONIFIED

d. All of the mentioned

91. Which of these methods is used to get x coordinate of the mouse?

a. getX( ) b. getXCoordinate()

c. getCoordinateX() d. getPointX()

MCQ QUESTIONS TOUR2TECH


Page 19 of 38

UNIT – 4

92. Which of these package contains classes and interfaces for networking?

a. java.io

b. java.util

c. java.net

d. java.network

93. Which of these is a protocol for breaking and sending packets to an


address across a network?

a. TCP/IP

b. DNS

c. Socket

d. Proxy Server

94. How many ports of TCP/IP are reserved for specific protocols?

a. 10

b. 1024

c. 2048

d. 512

95. How many bits are in a single IP address?

a. 8

b. 16

c. 32

d. 64

96. Which of these is a full form of DNS?

a. Data Network Service

b. Data Name Service

c. Domain Network Service

d. Domain Name Service

MCQ QUESTIONS TOUR2TECH


Page 20 of 38

97. Which of these class is used to encapsulate IP address and DNS?

a. DatagramPacket

b. URL

c. InetAddress

d. ContentHandler

98. URL is an acronym for?

a. Unified Restore Locator

b. Uniform Restore Locator

c. Unified Resource Locator

d. Uniform Resource Locator

99. URL stands for Uniform Resource Locator and represents a resource
on the World Wide Web, such as a Web page or FTP directory.

a. True

b. False

100. Which of these is an instance variable of class httpd?

a. Port

b. Cache

c. Log

d. All of above

101. Which of these class is used for operating on request from the client to
the server?

a. http

b. httpDecoder

c. httpConnection

d. httpd

102. Which of these interface abstractes the output of messages from httpd?

a. LogMessage

b. LogResponse

MCQ QUESTIONS TOUR2TECH


Page 21 of 38

c. Httpdserver

d. httpdResponse

103. Which class is used to create servers that listen for either local client or
remote client programs?

a. httpServer

b. httpResponse

c. httpRequest

d. ServerSockets

104. The DatagramSocket and DatagramPacket classes are not used for
connection-less socket programming.

a. False

b. True

105. Which method of URL class represents a URL and it has complete set of
methods to manipulate URL in Java?

a. java.net.URLConnection

b. java.net.URL

c. Both A & B

d. None of the above

106. Which classes are used for connection-less socket programming?

a. DatagramSocket

b. DatagramPacket

c. Both A & B

d. None of the above

107. Which methods are commonly used in ServerSocket class?

a. public synchronized void close()

b. public Socket accept()

c. public OutputStream getOutputStream()

d. None of the above

MCQ QUESTIONS TOUR2TECH


Page 22 of 38

108. Which constructor of DatagramSocket class is used to create a datagram


socket and binds it with the given Port Number?

a. DatagramSocket(int port)

b. DatagramSocket()

c. DatagramSocket(int port, InetAddress address)

d. None of the above

109. Give the abbreviation of BSD.

a. Berkeley System Distribution

b. Berkeley Socket Distribution

c. Berkeley Software Distribution

d. None of the above

110. The client in socket programming must know which information’s?

a. IPaddress of Server

b. Port number

c. Both A & B

d. None of the above

111. The URLConnection class can be used to read and write data to the
specified resource referred by the URL

a. True

b. False

112. What does the java.net.InetAddress class represent?

a. Socket

b. IP Address

c. MAC Address

d. Protocol

MCQ QUESTIONS TOUR2TECH


Page 23 of 38

113. Datagram is basically an information but there is no guarantee of


its content, arrival or arrival time.

a. False

b. True

114. The flush() method of PrintStream class flushes any uncleared


buffers in memory

a. True

b. False

115. TCP, FTP, Telnet, SMTP, POP etc. are examples of?

a. Socket

b. Protocol

c. MAC Address

d. IP Address

116. Which of these class is used to create servers that listen for either local
or remote client programs?

a. httpServer

b. ServerSockets

c. MimeHeader

d. HttpResponse

117. Which of these is a standard for communicating multimedia content over


email?

a. http

b. https

c. Mime

d. httpd

118. Which of these methods is used to make raw MIME formatted string?

a. parse()

b. toString()

MCQ QUESTIONS TOUR2TECH


Page 24 of 38

c. getString()

d. parseString()

119. Which of these method of MimeHeader is used to return the string


equivalent of the values stores on MimeHeader?

a. string()

b. toString()

c. convertString()

d. getString()

120. Which of these class is used for operating on request from the client to
the server?

a. http

b. httpDecoder

c. httpConnection

d. httpd

121. In InetAddress class which method returns the host name of the IP
Address?

a. public static InetAddress getLocalHost()

b. public String getHostAddress()

c. public String getHostName()

d. None of the above

122. Which of these methods of httpd class is used to read data from the
stream?

a. getDta()

b. GetResponse()

c. getStream()

d. getRawRequest()

MCQ QUESTIONS TOUR2TECH


Page 25 of 38

UNIT – 5

123. Which of the following contains both date and time?

a. java.io.date

b. java.sql.date

c. java.util.date

d. java.util.dateTime

124. Which of the following is advantage of using JDBC connection


pool?

a. Slow performance

b. Using more memory

c. Using less memory

d. Better performance

125. Which of the following is advantage of using


PreparedStatement in Java?

a. Slow performance

b. Encourages SQL injection

c. Prevents SQL injection

d. More memory usage

126. Which one of the following contains date information?

a. java.sql.TimeStamp

b. java.sql.Time

c. java.io.Time

d. java.io.TimeStamp

127. What does setAutoCommit(false) do?

a. commits transaction after each query

b. explicitly commits transaction

MCQ QUESTIONS TOUR2TECH


Page 26 of 38

c. does not commit transaction automatically after each query

d. never commits transaction

128. Which of the following is used to call stored procedure?

a. Statement

b. PreparedStatement

c. CallableStatment

d. CalledStatement

129. Which of the following is used to limit the number of rows returned?

a. getMinRows(int i)

b. setMinRows(int i)

c. getMaxrows(int i)

d. setMaxRows(int i)

130. Which methods returns a stream that simply provides the raw bytes
from the database without any conversion?

a. getUnicodeStream

b. getAsciiStream

c. getCharacterStream

d. getBinaryStream

131. How many JDBC Driver types does Sun define?

a. 1

b. 2

c. 3

d. 4

132. Who invented java?

a. Sun
b. Microsoft

MCQ QUESTIONS TOUR2TECH


Page 27 of 38

c. Google

d. Netscape

133. The intent is for JDBC drivers to implement nonscrollable result sets
using the support provided by the underlying database systems.

a. True

b. False

134. Which method drops all changes made since the previous
commit/rollback?

a. public void close()

b. public void commit()

c. public void rollback()

d. public Statement createStatement()

135. Which of the following is method of JDBC batch process?

a. setBatch()

b. deleteBatch()

c. removeBatch()

d. addBatch()

136. Which of the following is used to rollback a JDBC transaction?

a. rollback()

b. rollforward()

c. deleteTransaction()

d. RemoveTransaction()

137. Which of the following is not a JDBC connection isolation levels?

a. TRANSACTION_NONE

b. TRANSACTION_READ_COMMITTED

c. TRANSACTION_REPEATABLE_READ

d. TRANSACTION_NONREPEATABLE_READ

MCQ QUESTIONS TOUR2TECH


Page 28 of 38

138. The performance of the application will be faster if you use


PreparedStatement interface because query is compiled only once.

a. True

b. False

139. Abbreviate the term UDA?

a. Uniform Data Access

b. Unified Data Access

c. Universal Digital Access

d. Universal Data Access

140. How many Result sets available with the JDBC 2.0 core API?

a. 2

b. 4

c. 3

d. 6

141. Which method is used for retrieving streams of both ASCII and
Unicode characters is new in the JDBC 2.0 core API?

a. getUnicodeStream

b. getAsciiStream

c. getBinaryStream

d. getCharacterStream

142. Which JDBC type represents a "single precision" floating point number
that supports seven digits of mantissa?

a. FLOAT

b. DOUBLE

c. REAL

d. INTEGER

MCQ QUESTIONS TOUR2TECH


Page 29 of 38

143. The JDBC API has always supported persistent storage of objects
defined in the Java programming language through the methods getObject
and setObject.

a. False

b. True

144. In order to transfer data between a database and an application written in


the Java programming language, the JDBC API provides which of these
methods?

a. Methods on the CallableStatement class for retrieving SQL OUT parameters as


Java types.

b. Methods on the PreparedStatement class for sending Java types as SQL


statement parameters.

c. Methods on the ResultSet class for retrieving SQL SELECT results as Java types.

d. All mentioned above

145. The ACID properties does not describes the transaction management
well.

a. False

b. True

146. Which method is used to establish the connection with the specified url
in a Driver Manager class?

a. public static Connection getConnection(String url,String userName,String


password)

b. public static void deregisterDriver(Driver driver)

c. public static void registerDriver(Driver driver)

d. public static Connection getConnection(String url)

147. Which Indicates a result set that cannot be updated programmatically in


concurrency?

a. CONCUR_READ_ONLY
b. CONCUR_UPDATABLE
c. All of the above
d. None of the above

MCQ QUESTIONS TOUR2TECH


Page 30 of 38

148. Which driver Network connection is indirect that a JDBC client makes to
a middleware process that acts as a bridge to the DBMS server?

a. Native API as basis

b. JDBC-ODBC bridge

c. JDBC-Net

d. Native protocol as basis

149. JDBC RowSet is the wrapper of ResultSet,It holds tabular data like
ResultSet but it is easy and flexible to use.

a. False

b. True

150. Which kind of driver converts JDBC calls into calls on the client API for
Oracle, Sybase, Informix, IBM DB2, or other DBMS?

a. Native-protocol pure Java driver

b. JDBC-Net pure Java driver

c. JDBC-ODBC bridge plus ODBC driver

d. Native-API partly-Java driver

151. Which interfaces provide methods for batch processing in JDBC?

a. java.sql.Statement

b. java.sql.PreparedStatement

c. None of the above

d. All the above

152. Which is used to call the stored procedures and functions?

a. PreparedStatement Interface

b. CallableStatement Interface

c. All the above

d. None of the above

MCQ QUESTIONS TOUR2TECH


Page 31 of 38

153. Drivers that are JDBC Compliant should normally support scrollable
result sets, but they are not required to do so.

a. False

b. True

154. The ResultSet.next method is used to move to the next row of the
ResultSet, making it the current row.

a. True

b. False

MCQ QUESTIONS TOUR2TECH


Page 32 of 38

UNIT – 6

155. How constructor can be used for a servlet?

a. Initialization

b. Constructor function

c. Initialization and Constructor function

d. Setup() method

156. Can servlet class declare constructor with ServletConfig object as an


argument?

a. True

b. False

157. Which of the following code is used to get an attribute in a HTTP Session
object in servlets?

a. session.getAttribute(String name)

b. session.alterAttribute(String name)

c. session.updateAttribute(String name)

d. session.setAttribute(String name)

158. Which method is used to get three-letter abbreviation for locale’s country
in servlets?

a. Request.getISO3Country()

b. Locale.getISO3Country()

c. Response.getISO3Country()

d. Local.retrieveISO3Country()

159. Connection Pooling Class manages no of user requests for connections


to improve the performance.

a. False

b. True

MCQ QUESTIONS TOUR2TECH


Page 33 of 38

160. Which object of HttpSession can be used to view and manipulate


information about a session?

a. last accessed time

b. creation time

c. session identifier

d. All mentioned above

161. Using mail API we cannot send mail from a servlet.

a. False

b. True

162. Which class provides stream to read binary data such as image etc. from
the request object?

a. ServletOutputStream

b. ServltInputStream

c. Both A & B

d. None of the above

163. The sendRedirect() method of HttpServletResponse interface can be used


to redirect response to another resource, it may be servlet, jsp or html file.

a. False

b. True

164. Which of these ways used to communicate from an applet to servlet?

a. Socket Communication

b. HTTP Communication

c. RMI Communication

d. All mentioned above

165. Which methods are used to bind the objects on HttpSession instance and
get the objects?

a. getAttribute
b. setAttribute
c. Both A & B
d. None of the above

MCQ QUESTIONS TOUR2TECH


Page 34 of 38

166. Which type of ServletEngine is a server that includes built-in support for
servlets?

a. Standalone ServletEngine

b. Add-on ServletEngine

c. Embedded ServletEngine

d. None of the above

167. What type of servlets use these methods doGet(), doPost(),doHead,


doDelete(), doTrace()?

a. HttpServlets

b. Genereic Servlets

c. All of the above

d. None of the above

168. Which cookie it is valid for single session only and it is removed each
time when the user closes the browser?

a. Non-persistent cookie

b. Persistent cookie

c. All the above

d. None of the above

169. Sessions is a part of the SessionTracking and it is for maintaining the


client state at server side.

a. False

b. True

170. Web server is used for loading the init() method of servlet .

a. False

b. True

MCQ QUESTIONS TOUR2TECH


Page 35 of 38

171. Servlets handle multiple simultaneous requests by using threads.

a. True

b. False

172. Which method is used to send the same request and response objects
to another servlet in RequestDispacher ?

a. sendRedirect()

b. forward()

c. Both A & B

d. None of the above

173. Which packages represent interfaces and classes for servlet API?

a. javax.servlet.http

b. javax.servlet

c. Both A & B

d. None of the above

174. Which HTTP Request method is non-idempotent?

a. POST

b. GET

c. BOTH A & B

d. None of the above

175. Which class can handle any type of request so that it is protocol-
independent?

a. HttpServlet

b. GenericServlet

c. Both A & B

d. None of the above

MCQ QUESTIONS TOUR2TECH


Page 36 of 38

176. Which object is created by the web container at time of deploying the
project?

a. ServletContext

b. ServletConfig

c. Both A & B

d. None of the above

177. What is the lifecycle of a servlet?

a. init, Service, destroy method is invoked

b. Servlet instance is created

c. Servlet class is loaded

d. All mentioned above

178. Which of the following code retrieves the body of the request as binary
data?

a. DataInputStream data = new InputStream()

b. DataInputStream data = response.getInputStream()

c. DataInputStream data = request.getInputStream()

d. DataInputStream data = request.fetchInputStream()

179. When destroy() method of a filter is called?

a. The destroy() method is called only once at the end of the life cycle of a filter

b. The destroy() method is called after the filter has executed doFilter method

c. The destroy() method is called only once at the begining of the life cycle of a filter

d. The destroyer() method is called after the filter has executed

180. Which of the following is true about servlets?

a. Servlets execute within the address space of web server

b. Servlets are platform-independent because they are written in java

c. Servlets can use the full functionality of the Java class libraries

d. Servlets execute within the address space of web server, platform independent and uses
the functionality of java class libraries

MCQ QUESTIONS TOUR2TECH


Page 37 of 38

181. How is the dynamic interception of requests and responses to transform


the information done?

a. servlet container

b. servlet config

c. servlet context

d. servlet filter

182. Which of the below is not a session tracking method?

a. URL rewriting

b. History

c. Cookies

d. SSL sessions

183. Which of the following is stored at client side?

a. URL rewriting

b. Hidden form fields

c. SSL sessions

d. Cookies

184. Which of the following leads to high network traffic?

a. URL rewriting

b. Hidden form fields

c. SSL sessions

d. Cookies

MCQ QUESTIONS TOUR2TECH


Page 38 of 38

Notes & Tips

1. All these MCQ Questions are for practice & have taken from your syllabus.
2. Don’t Byheart, understand the concept.
3. Do more and more practice.
4. Read your Textbooks 1st and then practice this MCQ’s.

Motivational Quotes

Don’t Stress.

Do Your Best.

Forget the Rest.

MCQ QUESTIONS TOUR2TECH

You might also like