You are on page 1of 5

Answer Key

Internet Technologies Q.Paper 2019


Section-A
Q1. (a) Describe Auto-boxing and Auto-unboxing in java. 1.5+1.5

Auto-Boxing: The automatic conversion of primitive data types into its


equivalent Wrapper type is known as auto-boxing.
No need of conversion between primitives and Wrappers manually so less
coding is required.
Example: Integer a2=new Integer(a); //Boxing
Integer a3=5;//Auto-Boxing

Auto-unboxing: The automatic conversion of wrapper class type into


corresponding primitive type, is known as auto-unboxing.
Example: Integer i=new Integer(50);
int a=i;

(b) What would be the output of: 1+1+1

(i) parseFloat(“xy2.57”) gives NaN


(ii) document.writeln(1+2+"3") gives 33
(iii) fn:contains('test String','TEST') gives false

(c) Write a Javascript code to display the information about the Operating 3
System and browser being used by the client.

<html>
<head>
<title>Browser and OS information</title>
<script language="Javascript">
document.writeln(“Operating system=”+navigator.appName);
document.writeln( “Browser = "+navigator.appVersion);
</script>
</head>
<body>
</body>
</html>

(d) What is the significance of Introspector and Event Set Descriptor classes 3
in Java Bean API?

The Introspector is a utility for developers to figure out which properties, events, and
methods a JavaBean supports. The java.beans.Introspector class walks over the
class/superclass chain of the target bean class. At each level it checks if there is a
matching BeanInfo class which provides explicit information about the bean, and if
so uses that explicit information. Otherwise, it uses the low level reflection APIs to
study the target class and uses design patterns to analyze its behaviour and then
proceeds to continue the introspection with its base class.
The Introspector.getBeanInfo(...) method is used to get a BeanInfo object for the
given Bean class to discover all its features i.e properties, methods and events using
the appropriate getter methods.

An EventSetDescriptor describes a group of events that a given Java bean fires. An


EventSetDescriptor object is a type of FeatureDescriptor that describes a single set of
events supported by a JavaBeans component. A set of events corresponds to one or
more methods supported by a single EventListener interface. The BeanInfo class for
a bean optionally creates EventSetDescriptor objects to describe the event sets the
bean supports.
BeanInfo defines the method getEventSetDescriptors() that return descriptors for
each event that you want exposed. Here's the prototype for these methods:

EventSetDescriptor[] getEventSetDescriptors();
This method returns an array of event set descriptors for each set of events.

(e) List the types of driver available in JDBC and explain when are they used. 4

There are 4 types of JDBC drivers:


1. JDBC-ODBC bridge driver - The JDBC-ODBC bridge driver uses ODBC
driver to connect to the database. The JDBC-ODBC bridge driver converts
JDBC method calls into ODBC function calls. It is easy and can be used to
connect to any kind of database. Performance degraded because JDBC
method call is converted into the ODBC function calls. The ODBC driver
needs to be installed on the client machine.

2. Native-API driver (partially java driver) - The Native API driver uses the
client-side libraries of the database. The driver converts JDBC method calls
into native calls of the database API. It is not written entirely in java. The
Native driver needs to be installed on each client machine. The Vendor client
library needs to be installed on client machine.
3. Network Protocol driver (fully java driver) - The Network Protocol driver
uses middleware (application server) that converts JDBC calls directly or
indirectly into the vendor-specific database protocol. It is fully written in
java. Its advantage is that no client side library is required because of
middleware/application server that can perform many tasks like auditing, load
balancing, logging etc.
4. Thin driver (fully java driver) - The thin driver converts JDBC calls
directly into the vendor-specific database protocol. That is why it is known as
thin driver. It is fully written in Java language. It has better performance than
all other drivers and no software is required at client side or server side.

(f) (i) next() will move the result set cursor to the first record i.e. ABC 100 4
(ii) relative(2) will move the result set cursor two steps forward and will
bring to the third record i.e. DEF 102
(iii) previous() will now move the result set cursor one step backward and
will refer to the second record i.e. PQR 101
(iv) relative(-2) will attempt to move the result set cursor two steps
backward however as the cursor is on the second record, Exception will
occur as the cursor cannot move two steps in backward direction.
Exception occurred java.sql.SQLException: Before start of result set

(g) What are directives? List and explain the usage of different types of 5
directives available in JSP.

Directive elements are used to specify information about the page itself, especially
information that doesn't differ between requests for the page. A JSP directive affects
the overall structure of the servlet class.
Syntax: <%@ directive attribute = "value" %>

There are three types of directives:


1. Page directive- This directive can only be used in JSP pages. It defines page
dependent attributes, such as scripting language, error page, and buffering
requirements.
Syntax/Example: <%@ page language="java|language "%>
Some other attributes are: isErrorPage, autoFlush, contentType, errorPage,
import etc.
2. Include directive - Includes a static file, merging its content with the
including page before the combined result is converted to a JSP page
implementation class.
Syntax: <%@ include file="pageOrContextRelativePath" %>
3. Taglib directive - The taglib directive declares that your JSP page uses a set
of custom tags, identifies the location of the library, and provides means for
identifying the custom tags in your JSP page.
Syntax: <%@ taglib uri="uri" prefix = "prefixOfTag" >
The uri attribute value resolves to a location the container understands and
the prefix attribute informs a container what bits of markup are custom
actions.

(h) Explain Math object with its five objects and five properties. 2.5 +2.5

The Math object is used to perform mathematical functions.All properties/methods of


Math can be called by using Math as an object, without creating it.
Math object properties (any five):
● E Returns Euler's number (approx. 2.718)
● LN2 Returns the natural logarithm of 2 (approx. 0.693)
● LN10 Returns the natural logarithm of 10 (approx. 2.302)
● LOG2E Returns the base2 logarithm of E (approx. 1.442)
● LOG10E Returns the base10 logarithm of E (approx. 0.434)
● PI Returns PI (approx. 3.14)
● SQRT1_2 Returns the square root of 1/2 (approx. 0.707)
● SQRT2 Returns the square root of 2 (approx. 1.414)
Math object methods (any five):
● abs(x) Returns the absolute value of x
● acos(x) Returns the arccosine of x, in radians
● acosh(x) Returns the hyperbolic arccosine of x
● asin(x) Returns the arcsine of x, in radians
● asinh(x) Returns the hyperbolic arcsine of x
● atan(x) Returns the arctangent of x as a numeric value between PI/
● 2 and PI/2 radians
● atan2(y, x) Returns the arctangent of the quotient of its arguments
● atanh(x) Returns the hyperbolic arctangent of x
● cbrt(x) Returns the cubic root of x
● ceil(x) Returns x, rounded upwards to the nearest integer
● cos(x) Returns the cosine of x (x is in radians)
● cosh(x) Returns the hyperbolic cosine of x
● exp(x) Returns the value of E
● floor(x) Returns x, rounded downwards to the nearest integer x
● log(x) Returns the natural logarithm (base E) of x
● max(x, y, z,..., n) Returns the number with the highest value
● min(x, y, z,..., n) Returns the number with the lowest value
● pow(x, y) Returns the value of x to the power of y
● random() Returns a random number between 0 and 1
● round(x) Rounds x to the nearest integer
● sin(x) Returns the sine of x (x is in radians)
● sinh(x) Returns the hyperbolic sine of x
● sqrt(x) Returns the square root of x
● tan(x) Returns the tangent of an angle
● tanh(x) Returns the hyperbolic tangent of a number
● trunc(x) Returns the integer part of a number (x)

(i) Explain HTTP request and response header in detail. 5

HTTP Request Header: The request headers provide additional information the
server may use to process the request.
1. Host header tells the server the hostname used in the URL.
Example: Host: www.gefionsoftware.com
2. User-Agent header contains information about the type of browser making
the request. The server can use this to send different types of responses to
different types of browsers.
Example: User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; en-US; rv:
1.0.2)
3. Accept headers provide information about the languages and file formats the
browser accepts. These headers can be used to adjust the response to the
capabilities of the browser and the user's preferences, such as use a supported
image format and the preferred language.
Example:
Accept: image/gif, image/jpeg, image/pjpeg, image/png, */*
Accept-Language : en
Accept-Charset : iso-8859-1,*,utf-8

HTTP Response Headers: The response message has headers just like the
request message.
● Last-Modified header gives the date and time for when the resource was last
modified. The browser can use this information as a timestamp in a local
cache; the next time the user asks for this resource, he can ask the server to
send it only if it's been updated since the last time it was requested.
Example: Last-Modified: Mon, 20 Dec 2002 23:26:42 GMT Date: Tue, 11
Jan 2003 20:52:40 GMT
● Status:Code The status code tells whether the request was successful or not.
Code 200 means that the request was successful.

● Content-Type header tells the browser what type of response data the body
contains and the Content-Length header how large it is.
Example:
Content-Type: text/html
Servlet-Engine: Tomcat Web Server/5.0
Content-Length: 59
A blank line separates the headers from the message body.

You might also like