It8501 Web Technology
It8501 Web Technology
M
3. A typical _________ program creates some
remote objects, makes references to these
IT - 5TH
O
objects accessible, and waits for clients to
invoke methods on these objects.
SEMESTER a) Server
C
b) Client
c) Thread
T.
Reg. 2017 d) Concurrent
Answer: a
O
Explanation: A server program creates
remote objects. It gives reference to these
objects and then waits for clients to invoke
SP
UNIT I WEB SITE BASICS methods on these objects.
a) Server
COMMUNICATION b) Client
c) Thread
1. RMI stands for? d) Concurrent
.B
environment. c) Bit
a) True d) Stub/skeleton
b) False
Answer: d
C
6. A layer which is the binary data protocol 10. RMI uses stub and skeleton for
layer. communication with the ________ object.
a) stub layer a) client
b) skeleton layer b) remote
c) remote layer c) server
M
d) transport protocol d) any
Answer: d Answer: b
O
Explanation: The transport protocol layer is Explanation: RMI uses stub and skeleton
the binary data protocol that sends remote object for communication with the remote
C
object requests over the wire. A client is any object. A remote object is an object whose
remote application that communicates with method can be invoked from another JVM.
T.
these server objects.
O
a) remote layer
b) instruction layer 1. What is internet?
SP
c) reference layer a) a single network
d) remote reference layer b) a vast collection of different networks
c) interconnection of local area networks
Answer: d d) interconnection of wide area networks
G
Explanation: The remote reference layer is
the middleware between the stub/skeleton Answer: b
layer and underlying transport protocol. Explanation: Internet is nothing but an
LO
b) stub protocols.
c) remote
d) server 2. To join the internet, the computer has to be
connected to a _________
17
M
Explanation: An IPv6 address is 128 bits
Answer: b long. Therefore, 2128 i.e. 340 undecillion
Explanation: DSL (Digital Subscriber Line) addresses are possible in IPv6. IPv4 has only
O
is the technology designed to use the existing 4 billion possible addresses and IPv6 would
telephone lines to transport high-bandwidth be a brilliant alternative in case IPv4 runs out
C
data to service subscribers. DSL was used to of possible new addresses.
allow the early users access to the internet
T.
and it provides dedicated, point-to-point, 7. Internet works on _______
public network access. a) packet switching
b) circuit switching
4. ISP exchanges internet traffic between c) both packet switching and circuit switching
O
their networks by __________ d) data switching
a) internet exchange point
SP
b) subscriber end point Answer: a
c) isp end point Explanation: Packet switching is the method
d) internet end point based on which the internet works. Packet
switching features delivery of packets of data
G
Answer: a between devices over a shared network.
Explanation: ISPs exchange internet traffic
between their networks by using Internet 8. Which one of the following is not an
LO
Exchange Points. ISPs and CDNs are application layer protocol used in internet?
connected to each other at these physical a) remote procedure call
locations are they help them provide better b) internet relay chat
service to their customers. c) resource reservation protocol
.B
Answer: d
Explanation: HTTP is used to browse all the 9. Which protocol assigns IP address to the
websites on the World Wide Web, DHCP is client connected in the internet?
a) DHCP
SE
assign IP address to the clients connected to c) both is same every time whenever it
the internet. The server that performs this displays and generates on demand by a
fuction is called the DHCP server. program or a request from browser
d) is different always in a predefined order
10. Which one of the following is not used in
M
media access control? Answer: b
a) ethernet Explanation: A dynamic web page provides
b) digital subscriber line different content every time the user opens it
O
c) fiber distributed data interface based on some events like new additions or
d) packet switching time of the day. Languages such as JavaScript
C
are used to respond to client-side events while
Answer: d languages such as PHP as used to respond to
T.
Explanation: Packet switching is not really server-side events.
related to media access control as it just
features delivery of packets of data between 3. What is a web browser?
devices over a shared network. Internet is a) a program that can display a web page
O
actually based on packet switching. b) a program used to view html documents
c) it enables user to access the resources of
SP
internet
TOPIC 1.3 THE WORLD WIDE d) all of the mentioned
WEB-HTTP REQUEST
MESSAGE-RESPONSE Answer: d
G
MESSAGE-WEB CLIENTS WEB Explanation: A web browser is an
application program that is used to access the
SERVERS World Wide Web resources, applications and
LO
Answer: c Answer: a
Explanation: The Uniform Resource Locator Explanation: VBScript is a general-purpose,
M
is a locator for the resource to be located by lightweight and active scripting language
HTTP on the World Wide Web. The URL is which can be used on Microsoft Visual Basic.
derived from the Uniform Resource Identifier. It was first released in 1996.
O
6. A web cookie is a small piece of data that 9. What is document object model (DOM)?
C
is _______ a) convention for representing and interacting
a) sent from a website and stored in user’s with objects in html documents
T.
web browser while a user is browsing a b) application programming interface
website c) hierarchy of objects in ASP.NET
b) sent from user and stored in the server d) scripting language
while a user is browsing a website
O
c) sent from root server to all servers Answer: a
d) sent from the root server to other root Explanation: DOM is a hierarchical model
SP
servers i.e. a tree used to represent an HTML or
XML document. Every node of the tree an
Answer: a object that represents a part of the document.
Explanation: A web cookie is a small piece
10. AJAX stands for _______
G
of data sent from a website and stored in
user’s web browser while a user is browsing a) asynchronous javascript and xml
the website and is used to remember stateful b) advanced JSP and xml
LO
information about the user’s operations on the c) asynchronous JSP and xml
website. This can help the website provide a d) advanced javascript and xml
better browsing experience to the user.
Answer: a
Explanation: AJAX is a group of
.B
Answer: d
TOPIC 1.4 MARKUP
-R
be used along with JavaScript to generate 1. State whether the given statement is true or
dynamic web pages which are visually false. !DOCTYPE is case sensitive”.
compelling. a) True
b) False
8. An alternative to JavaScript on windows
C
“!DOCOTYPE” is case sensitive in XML and web browser about what version of HTML
it is not case sensitive in HTML, we can write the page is written in. The XHTML doctype
the “!DOCTYPE” declaration in both declaration “!DOCTYPE html PUBLIC
lowercase and uppercase, thus both are valid. “-//W3C//DTD XHTML 1.0 Strict//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-
M
2. Choose the correct statement. strict.dtd”” is of XHTML 1.0 strict,
a) In traditional XHTML close tag for some “!DOCTYPE html PUBLIC “-//W3C//DTD
elements is optional but not encouraged
O
XHTML 1.0 Transitional//EN”
b) In traditional HTML close tag for some “http://www.w3.org/TR/xhtml1/DTD/xhtml1-
elements is optional but not encouraged transitional.dtd”” is of XHTML 1.0
C
c) In both traditional XHTML and HTML transitional, “!DOCTYPE html PUBLIC
close tag for some elements is not optional “-//W3C//DTD XHTML 1.0 Frameset//EN”
T.
d) In both traditional XHTML and HTML “http://www.w3.org/TR/xhtml1/DTD/xhtml1-
close tag for some elements is optional frameset.dtd”” is of XHTML 1.0 frameset
and “<!DOCTYPE html PUBLIC
Answer: b “-//W3C//DTD XHTML 1.1//EN”
O
Explanation: In XHTML all elements must “http://www.w3.org/TR/xhtml11/DTD/xhtml11
always be closed and empty elements also be is of XHTML 1.1.
SP
closed. XHTML close tags are not optional
neither they are encouraged. HTML is case 4. Which of the following is not a difference
insensitive and thus closing tags for some between HTML and XHTML?
elements including empty elements is a) Charset in html is “text/html” where as in
G
optional and is ignored by browsers. xhtml it is “application/xml+xhtml”
b) Charset in both html and xhtml is
3. Which of the following XHTML doctype “text/html”
LO
declaration contains all HTML elements and c) Tags and attributes are case-insensitive in
attributes, including presentational and HTML but not in XHTML
deprecated elements (like font) but not d) Special characters must be escaped using
framesets? character entities in XHTML unlike HTML
.B
Answer: b
Explanation: The !DOCTYPE declaration is Answer: b
not an HTML tag; it is an instruction to the Explanation: Content-type: header indicates
the content in the file is HTML and we can 9. Which of the following are table tags?
see file content through it when delivered on a) table, thead, tr, td
the network. “.html” is the file extension for b) colspan, table, tr
HTML. c) table, tt, tr, td
d) thead, colspan, td, tr
M
6. State whether the given statement is true or
false. “We can intermix XHTML and HTML Answer: a
4.01 documents” Explanation: Table has different tags such as
O
a) True table, thead, tr, td, etc whereas colospan is an
b) False attribute of table.
C
Answer: b 10. Choose the correct HTML for width
T.
Explanation: HTML is not in XML format. attribute and its value.
You have to make the changes necessary to a) width=80
make the document proper XML before you b) width=”80″
can get it accepted as XML. c) WIDTH=”80″
O
d) WIDTH=80
7. HTML and XHTML stands for ______
SP
a) Hyper Text Markup Language and Answer: b
Extensible HyperText Markup Language Explanation: Always mention the attribute
b) Hyper Text Markup Language and value in quotes in HTML. It is one of the rule
Extensible HyperText Marking Language of HTML attributes.
G
c) Hyper Text Marking Language and
EXtensible HyperText Marking Language
d) Hyper Text Marking Language and
TOPIC 1.5 AN INTRODUCTION
LO
<h1> to <h6> in which <h1> heading is the lowercase and uppercase, thus both are valid.
largest one and <h6> is smallest one among
those. The heading tags are <h1> <h2> <h3> 2. Choose the correct statement.
<h4> <h5> and <h6> that are used for the a) In traditional XHTML close tag for some
C
close tag for some elements is not optional “-//W3C//DTD XHTML 1.0 Frameset//EN”
d) In both traditional XHTML and HTML “http://www.w3.org/TR/xhtml1/DTD/xhtml1-
close tag for some elements is optional frameset.dtd”” is of XHTML 1.0 frameset
and “<!DOCTYPE html PUBLIC
Answer: b “-//W3C//DTD XHTML 1.1//EN”
M
Explanation: In XHTML all elements must “http://www.w3.org/TR/xhtml11/DTD/xhtml11
always be closed and empty elements also be is of XHTML 1.1.
closed. XHTML close tags are not optional
O
neither they are encouraged. HTML is case 4. Which of the following is not a difference
insensitive and thus closing tags for some between HTML and XHTML?
C
elements including empty elements is a) Charset in html is “text/html” where as in
optional and is ignored by browsers. xhtml it is “application/xml+xhtml”
T.
b) Charset in both html and xhtml is
3. Which of the following XHTML doctype “text/html”
declaration contains all HTML elements and c) Tags and attributes are case-insensitive in
attributes, including presentational and HTML but not in XHTML
O
deprecated elements (like font) but not d) Special characters must be escaped using
framesets? character entities in XHTML unlike HTML
SP
a) !DOCTYPE html PUBLIC “-//W3C//DTD
XHTML 1.0 Strict//EN” Answer: b
“http://www.w3.org/TR/xhtml1/DTD/xhtml1- Explanation: HTML is case insensitive while
strict.dtd” XHTML is case sensitive. In XHTML,
G
b) !DOCTYPE html PUBLIC “-//W3C//DTD special characters can be escaped using
XHTML 1.0 Transitional//EN” character entites but not in HTML. Charset in
“http://www.w3.org/TR/xhtml1/DTD/xhtml1- HTML is “text/html” where as it is
LO
“http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>
d) The “content_type” header
Answer: b
Explanation: The !DOCTYPE declaration is Answer: b
not an HTML tag; it is an instruction to the Explanation: Content-type: header indicates
-R
web browser about what version of HTML the content in the file is HTML and we can
the page is written in. The XHTML doctype see file content through it when delivered on
declaration “!DOCTYPE html PUBLIC the network. “.html” is the file extension for
SE
“http://www.w3.org/TR/xhtml1/DTD/xhtml1- a) True
transitional.dtd”” is of XHTML 1.0 b) False
transitional, “!DOCTYPE html PUBLIC
M
d) WIDTH=80
7. HTML and XHTML stands for ______
a) Hyper Text Markup Language and Answer: b
O
Extensible HyperText Markup Language Explanation: Always mention the attribute
b) Hyper Text Markup Language and value in quotes in HTML. It is one of the rule
C
Extensible HyperText Marking Language of HTML attributes.
c) Hyper Text Marking Language and
T.
EXtensible HyperText Marking Language
d) Hyper Text Marking Language and
TOPIC 1.6 SOME
Extensible HyperText Markup Language FUNDAMENTAL HTML
ELEMENTS
O
Answer: a
Explanation: HTML stands for “Hyper Text 1. Which attribute specifies a unique
SP
Markup Language” and XHTML stand for alphanumeric identifier to be associated with
“Extensible HyperText Markup Language”. an element?
a) class
8. Choose the correct tag for the largest
b) id
G
heading in HTML.
c) article
a) h6
d) html
b) heading
LO
c) h1 Answer: b
d) head Explanation: HTML is Hyper Text Markup
Language which is used to create web pages
Answer: c
and applications. The id attribute is most used
.B
Answer: b
Explanation: Style attribute specifies an
M
elements which can be used by CSS and data is rendered. The identifier for data source
JavaScript for styling the web pages. List of is set by dataSrc. Datafld attribute specifies
the column name from the data source object
O
directory files is given by dir tag which is not
supported in HTML5. that supplies the bound data. This attribute is
specific to Microsoft’s data binding. A
C
3. Which attribute is used to provide an Disabled is a boolean attribute which
advisory text about an element or its specifies that <input> element should be
T.
contents? disabled.
a) tooltip
b) dir 6. Which of the following is the attribute that
c) title indicates the name of the data source object
O
d) head that supplies the data that is bound to this
element?
SP
Answer: c a) dataFormatAs
Explanation: The extra information about an b) datafld
element is specified by title tag. The c) disabled
information is most often shown as a tooltip d) datasrc
G
text when the mouse moves over the element.
List of directory files is given by dir tag Answer: d
which is not supported in HTML5. Tooltip or Explanation: The identifier for data source is
LO
else infotip is a graphical user interface of an set by dataSrc. When the dataSrc property is
element. Container of metadata is called head. applied to a tabular data consumer, the entire
data set is repeated by the consuming
4. The __________ attribute sets the text elements. DataFormatAs specifies how data is
.B
source object that supplies the bound data? specified by height attribute. The hspace
a) dataFormatAs attribute specifies the whitespace on left and
b) datafld right side of an object. The hidefocus
specifies whether a focused rectangle is the item’s descendants. Markup without the
drawn around an object. The identifier for microdata-related attributes does not have any
data source is set by dataSrc. effect on the microdata model. Itemref
provides list of elements id’s with
8. The accesskey attribute specifies a extra/additional properties in the document.
M
keyboard navigation accelerator for the
element.
a) True TOPIC 1.7 RELATIVE URLS-
O
b) False LISTS-TABLES-FRAMES-
FORMS-HTML 5.0
C
Answer: a
Explanation: The accesskey attribute
1. Each cell of the table can be represented by
T.
specifies a shortcut key to activate/focus an
using __________
element. It specifies a keyboard navigation
a) <tr>
accelerator for the element. We can use
b) <td>
accesskey attribute in forms or links.
O
c) <th>
9. Which of the following is the attribute that d) <thead>
SP
is used to set a global identifier for a
Answer: b
microdata item?
Explanation: td stands for table data, we can
a) key
represent each cell of the table by using <td>,
b) id
at the end we used </td> tag. But some
G
c) itemclass
browsers by default draw the lines around
d) itemid
table. <tr> is used to indicate start of every
LO
d) <th>
10. Which of the following is the attribute
Answer: d
that is used to add a name/value pair to a
Explanation: <th> element is used for
microdata item?
-R
d) itemid
heading is for row or column. Usually content
Answer: c of <th> is represented in bold. <thead> tag
Explanation: A boolean global attribute contains the group of header. <tr> is used to
which specifies scope of associated metadata indicate start of every row i.e. it stands for
C
b) <tfoot> b) <thead>
c) <th> c) <th>
d) <tbody> d) <tr>
Answer: a Answer: a
M
Explanation: Headings of the table lies inside Explanation: For adding caption to the table
<thead> element. Footer lies inside the we use <caption> tag. It should be used just
<tfoot> element. The body of the table lies below the <table> tag.
O
inside <tbody> element. <th> is used for
Syntax is
giving heading to a row or a column. Every
<table>
C
element must have closing tag also i.e. <caption> Savings </caption>
</thead>, </tfoot>, </tbody> <tr> <th> saving </th><th>loss</th> </tr>
T.
<tr><td>$12</td>$45<td></td> </tr>
4. Which of the following is not the element </table>.
associated with HTML table layout?
a) size <thead> tag contains the group of header.
O
b) spanning <tr> is used to indicate start of every row i.e.
c) alignment it stands for table row. The header
SP
d) color information is present in <th> tag.
6. For adding caption to the table we use structural elements. For setting borders with
____________ <tr> element, border-collapse property should
a) <caption> be set to collapse.
Syntax is Answer: d
table {border-collapse: collapse;} Explanation: scope attribute defines a set of
th, td{border-bottom: 2px dotted red; }
tfoot tr:last-child td{border-bottom: 9 p
data cell. It is used in place of headers. This
x;} attribute can have one of the value among
rowgroup, row, colgroup, col, rowgroup, and
M
9. Which attribute defines numbers of colgroup provides information of header cell
columns in a group? of the corresponding row and column groups.
O
a) width=multi-length[CN].
b) span=number[CN]. 12. Which of the following is not the value
c) scope=scope-name[CN]. for frame attribute?
C
d) headers=idrefs[CS]. a) above
b) void
T.
Answer: b c) none
Explanation: span=number[CN] attribute’s d) box
value must be an integer and greater than 0. It
specifies the number of columns in a group. Answer: c
O
When span attribute is not in use, colgroup Explanation: Frame attribute gives
defines a single column group containing one information about which sides of the frame
SP
column. width=multi-length[CN] specifies surrounding that table will be visible. The
default width of for every column. values that this attribute can take are lhs, rhs,
scope=scope-name[CN] specifies set of data box, border, vsides, hsides, below, above,
cells for which going header cell gives header void.
G
information. The headers=idrefs[CN]
provides list of header cells that gives header 13. Which of the following is not the value
information. for rules attribute?
LO
a) vsides
10. Which of the following does not specify a b) rows
column width? c) all
a) Fixed d) groups
.B
b) Percentage
c) Proportional Answer: a
d) Pixels Explanation: The rules which will appear
between cells of the table is specified by this
17
b) rowgroup Answer: c
c) col Explanation: align attribute is the alignment
d) <head> of data and for justification of text in the cell.
It can take the values left, right, justify, 2. Which of the following selector selects the
center, char. Justify is for double justifying elements that are checked?
the text, char is for aligning text around a
particular character. a) E ~ F
b) ::after
M
c) :checked
15. valign attribute does not take the value d) none of the mentioned
__________________
a) justify Answer: c
O
b) middle Explanation:
c) baseline
C
d) bottom Example: :checked {color: blue;}
T.
Answer: a
Explanation: valign attribute is for 3. Which of the following selector selects the
specifying the vertical position of the data in elements that are the default among a set of
a cell. It can take the values middle, top,
O
similar elements?
baseline, bottom, Top is for the top of the
cell’s data, middle is for the centered data, a) :default
SP
bottom is for the bottom of the cell, first text b) :%
line occurs on the baseline which is common c) :disabled
d) none of the mentioned
to all the cells.
Answer: a
G
Explanation:
Example: :default {background-color: red;
LO
SIDE SCRIPTING
4. Which of the following selector selects an
.B
c) :inheritance
d) :no-child
1. Which of the following selector selects all
elements of E that have the attribute attr that Answer: a
end with the given value?
-R
Explanation: None.
a) E[attr^=value]
b) E[attr$=value]
c) E[attr*=value] 5. Which of the following selector selects the
SE
Answer: c
Explanation:
Answer: a
M
6. Which of the following selector selects the
element that is the first child of its parent that Explanation:
is of its type? Example: :target{color:red;}
O
a) :first-of-type
b) :last-child
C
c) ::first-line
d) ::first-letter 10. Which of the following selector applies
styles to elements that are valid per HTML5
T.
Answer: a validations set either with the pattern or type
Explanation: attributes?
Example: strong:first-of-type {font-size:
O
a) :valid
bigger;} b) :required
c) :optional
SP
d) :invalid
b) :nth-oftype(n)
c) :only-child b) /! comments !/
d) none of the mentioned c) /* comments */
Answer: c d) None of the mentioned
SE
Explanation:
Answer: c
Example: h1:only-child {color: blue;} Explanation: Comments can be placed
within style sheets. Style sheets use the
comment syntax used in C programming
C
9. Which of the following selector selects the 2. A single _____________ rule can be used
element that is the target of a referring URI? in an external sheet to define character set
encoding of the style rules and values. 6. Which of the following property specifies
a) @media the size of the mask?
b) @charset a) box-sizing
c) @font-face b) box-shadow
d) None of the mentioned c) box-reflect
M
d) none of the mentioned
Answer: b
Explanation: None. Answer: c
O
Explanation:
3. An ___________ rule can be used to define
C
style rules for multiple media types in a single Syntax: -webkit-box-reflect: direction of
fset mask-box-image
embedded style sheet
T.
a) @media 7. Which of the following property is used to
b) @charset control column element breaks after an
c) @font-face associated element when flowing
d) None of the mentioned
O
multicolumn text?
a) column-break
Answer: a
b) column-break-after
SP
Explanation: None.
c) column-count
4. An ___________ rule is used to define a d) column-break-before
page block for printed styles.
Answer: b
a) @important
G
Explanation:
b) @page
c) @css Syntax: column-break-after: always | auto
LO
d) @html | avoid
d) column-width
5. Which of the following construct specifies
that a style takes precedence over any Answer: c
different, conflicting styles? Explanation:
-R
c) column-change
d) column-check
Answer: b Answer: d
Explanation: Explanation: Self-explainatory.
Syntax: column-rule: rule-width rule-styl 3. Which of the following property defines
e color
the style for the bottom border of an element?
M
10. Which of the following property defines a) border-bottom-style
the width of a rule between columns in a b) border-collapse
c) border-style-bottom
O
multicolumn text flow?
a) column-width d) none of the mentioned
b) column-rule
C
Answer: a
c) column-float
Explanation: Self-explainatory.
d) column-rule-width
T.
4. Which of the following property defines
Answer: d
the style for the left border of an element?
Explanation:
a) border-style
O
Syntax: column-rule-width: non-negative l b) border-left-style
ength | medium | thick | thin | inherit c) border-left-width
SP
d) border-right
TOPIC 2.3 STYLE RULE Answer: b
CASCADING AND Explanation: Self-explainatory.
INHERITANCE-TEXT
G
PROPERTIES-BOX MODEL 5. Which of the following visibility property
value is described by The element is not
NORMAL FLOW BOX
LO
M
browser is to ___________
Answer: a a) Creating animations and other visual
Explanation: Self-explainatory. effects
O
b) User Interface
8. Which of the following Overflow property c) Visual effects
C
value is described by scrollbars should be d) User experience
provided if the content is too big, but actual
Answer: a
T.
implementation is left up to the browser?
a) visible Explanation: JavaScript can help to facilitate
b) scroll that experience, for example by:
c) auto
O
d) hidden 1. Creating animations and other visual
effects to subtly guide a user and help
SP
Answer: c with page navigation
Explanation: Self-explainatory. 2. Sorting the columns of a table to make
it easier for a user to find what she
9. Which of the following property sets a needs
consistent margin on all four sides of the
G
affected element? 2. A JavaScript program can traverse and
a) boder manipulate document content through
LO
b) margin __________
c) padding a) Element Object
d) none fof the mentioned b) Document Object
c) Both Element and Document Object
Answer: b d) Data object
.B
Explanation: Self-explainatory.
Answer: c
10. Which of the following box-sizing Explanation: A JavaScript program can
17
property value is described by width and traverse and manipulate document content
height include content, padding, and borders? through the Document object and the Element
a) border-box objects it contains. It can alter the
b) content-box presentation of that content by scripting CSS
-R
Answer: b Answer: d
Explanation: The JavaScript program can Explanation: Data storage is used to store
define the behavior of document elements by data locally on user’s computer and
registering appropriate event handlers. A networking is used for connecting between
JavaScript program can traverse and different platforms.
M
manipulate document content through the
Document object and the Element objects it 7. JavaScript code between a pair of “script”
tags are called __________
O
contains.
a) Non-inline
4. The service(s) that enables networking b) External
C
through scripted HTTP requests is c) Referenced
__________ d) Inline
T.
a) XMLHttpResponse
b) XMLRequest Answer: d
c) XMLHttpRequest Explanation: The <script> tag is used to
d) XMLHttps define a client-side script (JavaScript). The
O
<script> element either contains scripting
Answer: c statements, or it points to an external script
SP
Explanation: The best known advanced file through the src attribute. Inline code are
services is the XMLHttpRequest object, those that are written between a pair of
which enables networking through scripted “script” tags.
HTTP requests. The XMLHttpRequest object
G
can be used to request data from a web server. 8. Client-side JavaScript code is embedded
within HTML documents in __________
5. The HTML5 specification does not a) A URL that uses the special
LO
d) Networking javascript:protocol
d) A URL that uses the special
Answer: d javascript:code
Explanation: The HTML5 specification
17
d) Graphics APIs
9. What is the programming philosophy that
argues that content and behaviour should as
M
onsubmit etc.
Answer: a
Explanation: A programming philosophy 2. The type of a variable that is volatile is
O
known as unobtrusive JavaScript argues that _______________
content (HTML) and behavior (JavaScript a) Volatile variable
C
code) should as much as possible be kept b) Mutable variable
separate. According to this programming c) Immutable variable
T.
philosophy, JavaScript is best embedded in d) Dynamic variable
HTML documents using “script” elements
with src attributes. Answer: b
Explanation: The variables whose values can
O
10. Which of the following communicates be changed are called mutable variable types.
with server-side CGI scripts through HTML In JavaScript, only objects and arrays are
SP
form submissions and can be written without mutable, not primitive values.
the use of JavaScript?
a) Static Web Pages 3. A hexadecimal literal begins with
b) Interactive Web Pages __________
G
c) Conditional Web Pages a) 00
d) All web pages b) 0x
c) 0X
LO
communicate with server-side CGI scripts hexadecimal values. So, any integer literal
through HTML form submissions were the that begins with 0X or 0x denotes a
original “web application” and can be written hexadecimal number.
without the use of JavaScript.
17
5. JavaScript _________ when there is an It skips to the start of the next page. (Applies
indefinite or an infinite value during an mostly to terminals where the output device is
arithmetic computation. a printer rather than a VDU).
a) Prints an exception error
b) Prints an overflow error 8. The snippet that has to be used to check if
M
c) Displays “Infinity” “a” is not equal to “null” is _________
d) Prints the value as such a) if(a!=null)
b) if (!a)
O
Answer: c c) if(a!null)
Explanation: When the result of a numeric d) if(a!==null)
C
operation is larger than the largest
representable number (overflow), JavaScript Answer: d
T.
prints the value as Infinity. Similarly, when a Explanation: A strict comparison (e.g., ===)
negative value becomes larger than the largest is only true if the operands are of the same
representable negative number, the result is type and the contents match. The more
negative infinity. The infinite values behave commonly-used abstract comparison (e.g. ==)
O
as you would expect: adding, subtracting, converts the operands to the same type before
multiplying, or dividing them by anything making the comparison. The not-equal
SP
results in an infinite value (possibly with the operator !== compares 0 to null and evaluates
sign reversed). to either true or false.
6. Which of the following is not considered as 9. The statement a===b refers to _________
G
an error in JavaScript? a) Both a and b are equal in value, type and
a) Syntax error reference address
b) Missing of semicolons b) Both a and b are equal in value
LO
Answer: c Answer: c
.B
Explanation: Division by zero is not an error Explanation: ”===” operator is known as the
in JavaScript: it simply returns infinity or strict comparison operator. A strict
negative infinity. There is one exception, comparison (===) is only true if the operands
however: zero divided by zero does not have are of the same type and the contents match.
17
converted in two ways without using a new characters, same length, and same characters
operator false.toString () and String(false). in corresponding positions.
11. What will be the output of the following 13. What will be the output of the following
JavaScript code? JavaScript code?
M
function compare() function compare()
{ {
O
int num=2; int a=1;
char b=2; char b=1;
if(a==b) if(a.tostring()===b)
C
return true; return true;
else else
return false; return false;
T.
} }
a) true a) true
O
b) false b) false
c) runtime error c) runtime error
d) compilation error d) logical error
Answer: a
Explanation: The == convert different type
of operands to the same type before making SP
Answer: a
Explanation: A non string (integer) can be
converted to string using .tostring() function.
G
the comparison. A strict comparison results A strict comparison is only true if the
into true value if the operands are of the same operands are of the same type and the
LO
type and the contents match. contents match. Hence the following code
snippet would result into true output.
12. What will be the output of the following
JavaScript code? 14. What will be the output of the following
JavaScript code?
.B
function equalto()
{ int a==2;
int num=10; int b=4;
if(num===”10”) int ans=a+b;
17
a) true c) 0
b) false d) error
c) runtime error
d) compilation error Answer: d
SE
M
a) 1 values. Therefore we can access the indexes
b) 0 0, 1 and 2. But array a2 is only defined not
declared. Therefore we cannot access index 0.
O
c) runtime error
d) compiler error
3. The pop() method of the array does which
C
Answer: a of the following task?
Explanation: != is the not equal to operator. a) decrements the total length by 1
T.
It gives a value of 1 if the two values which b) increments the total length by 1
are compared are not equal and give 0 if the c) prints the first element but no effect on the
two values are equal. length
d) updates the element
O
TOPIC 2.6 FUNCTIONS- Answer: a
SP
OBJECTS-ARRAYS-BUILT-IN Explanation: pop() function pops out that is
OBJECTS-JAVASCRIPT delete the last element from the array. Hence
pop() method (it works with push()) reduces
DEBUGGERS.
the length of an array by 1.
G
1. What is the observation made in the 4. What is the observation made in the
following JavaScript code? following JavaScript code?
LO
Answer: a Answer: c
Explanation: Array is defined with a null Explanation: The if loop in the above code
value when no value is mentioned. If you checks whether the value of a[i] exists or not.
omit a value from an array literal, the omitted For undefined, non existent and null values
-R
2. What will be the output of the following 5. What will happen if reverse() and join()
JavaScript code? methods are used simultaneously?
SE
M
respective array and will store the reversed all subsequent elements down one place to
array in the memory. occupy the newly vacant space at the start of
O
the array.
6. What will be the possible output of the
following JavaScript code? 8. The primary purpose of the array map()
C
function is that it __________
var a = [1,2,3,4,5]; a) maps the elements of another array into
a.slice(0,3);
T.
itself
b) passes each element of the array and
a) Returns [1,2,3]
returns the necessary mapped elements
b) Returns [4,5]
c) passes each element of the array on which
O
c) Returns [1,2,3,4]
it is invoked to the function you specify, and
d) Returns [1,2,3,4,5]
returns an array containing the values
SP
Answer: a returned by that function
Explanation: .slice() function is a predefined d) pass the elements of the array into another
function in JavaScript used to keep the array
elements from starting point and ending point
G
Answer: c
mentioned in the function argument. The
Explanation: map() is a predefined function
elements after the ending point and before the
in javascript used for mapping the array
LO
a.unshift(3,[4,5]);
a.shift();
__________
a.shift(); a) filter and fold
a.shift(); b) inject and fold
c) finger and fold
-R
a) 1 d) fold
b) [4,5]
c) [3,4,5] Answer: b
SE
except that they insert and remove elements is stored in an accumulator (result/total).
from the beginning of an array rather than Hence it does the operation of injecting and
from the end. unshift() adds an element or folding.
10. The method or operator used to identify accepts two arguments as the starting and
the array is __________ ending values for slicing elements. As in the
a) isarrayType() above function, only one argument is passed
b) == therefore it will result in an error.
c) ===
M
d) typeof 13. What will be the output of the following
JavaScript code?
Answer: d
O
Explanation: The typeof operator is used to int sum=0;
get the data type (returns a string) of its var arr = [10,15,20,30];
C
operand. The operand can be either a literal or
a data structure such as a variable, a function, arr.forEach(function myFunction(element)
T.
or an object. The operator returns the data {
type. sum= sum+element;
});
document.writeln(sum);
11. What will be the output of the following
O
JavaScript code? a) 70
b) 75
SP
var val1=[1,2,3];
var val2=[6,7,8]; c) 10
var result=val1.concat(val2); d) error
document.writeln(result);
Answer: b
G
a) 1, 2, 3 Explanation: forEach is a predefined
b) Error function in Javascript which used to traverse
c) 1, 2, 3, 6, 7, 8
LO
i.e.1, 2, 3, 6, 7, 8
document.writeln(ans);
12. What will be the output of the following
JavaScript code? a) one
b) two
-R
M
b) 3, 2, 1
Explanation: setTimeout() and setInterval()
c) 3
allow you to register a function to be invoked
d) 1
once or repeatedly after a specified amount of
O
Answer: b time has elapsed. Both these function are used
Explanation: reverse function is a predefined to do time manipulation in javascript.
C
function in array library in Javascript. The
3. Which is the handler method used to
function is used to reverse the element of the
T.
invoke when uncaught JavaScript exceptions
array.
occur?
i.e. 3, 2, 1.
a) Onhalt
b) Onerror
O
c) Both onhalt and onerror
d) Onsuspend
SP
UNIT III SERVER SIDE Answer: b
SCRIPTING Explanation: The onerror handler method
can be registered to be invoked when
G
uncaught JavaScript exceptions occur. The
TOPIC 3.1 HOST OBJECTS: onerror event is triggered if an error occurs
BROWSERS AND THE DOM- while loading an external file (e.g. a
LO
a) modal
1. Which function among the following lets to b) version
register a function to be invoked once? c) browser
a) setTimeout() d) navigator
17
b) setTotaltime()
c) setInterval() Answer: d
d) settime() Explanation: The navigator property is used
to obtain browser vendor and version
-R
M
value returned by setInterval() is used as the a) Window
parameter for the clearInterval() method. b) Position
c) Element
O
6. The setTimeout() belongs to which object? d) Location
a) Element
C
b) Window Answer: a
c) Location Explanation: The location property of the
T.
d) Event Window object refers to a Location object,
which represents the current URL of the
Answer: b document displayed in the window. The
Explanation: The setTimeout() method of the window.location object can be used to get the
O
Window object schedules a function to run current page address (URL) and to redirect
after a specified number of milliseconds the browser to a new page.
SP
elapses. setTimeout() and setInterval() are
used for time manipulations in javascript. 10. What is the result of the following code
snippet?
7. Which method receives the return value of
window.location === document.location
G
setTimeout() to cancel future invocations?
a) clearTimeout()
b) clearInterval() a) False
LO
c) clearSchedule() b) True
d) cancelInvocation() c) 0
d) 1
Answer: a
Answer: b
.B
the parameter for the clearTimeout() method. The Document.location read-only property
returns a Location object, which contains
8. What will happen if we call setTimeout() information about the URL of the document
with a time of 0 ms? and provides methods for changing that URL
-R
M
a) 9 <h2>hello</h2>
b) 27
c) Error a) 0
b) hello
O
d) Undefined
c) h2
Answer: b d) 2
C
Explanation: The
document.getElementById() is used to get Answer: d
T.
value of the input text. But we need to define Explanation: The
id for the input field. document.getElementsByTagName() method
returns all the element of specified tag name.
12. What will be the output of the following The above code counts the total number of
O
JavaScript code? specific tags.
SP
function totalelements() 14. What will be the output of the following
{ JavaScript code?
var allgenders=document.getElementsBy
Name("gender"); function validate()
alert("Total Genders:"+allgenders.len {
G
gth); var msg;
} if(document.myForm.userPass.value.len
<form> gth>5)
LO
b) Error }
c) 2 <form name="myForm">
<input type="password" value="rhuld" onk
d) 1 eyup="validate()">
Strength:<span id="mylocation">no strengt
-R
Answer: c h</span>
Explanation: The </form>
document.getElementsByName() method
returns all the element of specified name. The a) Strength: good
SE
M
JavaScript code?
2. Which is the object on which the event
function showcommentform() occurred or with which the event is
O
{
var data=”new text”
associated?
document.getElementById('mylocation') a) event type
C
.innerHTML=data; b) event target
} c) both event type and even target
T.
<form name="myForm"> d) interface
<input type="button" value="comment" oncl
ick="showcommentform()">
<div id="mylocation"></div>
Answer: b
Explanation: The event target is the object
O
</form>
on which the event occurred or with which
a) Comment the event is associated. When we speak of an
SP
b) new text event, we must specify both the type and the
c) Error target. The target property of the Event
d) Undefined interface is a reference to the object that
dispatched the event.
G
Answer: a
Explanation: The innerHTML property can 3. In general, event handler is nothing but
be used to write the dynamic html on the html ____________
LO
d) Webpage loads
1. The type that specifies what kind of event
occurred is ____________ Answer: c
a) event type Explanation: When an event of the specified
b) even target type occurs on the specified target, the
C
c) both event type and even target browser invokes the handler. For example
d) interface onclick function is executed when mouse is
clicked.
M
d) Program Explanation: These are events that are
directly tied to a specific input device, such as
Answer: a the mouse or keyboard) They include legacy
O
Explanation: All event objects have a type event types such as “mousedown”,
property that specifies the event type. Event “mousemove”, “mouseup”, “keydown”,
C
type is a string that specifies what kind of “keypress”, and “keyup” and also new touch
event occurred. specific events like “touchmove” and
T.
“gesturechange”.
6. The process by which the browser decides
which objects to trigger event handlers on is 9. The high-level events among the following
____________ events are ____________
O
a) Event Triggering a) User interface events
b) Event Listening b) Device-independent events
SP
c) Event Handling c) Device-dependent events
d) Event propagation d) Stage event change
Answer: d Answer: a
G
Explanation: Event propagation is the Explanation: UI events are higher-level
process by which the browser decides which events, often on HTML form elements that
objects to trigger event handlers. Event define a user interface for a web application.
LO
propagation is a way to describe the “stack” They include the focus event (when a text
of events that are fired in a web browser. input field gains keyboard focus), the change
event when the user changes the value
7. Which form of event propagation handles displayed by a form element, and the submit
.B
the registered container elements? event when the user clicks a Submit button in
a) Event Propagation a form.
b) Event Registration
c) Event Capturing 10. The events that are not directly tied to a
17
element and then propagated to outer Explanation: These are input events that are
elements. With capturing, the event is first not directly tied to a specific input device.
captured by the outermost element and The click event, for example, indicates that a
propagated to the inner elements. link or button (or other document element)
has been activated) This is often done via a
C
8. The events that are directly tied to a mouse click, but it could also be done by
specific input device are ____________ keyboard or (on touch-sensitive devices) by
a) Device-independent input events gesture.
M
a) Tomcat server
b) Glassfish
1. The _______ specification defines an c) JBoss
O
application programming interface for d) None of the mentioned
communication between the server and the
C
application program Answer: d
a) Java Servlet Explanation: All of the mentioned
b) JDBC
T.
application servers provide built in support
c) Java Applet for servlets. Glassfish and Tomcat are the
d) Java Swing most prominently used application servers.
O
Answer: a 5. What is the full form of JSP?
Explanation: The java servlet specification a) Java servlet program
defines an application programming interface
SP
b) Java server pages
for communication between the server and c) Java server pages
the application program. The HttpServlet d) Java server program
class in Java implements the servlet API
specification. Answer: b
G
Explanation: The full form of JSP is Java
2. State true or false: Servlets are used to Server Pages. It is a scripting language that
LO
c) Shutting down the servlet code can modify the tree structure to carry out
d) Pausing the servlet for a given period of certain operations.
time.
7. Javascript is used to create dynamic
C
b) Thor Answer: b
c) Dynamo Explanation: Executing programs on the
d) Achilles client side is faster than executing programs
on the server which includes sending every
Answer: a interaction to the server.
M
Explanation: Javascript is used to create
dynamic webpages using technologies that
are collectively called Ajax. TOPIC 3.4 A SERVLET-
O
GENERATING DYNAMIC
8. What are scripting languages? CONTENT-LIFE CYCLE
C
a) The programming languages that pre
decide the web page content
1. The _______ specification defines an
T.
b) The programming languages that are
application programming interface for
simpler and offer same protection
communication between the server and the
c) The programming languages that trade off
application program
simplicity for protection.
O
a) Java Servlet
d) None of the mentioned
b) JDBC
c) Java Applet
SP
Answer: b
Explanation: Scripting languages are those d) Java Swing
languages that are simpler with enriched user
Answer: a
interface features but offer the same
Explanation: The java servlet specification
G
protection as that of Java.
defines an application programming interface
9. What are client side scripting languages? for communication between the server and
LO
b) False
Answer: a
Answer: a
Explanation: Client side scripting languages
Explanation: Servlets are used to generate
are those languages that are designed to be
-R
M
c) Dynamo
4. Which of the following application servers d) Achilles
do not provide built in support for servlets?
O
a) Tomcat server Answer: a
b) Glassfish Explanation: Javascript is used to create
C
c) JBoss dynamic webpages using technologies that
d) None of the mentioned are collectively called Ajax.
T.
Answer: d 8. What are scripting languages?
Explanation: All of the mentioned a) The programming languages that pre
application servers provide built in support decide the web page content
O
for servlets. Glassfish and Tomcat are the b) The programming languages that are
most prominently used application servers. simpler and offer same protection
SP
c) The programming languages that trade off
5. What is the full form of JSP? simplicity for protection.
a) Java servlet program d) None of the mentioned
b) Java server pages
G
c) Java server pages Answer: b
d) Java server program Explanation: Scripting languages are those
languages that are simpler with enriched user
LO
d) DON
Answer: a
Answer: c Explanation: Client side scripting languages
Explanation: While using Javascript, the
SE
a) True Answer: d
b) False Explanation: Cookies are stored at client
side. Hence, it is advantageous in some cases
Answer: b where clients disable cookies.
Explanation: Executing programs on the
M
client side is faster than executing programs 4. Which of the following leads to high
on the server which includes sending every network traffic?
interaction to the server. a) URL rewriting
O
b) Hidden form fields
c) SSL sessions
TOPIC 3.5 PARAMETER
C
d) Cookies
DATASESSIONS-COOKIES-URL
REWRITING-OTHER
T.
Answer: a
CAPABILITIES Explanation: WRL rewriting requires large
data transfer to and from the server which
leads to network traffic and access may be
O
1. Which of the following is used for session slow.
migration?
a) Persisting the session in database
SP
5. Which of the following is not true about
b) URL rewriting session?
c) Create new database connection a) All users connect to the same session
d) Kill session from multiple sessions b) All users have same session variable
G
c) Default timeout value for session variable
Answer: a is 20 minutes
Explanation: Session migration is done by d) New session cannot be created for a new
LO
c) Cookies a) True
d) SSL sessions b) False
Answer: b Answer: a
-R
a) 4 KB
3. Which of the following is stored at client b) 4 MB
side? c) 4 bytes
a) URL rewriting d) 40 KB
C
for the entire cookie, including name, value, Java MCQs | 1000 Java Programs | 1000 Java
expiry date etc. To support most browsers, it Algorithms | Best Java Books
is suggested to keep the name under 4000
bytes, and the overall cookie size under 4093
bytes.
TOPIC 3.6 DATA STORAGE
M
SERVLETS AND
8. How can we invalidate a session? CONCURRENCYDATABASES
a) session.discontinue()
O
AND JAVA SERVLETS.
b) session.invalidate()
c) session.disconnect()
C
d) session.falsify() 1. The Java __________ specification defines
an application programming interface for
communication between the Web server and
T.
Answer: b
Explanation: We can invalidate session by the application program.
calling session.invalidate() to destroy the a) Servlet
session. b) Server
O
c) Program
9. Which method creates unique fields in the d) Randomize
SP
HTML which are not shown to the user?
a) User authentication Answer: a
b) URL writing Explanation: Servlets are commonly used to
c) HTML Hidden field generate dynamic responses to HTTP
requests.
G
d) HTML invisible field
Explanation: HTML Hidden field is the extracts values of the parameter’s type and
simplest way to pass information but it is not number by using __________
secure and a session can be hacked easily. a) request.getParameter()
b) request.setParameter()
10. Which object is used by spring for c) responce.getParameter()
.B
authentication? d) responce.getAttribute()
a) ContextHolder
b) SecurityHolder Answer: a
17
JBDB.DriverManager.getConnection() is
| 1000 used to get the connection to the database.
4. Which JDBC driver Type(s) can be used in bridge is used to access ODBC drivers
either applet or servlet code? installed on each client machine.
a) Both Type 1 and Type 2
b) Both Type 1 and Type 3 8. What programming language(s) or
c) Both Type 3 and Type 4 scripting language(s) does Java Server Pages
M
d) Type 4 only (JSP) support?
a) VBScript only
Answer: c b) Jscript only
O
Explanation: In a Type 3 driver, a three-tier c) Java only
approach is used to accessing databases. The d) All of the mentioned
C
JDBC clients use standard network sockets to
communicate with an middleware application Answer: c
T.
server. In a Type 4 driver, a pure Java-based Explanation: JSP primarily uses Java for
driver that communicates directly with certain codes.
vendor’s database through socket connection.
9. What is bytecode?
O
5. What MySQL property is used to create a a) Machine-specific code
surrogate key in MySQL? b) Java code
SP
a) UNIQUE c) Machine-independent code
b) SEQUENCE d) None of the mentioned
c) AUTO_INCREMENT
d) None of the mentioned Answer: c
Explanation: Java bytecode is the form of
G
Answer: c instructions that the Java virtual machine
Explanation: A surrogate key in a database is executes. Each bytecode opcode is one byte
LO
a unique identifier for either an entity in the in length, although some require parameters,
modeled world or an object in the database. resulting in some multi-byte instructions.
a) Java applet
b) Java servlet b) In the MySQL database metasql
c) Either 1 or 2 above c) In the MySQL database mysql
d) Neither 1 nor 2 above d) None of the mentioned
17
Answer: b Answer: c
Explanation: Servlets are commonly used to Explanation: Metadata contains data about
generate dynamic responses to HTTP other data which is given in the <meta>…
-R
a) Type 1
b) Type 2 UNIT IV JSP AND XML
c) Type 3
d) Type 4
C
M
1. The Java __________ specification defines approach is used to accessing databases. The
an application programming interface for JDBC clients use standard network sockets to
communicate with an middleware application
O
communication between the Web server and
the application program. server. In a Type 4 driver, a pure Java-based
a) Servlet driver that communicates directly with
C
b) Server vendor’s database through socket connection.
c) Program
T.
d) Randomize 5. What MySQL property is used to create a
surrogate key in MySQL?
Answer: a a) UNIQUE
Explanation: Servlets are commonly used to b) SEQUENCE
O
generate dynamic responses to HTTP c) AUTO_INCREMENT
requests. d) None of the mentioned
SP
2. The doGet() method in the example Answer: c
extracts values of the parameter’s type and Explanation: A surrogate key in a database is
number by using __________ a unique identifier for either an entity in the
G
a) request.getParameter() modeled world or an object in the database.
b) request.setParameter()
c) responce.getParameter() 6. A JSP is transformed into a(n):
LO
a) One requests.
b) Two
c) Three 7. Which JDBC driver Type(s) is(are) the
d) Four JDBC-ODBC bridge?
-R
a) Type 1
Answer: d b) Type 2
Explanation: c) Type 3
d) Type 4
SE
JBDB.DriverManager.getConnection() is
used to get the connection to the database.
Answer: a
4. Which JDBC driver Type(s) can be used in Explanation: In a Type 1 driver, a JDBC
either applet or servlet code? bridge is used to access ODBC drivers
C
M
c) Java only 2. The doGet() method in the example
d) All of the mentioned extracts values of the parameter’s type and
number by using __________
O
Answer: c a) request.getParameter()
Explanation: JSP primarily uses Java for b) request.setParameter()
C
certain codes. c) responce.getParameter()
d) responce.getAttribute()
T.
9. What is bytecode?
a) Machine-specific code Answer: a
b) Java code Explanation: These methods uses these
c) Machine-independent code values to run a query against a database.
O
d) None of the mentioned
3. How many JDBC driver types does Sun
SP
Answer: c define?
Explanation: Java bytecode is the form of a) One
instructions that the Java virtual machine b) Two
executes. Each bytecode opcode is one byte c) Three
G
in length, although some require parameters, d) Four
resulting in some multi-byte instructions.
Answer: d
LO
other data which is given in the <meta>… c) Both Type 3 and Type 4
</meta> tags. d) Type 4 only
Answer: c
TOPIC 4.2 RUNNING JSP
-R
M
Explanation: A surrogate key in a database is instructions that the Java virtual machine
a unique identifier for either an entity in the executes. Each bytecode opcode is one byte
modeled world or an object in the database. in length, although some require parameters,
O
resulting in some multi-byte instructions.
6. A JSP is transformed into a(n):
C
a) Java applet 10. Where is metadata stored in MySQL?
b) Java servlet a) In the MySQL database metadata
T.
c) Either 1 or 2 above b) In the MySQL database metasql
d) Neither 1 nor 2 above c) In the MySQL database mysql
d) None of the mentioned
Answer: b
O
Explanation: Servlets are commonly used to Answer: c
generate dynamic responses to HTTP Explanation: Metadata contains data about
SP
requests. other data which is given in the <meta>…
</meta> tags.
7. Which JDBC driver Type(s) is(are) the
JDBC-ODBC bridge?
a) Type 1 TOPIC 4.3 BASIC JSP
G
b) Type 2 JAVABEANS CLASSES AND JSP-
c) Type 3 TAG LIBRARIES AND FILES
LO
d) Type 4
1. Which page directive should be used in
Answer: a
JSP to generate a PDF page?
Explanation: In a Type 1 driver, a JDBC
a) contentType
bridge is used to access ODBC drivers
.B
b) generatePdf
installed on each client machine.
c) typePDF
8. What programming language(s) or d) contentPDF
17
c) Java only
d) All of the mentioned 2. Which tag should be used to pass
information from JSP to included JSP?
Answer: c
SE
a) Machine-specific code
Answer: a
b) Java code
Explanation: <%jsp:param> tag is used to
pass information from JSP to included JSP.
M
Execution
Answer: d
Explanation: Application object is wrapper Answer: c
O
around the ServletContext object and it is an Explanation: The correct order is
instance of a javax.servlet.ServletContext Compilation, Initialization, Execution,
C
object. Cleanup.
T.
4. _jspService() method of HttpJspPage class 8. “request” is instance of which one of the
should not be overridden. following classes?
a) True a) Request
b) False b) HttpRequest
O
c) HttpServletRequest
Answer: a d) ServletRequest
SP
Explanation: _jspService() method is created
by JSP container. Hence, it should not be Answer: c
overridden. Explanation: request is object of
HttpServletRequest.
5. Which option is true about session scope?
G
a) Objects are accessible only from the page 9. Which is not a directive?
in which they are created a) include
LO
a) true d) type,id
b) false
Answer: a
Answer: a Explanation: The useBean searches existing
SE
Explanation: Default value “true” depicts object and if not found creates an object using
automatic buffer flushing. class.
7. Which one is the correct order of phases in | 1000 Java MCQs | 1000 Java Programs |
C
M
the model-view- controller architecture? involving a single participant is handled
a) The model corresponds to the business c) They describe how a particular task
O
logic layer involving multiple participants is handled.
b) The view defines the presentation of data d) None of the mentioned
c) The controller receives events, executes
C
actions on the model and returns a view Answer: c
d) All of the mentioned Explanation: Business logic includes
T.
workflows. Workflows in a business logic
Answer: d layer describe how a particular task involving
Explanation: In the model-view-controller multiple participants is handled.
architecture, the model corresponds to the
O
business logic layer, the view defines the way 5. State true or false: The code implementing
data is presented and the controller receives the actions in the business logic layer ensures
SP
events, executes actions on the model and that business rules are followed
returns a view. a) True
b) False
2. The ___________ provides a high level
G
view of data and actions on data Answer: a
a) Business-logic layer Explanation: The code implementing the
b) Data access layer actions in the business logic layer ensures that
LO
and the underlying database. The data access c) Auto generation of code for the user
layer provides the mapping from the object interface from a declarative specification
oriented data model to the relational model. d) All of the mentioned
Answer: d Answer: d
Explanation: The main features of Rapid Explanation: To reduce overhead, any of the
Application development are to provide a following methods can be used. Connection
library of functions for GUI development, to pooling, Parallel processing or caching query
provide drag and drop features in an IDE, results at the server. Caching query results at
M
Auto-generation of code for the user interface the server enables to reduce the number of
from a declarative specification. database accesses every time a similar request
O
is sent.
8. Which of the following is not a web
application development framework feature?
TOPIC 4.5 DATABASES AND JSP.
C
a) An object oriented model
b) A declarative way of specifying a form
T.
with validation constraints 1. The Java __________ specification defines
c) Creating mass servers for effective an application programming interface for
handling of data communication between the Web server and
d) A template scripting system the application program.
O
a) Servlet
Answer: c b) Server
SP
Explanation: Creating mass servers for c) Program
effective handling of data is not a part of the d) Randomize
web application development framework
feature. Answer: a
G
Explanation: Servlets are commonly used to
9. What are report generators? generate dynamic responses to HTTP
a) They are the tools to generate human requests.
LO
Answer: a
Explanation: Report generators are the tools Answer: a
to generate human readable reports from a Explanation: These methods uses these
database. They integrate querying the values to run a query against a database.
-R
JBDB.DriverManager.getConnection() is Answer: a
used to get the connection to the database. Explanation: In a Type 1 driver, a JDBC
bridge is used to access ODBC drivers
4. Which JDBC driver Type(s) can be used in installed on each client machine.
either applet or servlet code?
M
a) Both Type 1 and Type 2 8. What programming language(s) or
b) Both Type 1 and Type 3 scripting language(s) does Java Server Pages
c) Both Type 3 and Type 4 (JSP) support?
O
d) Type 4 only a) VBScript only
b) Jscript only
C
Answer: c c) Java only
Explanation: In a Type 3 driver, a three-tier d) All of the mentioned
T.
approach is used to accessing databases. The
JDBC clients use standard network sockets to Answer: c
communicate with an middleware application Explanation: JSP primarily uses Java for
server. In a Type 4 driver, a pure Java-based certain codes.
O
driver that communicates directly with
vendor’s database through socket connection. 9. What is bytecode?
SP
a) Machine-specific code
5. What MySQL property is used to create a b) Java code
surrogate key in MySQL? c) Machine-independent code
a) UNIQUE d) None of the mentioned
G
b) SEQUENCE
c) AUTO_INCREMENT Answer: c
d) None of the mentioned Explanation: Java bytecode is the form of
LO
M
TOPIC 4.8 EVENT-ORIENTED jQuery.parseJSON(). jQuery.getJSON()
PARSING: SAX- uses this type. If the type is “json” and the
TRANSFORMING XML
O
URL or data string contains “=?”, the type is
DOCUMENTS converted to “jsonp”.
C
4. What is the parameter of the method
1. What is the function of the XML parser? Date.parse()?
a) Converts XML document to XML DOM
T.
a) date
object b) string
b) Converts XML DOM object to XML c) datestring
document d) string
O
c) Converts XML DOM object to a comment
d) Compiles the html document Answer: c
SP
Explanation: The parse method is defined as
Answer: a Date.parse(datestring). The parse() method
Explanation: An XML parser converts an parses a date string and returns the number of
XML document into an XML DOM object – milliseconds between the date string.
which can then be manipulated with
G
JavaScript. All major browsers have a built-in 5. Which is the function in JavaScript that
XML parser to access and manipulate XML. will print the current page in JavaScript?
LO
a) print()
2. What is the purpose of the method b) printcurrent()
ActiveXObject()? c) print(now)
a) Used to call automation object d) print(this)
b) Used to reference automation object
.B
with instances of the ActiveXObject object 6. To which of the following object does the
like any predefined property or method. The print() method belong to?
ActiveXObject() object is used only to a) window
instantiate Automation objects, and has no
SE
b) document
members. c) hash
d) string
3. What is the purpose of the url json?
a) Belongs to JSON object Answer: a
C
the Print Dialog Box, which lets the user to value will be 16. If the string begins with “0”,
select preferred printing options. the radix is 8 (octal).
7. What will happen if the radix parameter of 10. What does it indicate when the radix
the parseInt() function is omitted? value is 16?
M
a) Runs in assumption a) String begins with 0x
b) Throws exception b) String begins with 0
c) Aborts c) String begins with 0P
O
d) Taken as 0 d) String begins with FF
C
Answer: a Answer: a
Explanation: The print() method opens the Explanation: If the string begins with “0x”,
T.
Print Dialog Box, which lets the user to select the radix is 16 (hexadecimal). If the string
preferred printing options. begins with “0”, the radix is 8 (octal).
If the string begins with “0x”, the radix 11. What will be the output of the following
O
is 16 (hexadecimal) JavaScript code?
If the string begins with “0”, the radix
SP
is 8 (octal). This feature is deprecated <p id="demo"></p>
<script>
If the string begins with any other
var str = "HELLO, LOOK AT YOU!";
value, the radix is 10 (decimal) var patt1 = /\BLO/;
var result = str.search(patt1);
8. What will be the radix value if the string
G
document.getElementById("demo").innerHTML
begins with 0x? = result;
a) 13 </script>
LO
b) 14
c) 15 a) 4
d) 16 b) 7
c) 3
Answer: d d) 1
.B
string begins with any other value, the radix find a match, but where it is NOT at the
is 10 (decimal). beginning/end of a word. It is found in the
regex library.
9. What is the function of the parseInt()
-R
<script>
d) Parses a string and return an object function myFunction()
{
Answer: b var str = "welcome to.\0JavaScript tes
t.";
Explanation: The function parseInt()
C
} }
</script> </script>
a) 12 a) 6
b) 13 b) 5
M
c) 10 c) 3
d) 11 d) -1
O
Answer: d Answer: a
Explanation: The \0 metacharacter is used to Explanation: The \r metacharacter is used to
find NUL character. \0 returns the position find a carriage return character. \r returns the
C
where the NUL character was found. If no position where the carriage return character
match is found, it returns -1. was found. If no match is found, it returns -1.
T.
13. What will be the output of the following 15. What will be the output of the following
JavaScript code? JavaScript code?
O
<p id="demo"></p> <p id="demo"></p>
<script> <script>
SP
function myFunction() function myFunction()
{ {
var str = "hello\f world."; var str = "hello to \r world.";
var patt1 = /\f/; var patt1 = /\t/;
var result = str.search(patt1); var result = str.search(patt1);
G
document.getElementById("demo").innerH document.getElementById("demo").innerH
TML = result; TML = result;
} }
LO
</script> </script>
a) 6 a) 6
b) 5 b) 8
c) 8 c) 9
.B
d) -1 d) -1
Answer: b Answer: c
17
<p id="demo"></p>
<script>
UNIT V AJAX AND WEB
function myFunction() SERVICES
{
var str = "hello \r world.";
C
M
requests? d) Comet
a) request
b) location Answer: d
O
c) send Explanation: Comet is the reverse of Ajax: in
d) write Comet, it is the web server that initiates the
C
communication, asynchronously sending
Answer: b messages to the client. The big advantage of
Explanation: It is possible for JavaScript
T.
Comet is that each client always has a
code to script HTTP, however. HTTP requests communication link open to the server.
are initiated when a script sets the location
property of a window object or calls the 5. The other name for Comet is
O
submit() method of a form object. The _____________
location object is part of the window object a) Server Push
SP
and is accessed through the window.location b) Ajax Push
property. c) HTTP Streaming
d) All of the mentioned
2. Which method is an alternative of the
property location of a window object?
G
Answer: d
a) submit() Explanation: Comet is a web application
b) locate() model where a request is sent to the server
LO
when a script sets the location property of a 6. Which is the element that has a src
window object or calls the submit() method property to initiate HTTP GET request?
of a form object. In both cases, the browser a) img
17
a) XML Answer: d
b) HTML Explanation: Both img and script contains
c) Ajax the src property that can be set to initiate an
d) CSS
SE
Answer: c Answer: c
Explanation: XMLHttpRequest is both an Explanation: The code that begins a HTTP
M
object and a class. The XMLHttpRequest GET request for the contents of the specified
object can be used to request data from a web URL is
server.
O
request.open("GET","data.csv");
8. Which of the following are the features of
To send a request to a server open() and
C
an HTTP request?
send() methods of the XMLHttpRequest
a) URL being requested
object are used.
T.
b) Optional request body
c) Optional set of request headers
d) All of the mentioned TOPIC 5.2 WEB SERVICES:
JAX-RPC-CONCEPTS-WRITING
O
Answer: d
Explanation: An HTTP request consists of A JAVA WEB SERVICE-
WRITING A JAVA WEB
SP
four parts :
SERVICE CLIENT
1. the HTTP request method or “verb”
2. the URL being requested
1. A web service contract is described using :-
3. an optional set of request headers,
G
a) Web Services Description Language
which may include authentication
b) Web Services Description
information
LO
3. In contrast, the contract-first approach SOAP web service. We will use Apache CXF,
encourages you to think of the service which is the de facto successor to XFire.
contract first in terms of :-
a) XML 7. The standard for deploying web services on
b) XML Schema(.xsd) the Java EE platform as of Java EE 1.4:-
M
c) WSDL a) JAX-RPC
d) All of the mentioned b) JAX
c) RPC
O
Answer: d d) None of the mentioned
Explanation: In contrast, the contract-first
C
approach encourages you to think of the Answer: a
service contract first, in terms of XML, using Explanation: The standard for deploying web
T.
XML schema (.xsd) and WSDL. services on the Java EE platform as of Java
EE 1.4 was called JAX-RPC. It supported
4. In some cases, it’s also hard to map an SOAP 1.0 and 1.1, but didn’t support
object to XML (e.g., an object graph with message-oriented web services.
O
cyclic references) because there’s actually an
impedance mismatch between an object 8. To send objects across the wire, beans need
SP
model and an XML model. to be encoded using the Java Architecture for
a) True XML Binding (JAXB).
b) False a) True
b) False
G
Answer: a
Explanation: Just like that between an object Answer: a
model and a relational model. Explanation: JAXB supports many class
LO
b) Hessian
c) Burlap a) javax.jws.WebService
d) All of the mentioned b) javax.jws.WebServiceProvider
c) all of the mentioned
17
Burlap, or HTTP Invoker remoting EE 5 (or better) container, you may simply
technologies. create a bean that is annotated with
javax.jws.WebService or
6. Spring comes with a service exporter that javax.jws.WebServiceProvider and deploy
SE
can export a bean as a SOAP web service. that into a container in your web application.
a) True
b) False 10. If you are using the JAX-RS Reference
Implementation, this intermediary step will
C
M
useful SOAP support.
11. Spring provides a factory that can export a) True
beans annotated with:- b) False
O
a) javax.jws.WebService
b) javax.jws.WebServiceProvider Answer: a
C
c) all of the mentioned Explanation: For our example, we’ll embed
d) none of the mentioned CXF since it’s robust, fairly well tested, and
T.
provides support for other important
Answer: c standards like JAX-RS, the API for REST-ful
Explanation: Spring provides a factory that endpoints.
can export beans annotated with
O
javax.jws.WebService or 15. Factory to use our Spring bean as the
javax.jws.WebServiceProvider inside the implementation:-
SP
Spring context and then publishes the services a) jaxws:end
using the JAX-WS runtime. b) jaxws:endpoint
c) all of the mentioned
12. Exposing a stand-alone SOAP endpoint d) none of the mentioned
G
using the:-
a) SimpleJaxWsServiceExporter Answer: b
b) JAX-WS Explanation: We tell the jaxws:endpoint
LO
conjunction with Spring is simple, but these 1. A web service contract is described using :-
solutions ignore the largest cross-section of a) Web Services Description Language
developers—people developing on Tomcat. b) Web Services Description
c) All of the mentioned
-R
embedding a JAX-WS runtime. There are 2. There are two approaches to developing a
many choices, and you’re free to take your web service, depending on whether you
define the contract first or last.
M
described using Web Services Description 6. Spring comes with a service exporter that
Language (WSDL). In contract-last, you can export a bean as a SOAP web service.
expose an existing service interface as a web a) True
O
service whose service contract is generated b) False
automatically. In contract-first, you design the
C
service contract in terms of XML and then Answer: b
write code to fulfill it. Explanation: Spring doesn’t come with a
T.
service exporter that can export a bean as a
3. In contrast, the contract-first approach SOAP web service. We will use Apache CXF,
encourages you to think of the service which is the de facto successor to XFire.
contract first in terms of :-
O
a) XML 7. The standard for deploying web services on
b) XML Schema(.xsd) the Java EE platform as of Java EE 1.4:-
SP
c) WSDL a) JAX-RPC
d) All of the mentioned b) JAX
c) RPC
Answer: d d) None of the mentioned
G
Explanation: In contrast, the contract-first
approach encourages you to think of the Answer: a
service contract first, in terms of XML, using Explanation: The standard for deploying web
LO
XML schema (.xsd) and WSDL. services on the Java EE platform as of Java
EE 1.4 was called JAX-RPC. It supported
4. In some cases, it’s also hard to map an SOAP 1.0 and 1.1, but didn’t support
object to XML (e.g., an object graph with message-oriented web services.
.B
b) False a) True
b) False
Answer: a
Explanation: Just like that between an object Answer: a
-R
M
javax.jws.WebServiceProvider and deploy a) True
that into a container in your web application. b) False
O
10. If you are using the JAX-RS Reference Answer: a
Implementation, this intermediary step will Explanation: Tomcat doesn’t support JAX-
C
involve a tool called wsgen. WS by itself, so we need to help it by
a) True embedding a JAX-WS runtime. There are
T.
b) False many choices, and you’re free to take your
pick. Two popular choices are Axis2 and
Answer: a CXF, both of which are Apache projects.
Explanation: It will generate the
O
configuration (a file called sun-jaxws.xml) 14. CXF represents the consolidation of the
and wrapper beans required to expose your Celtix and XFire projects, which each had
SP
service. useful SOAP support.
a) True
11. Spring provides a factory that can export b) False
beans annotated with:-
Answer: a
G
a) javax.jws.WebService
b) javax.jws.WebServiceProvider Explanation: For our example, we’ll embed
c) all of the mentioned CXF since it’s robust, fairly well tested, and
LO
Answer: c
Explanation: Exposing a stand-alone SOAP
TOPIC 5.4 REPRESENTING
endpoint using the DATA TYPES: XML SCHEMA
C
M
5. XML View Technology is useful in the
Answer: d following situations?
Explanation: XML is a good choice if you a) Your application needs system catalog
O
want a platform-independent model in order views to administer your XML data and XML
to ensure the portability of the data by using schema
C
structural and semantic markup. b) Indexing Capabilities
c) You want to bulk load XML data and
T.
2. Which of the following is not a XML decompose them into the underlying tables by
storage option? using the XML view
a) Native storage as XML data type d) None of the Mentioned
b) Mapping between XML and relational
O
storage Answer: c
c) Small object storage Explanation: XML bulk load can be used to
SP
d) None of the Mentioned populate the underlying tables by using the
XML view.
Answer: c
Explanation: XML uses large object storage 6. What is the hybrid model in SQL Server?
G
which uses varchar(max) and varbinary(max). a) Combination of relational and XML data
type columns
3. The choice of XML technology, native b) Combination of relational and non
LO
XML versus XML view, generally depends relational data type columns
upon the following factors? c) Using XML with views
a) Storage options d) Using XML with triggers
b) Query capabilities
.B
c) Indexing Answer: a
d) All of the Mentioned Explanation: Hybrid model may yield better
performance in that you have more control
Answer: d over the indexes created on the relational
17
4. In which of the following scenario, using data in the file system would be:
XML native storage would be inappropriate? a) You need language support for query and
a) Fixed schema data modification for cross-domain
b) You want to query and modify your XML
SE
applications
data b) You want the server to guarantee that the
c) You want to index the XML data for faster data is well formed and also optionally
query processing validate your data according to XML schema
d) Your application needs system catalog c) You want indexing of XML data for
C
views to administer your XML data and XML efficient query processing and good
schema scalability, and the use of a first-rate query
Answer: d
Explanation: If none of these conditions is TOPIC 5.5 COMMUNICATING
M
satisfied, it may be better to store your data as OBJECT DATA: SOAP -
a non-XML, large object type, such as RELATED TECHNOLOGIES-
varchar(max) or varbinary(max).
O
SOFTWARE INSTALLATION
8. Which of the following part of the XML
C
data stored in an XML column is very 1. A web service contract is described using :-
important for locking? a) Web Services Description Language
b) Web Services Description
T.
a) Granularity
b) Degree of Structure c) All of the mentioned
c) Hierarchy d) None of the mentioned
d) None of the mentioned
O
Answer: a
Answer: a Explanation: In contract-last, you expose an
existing service interface as a web service
SP
Explanation: When the granularity is large,
locking large XML instances for updates whose service contract is generated
causes throughput to decline in a multi user automatically.
scenario.
2. There are two approaches to developing a
G
9. XML datatype was introduced in which of web service, depending on whether you
the following versions of SQL Server? define the contract first or last.
LO
specifically hold xml data, whether it be an service whose service contract is generated
entire XML document or just some XML automatically. In contract-first, you design the
content. service contract in terms of XML and then
write code to fulfill it.
-R
Answer: a
Explanation: You need to create a stored Answer: d
Explanation: In contrast, the contract-first
approach encourages you to think of the
M
cyclic references) because there’s actually an message-oriented web services.
impedance mismatch between an object
model and an XML model. 8. To send objects across the wire, beans need
O
a) True to be encoded using the Java Architecture for
b) False XML Binding (JAXB).
C
a) True
Answer: a b) False
T.
Explanation: Just like that between an object
model and a relational model. Answer: a
Explanation: JAXB supports many class
5. Service exporters that can export a bean as types out of the box with no special support.
O
a remote service based on the :-
a) RMI 9. If you are deploying into a Java EE 5 (or
SP
b) Hessian better) container, you may simply create a
c) Burlap bean that is annotated with:-
d) All of the mentioned a) javax.jws.WebService
b) javax.jws.WebServiceProvider
Answer: d
G
c) all of the mentioned
Explanation: Spring comes with several d) none of the mentioned
service exporters that can export a bean as a
LO
javax.jws.WebService or
can export a bean as a SOAP web service. javax.jws.WebServiceProvider and deploy
a) True that into a container in your web application.
b) False
17
d) None of the mentioned 11. Spring provides a factory that can export
beans annotated with:-
a) javax.jws.WebService
b) javax.jws.WebServiceProvider Answer: a
c) all of the mentioned Explanation: For our example, we’ll embed
d) none of the mentioned CXF since it’s robust, fairly well tested, and
provides support for other important
Answer: c standards like JAX-RS, the API for REST-ful
M
Explanation: Spring provides a factory that endpoints.
can export beans annotated with
javax.jws.WebService or 15. Factory to use our Spring bean as the
O
javax.jws.WebServiceProvider inside the implementation:-
Spring context and then publishes the services a) jaxws:end
C
using the JAX-WS runtime. b) jaxws:endpoint
c) all of the mentioned
T.
12. Exposing a stand-alone SOAP endpoint d) none of the mentioned
using the:-
a) SimpleJaxWsServiceExporter Answer: b
b) JAX-WS Explanation: We tell the jaxws:endpoint
O
c) All of the mentioned factory to use our Spring bean as the
d) None of the mentioned implementation. We tell it at what address to
SP
publish the service using the address element.
Answer: c
Explanation: Exposing a stand-alone SOAP
endpoint using the TOPIC 5.6 STORING JAVA
OBJECTS AS FILES.
G
SimpleJaxWsServiceExporter or the support
for JAX-WS in a Java EE container in
conjunction with Spring is simple, but these 1. Which of these is a process of writing the
LO
many choices, and you’re free to take your 2. Which of these process occur automatically
pick. Two popular choices are Axis2 and by the java runtime system?
CXF, both of which are Apache projects. a) Serialization
SE
b) Garbage collection
14. CXF represents the consolidation of the c) File Filtering
Celtix and XFire projects, which each had d) All of the mentioned
useful SOAP support.
a) True Answer: a
C
occur automatically but is done by CPU or an object into invoking stream, it can be input
the operating system not by the java runtime stream or output stream.
system.
7. What will be the output of the following
3. Which of these is an interface for control Java program?
M
over serialization and deserialization?
a) Serializable 1. import java.io.*;
b) Externalization
O
c) FileFilter 2. class serialization
d) ObjectInput 3. {
C
Answer: b 4. public static void main(Str
T.
Explanation: None. ing[] args)
O
6. try
a) Serializable
b) Externalization 7. {
SP
c) ObjectOutput
d) ObjectInput 8. Myclass object1 = n
ew Myclass("Hello", -7, 2.1e10);
Answer: c
Explanation: ObjectOutput interface extends 9. FileOutputStream fo
G
s = new FileOutputStream("serial");
the DataOutput interface and supports object
serialization. 10. ObjectOutputStream
LO
12. oos.flush();
b) flush()
c) fflush() 13. oos.close();
d) close()
17
14. }
Answer: b
Explanation: None. 15. catch(Exception e)
16.
-R
{
6. Which of these is method of ObjectOutput
interface used to write the object to input or 17. System.out.println(
output stream as required? "Serialization" + e);
a) write()
SE
20. try
C
Answer: d
Explanation: writeObject() is used to write 21. {
M
25. object2 = (Myclass) d) Serialization
ois.readObject();
Answer: a
O
26. ois.close(); Explanation: None.
Output:
27.
C
System.out.println(
object2); $ javac serialization.java
$ java serialization
T.
28. } s=Hello; i=-7; d=2.1E10
O
30. {
SP
eserialization" + e);
2. class serialization
32. System.exit(0);
3. {
33. }
G
4. public static void main(Str
34. } ing[] args)
LO
35. } 5. {
37. {
8. Myclass object1 = n
38. String s; ew Myclass("Hello", -7, 2.1e10);
17
43. this.d = d;
12. oos.flush();
44. this.i = i;
13. oos.close();
14. }
C
45. this.s = s;
46. }
15. catch(Exception e)
16. {
M
19. } 43. this.d = d;
O
21. { 45. this.s = s;
22. 46.
C
int x; }
T.
= new FileInputStream("serial");
a) -7
24. ObjectInputStream o b) Hello
is = new ObjectInputStream(fis);
O
c) 2.1E10
25. x = ois.readInt(); d) deserialization
SP
26. ois.close(); Answer: d
Explanation: x = ois.readInt(); will try to
27. System.out.println( read an integer value from the stream ‘serial’
x); created before, since stream contains an
G
28. } object of Myclass hence error will occur and
it will be catched by catch printing
29. deserialization.
LO
catch (Exception e)
Output:
30. {
$ javac serialization.java
31. System.out.print("d $ java serialization
eserialization"); deserialization
.B
}
1. import java.io.*;
34. }
2. class Chararrayinput
35. }
-R
3. {
36. class Myclass implements Serial
izable 4. public static void main(Str
ing[] args)
SE
37. {
5. {
38. String s;
6. String obj = "abcdefg
39. int i;
h";
C
M
10. CharArrayReader input1 the screen.
= new CharArrayReader(c); Output:
O
11. CharArrayReader input2 $ javac Chararrayinput.java
= new CharArrayReader(c, 1, 4); $ java Chararrayinput
C
12. int i; 10. What will be the output of the following
Java program?
T.
13. int j;
1. import java.io.*;
14. try
2.
O
class streams
15. {
3. {
16. while ((i = input1.
SP
read()) == (j = input2.read())) 4. public static void main(Str
ing[] args)
17. {
5. {
18. System.out.prin
G
t((char)i); 6. try
19.
LO
}
7. {
20. }
8. FileOutputStream fo
s = new FileOutputStream("serial");
21. catch (IOException e)
.B
9. ObjectOutputStream
22. {
oos = new ObjectOutputStream(fos);
23. e.printStackTrace() 10. oos.writeFloat(3.5)
17
; ;
24. } 11. oos.flush();
25. } 12. oos.close();
-R
26. } 13. }
b) abcd
c) abcde 15. {
d) None of the mentioned
16. System.out.println(
"Serialization" + e);
Answer: d
C
20. { 33. }
M
22. FileInputStream fis a) 3
= new FileInputStream("serial"); b) 3.5
O
23. ObjectInputStream o
c) serialization
is = new ObjectInputStream(fis); d) deserialization
C
24. x = ois.readInt(); Answer: b
Explanation: oos.writeFloat(3.5); writes in
T.
25. ois.close(); output stream which is extracted by x =
ois.readInt(); and stored in x hence x contains
26. System.out.println(
x);
3.5.
O
Output:
27. }
$ javac streams.java
SP
28. catch (Exception e) $ java streams
3.5
29. {
30. System.out.print("d
G
eserialization");
31.
LO
System.exit(0);
.B
17
-R
SE
C