Module1&2-Internet Technology Answer
Module1&2-Internet Technology Answer
Module1&2-Internet Technology Answer
1. What is Segment ?
A network segment is a logical group of computers that share a network resource. This can
be accomplished with a router, VLAN, switch segmentation, etc. Unfortunately, with a hub,
everyone sees every packet which is why they have pretty much died in the market.
Switching is a much better technology. You can segment a network either logically
(through VLANs or mapping) or physically (connecting switches back to a core).
Unlike TCP, UDP doesn't establish a connection before sending data, it just sends. Because
of this, UDP is called "Connectionless".
In UDP, the receiver does not generate an acknowledgement of packet received and in turn,
the sender does not wait for any acknowledgement of packet sent. This shortcoming makes
this protocol unreliable as well as easier on processing.
4. Define Gateway.
A gateway is a network node that connects two networks using different protocols together.
While a bridge is used to join two similar types of networks, a gateway is used to join two
dissimilar networks.
TCP is connection oriented. TCP requires that connection between two remote points be
established before sending actual data.
To complete the delivery, we need a mechanism todeliver data from one of these processes
running on the source host to the corresponding process running on the destination host.
The transport layer is responsible for process-to-process delivery-thedelivery of a packet,
part of a message, from one process to another.
7. Define Congestion.
Network congestion in data networking and queueing theory is the reduced quality of
service that occurs when a network node or link is carrying more data than it can handle.
Typical effects include queueing delay, packet loss or the blocking of new connections.
8. What is IPV4 ?
Internet Protocol version 4 (IPv4) is the fourth version of the Internet Protocol (IP). It is
one of the core protocols of standards-based internet working methods in the Internet, and
was the first version deployed for production in the ARPANET in 1983.
https://docs.oracle.com/cd/E19253-01/816-4554/gdyen/index.html
Internet Protocol Version 6 (IPv6) is an Internet Protocol (IP) used for carrying data in
packets from a source to a destination over various networks. IPv6 is the enhanced version
of IPv4 and can support very large numbers of nodes as compared to IPv4. It allows for
2128 possible node, or address, combinations.
Quality of service (QoS) refers to a network's ability to achieve maximum bandwidth and
deal with other network performance elements like latency, error rate and uptime.
Though Perl is not officially an acronym but few people used it as Practical Extraction and
Report Language.
It is used for mission critical projects in the public and private sectors.
Perl is an Open Source software, licensed under its Artistic License, or the GNU General Public
License .
Perls database integration interface DBI supports third-party databases including Oracle, Sybase,
Postgres, MySQL and others.
Perl works with HTML, XML, and other mark-up languages.
Perl is extensible. There are over 20,000 third party modules available from the Comprehensive
Perl Archive Network (CPAN).
14. What are the benefits of Perl programming in using it in web based applications?
Perl used to be the most popular web programming language due to its text manipulation
capabilities and rapid development cycle.
A Perl identifier is a name used to identify a variable, function, class, module, or other object. A
Perl variable name starts with either $, @ or % followed by zero or more letters, underscores,
and digits (0 to 9).
Perl has three basic data types − scalars, arrays of scalars, and hashes of scalars, also known as
associative arrays.
Scalars are simple variables. They are preceded by a dollar sign . A scalar is either a number, a
string, or a reference. A reference is actually an address of a variable, which we will see in the
upcoming chapters.
Hashes are unordered sets of key/value pairs that you access using the keys as subscripts. They
are preceded by a percent sign .
Perl variables do not have to be explicitly declared to reserve memory space. The declaration
happens automatically when you assign a value to a variable. The equal sign is used to assign
values to variables.
This context not only doesn't care what the return value is, it doesn't even want a return value.
28. What is the difference between single quoted string and double quoted string?
Single quoted string prints the perl variable as a string whereas double quoted string evaluates
the variable and used to get the variable's value.
#!/usr/bin/perl
$var = "This is string scalar!";
$quote = 'I m inside single quote - $var';
$double = "This is inside double quote - $var";
$escape = "This example of escape -\tHello, World!";
print "var = $var\n";
print "quote = $quote\n"; print "double = $double\n"; print "escape = $escape\n";
Hashes are created in one of the two following ways. In the first method, you assign a value to a
named key on a one-by-one basis −
In the second case, you use a list, which is converted by taking individual pairs from the list: the
first element of the pair is used as the key, and the second, as the value. For example −
When accessing individual elements from a hash, you must prefix the variable with a dollar sign
append the element key within curly brackets after the name of the variable. For example −
#!/usr/bin/perl
%data = ('John Paul' =>45, 'Lisa' =>30, 'Kumar' =>40);
print "$data{'John Paul'}\n"; print "$data{'Lisa'}\n"; print "$data{'Kumar'}\n";
30
40
33. How will you get all keys from Hashes in perl?
You can get a list of all of the keys from a hash by using keys function, which has the following
syntax −
keys %HASH
This function returns an array of all the keys of the named hash. Following is the example −
#!/usr/bin/perl
%data = ('John Paul' =>45, 'Lisa' =>30, 'Kumar' =>40);
@names = keys %data;
print “$names[0]\n";
print "$names[1]\n";
print "$names[2]\n";
Lisa
John Paul
Kumar
34. How will you get all values from Hashes in perl?
You can get a list of all of the values from a hash by using values function, which has the
following syntax −
values %HASH
This function returns an array of all the values of the named hash. Following is the example −
#!/usr/bin/perl
%data = ('John Paul' =>45, 'Lisa' =>30, 'Kumar' =>40);
@ages = values %data;
print "$ages[0]\n"; print "$ages[1]\n"; print "$ages[2]\n";
45
40
35. What is the purpose of ** operator in perl? What is the purpose of <=> operator?
It checks if the value of two operands are equal or not, and returns -1, 0, or 1 depending on
whether the left argument is numerically less than, equal to, or greater than the right argument.
Assume Variable a holds 10 and variable b holds 20 then $a <=> $b returns -1.
36. What is the purpose of lt operator in perl? What is the purpose of gt operator?
lt: It returns true if the left argument is stringwise less than the right argument.
gt: It returns true if the left argument is stringwise greater than the right argument.
37. What is the difference between localtime() and gmtime() functions in perl?
localtime will return the current local time on the machine that runs the script and gmtime will
return the universal Greenwich Mean Time, or GMT .
Less server interaction − You can validate user input before sending the page off to
the server. This saves server traffic, which means less load on your server.
Immediate feedback to the visitors − They don't have to wait for a page reload to
see if they have forgotten to enter something.
Increased interactivity − You can create interfaces that react when the user hovers
over them with a mouse or activates them via the keyboard.
Richer interfaces − You can use JavaScript to include such items as drag-and-drop
components and sliders to give a Rich Interface to your site visitors.
We can not treat JavaScript as a full fledged programming language. It lacks the
following important features −
Client-side JavaScript does not allow the reading or writing of files. This has been
kept for security reason.
JavaScript can not be used for Networking applications because there is no such
support available.
42. Is JavaScript a case-sensitive language? How can you create an Array in JavaScript?
Yes! JavaScript is a case-sensitive language. This means that language keywords,
variables, function names, and any other identifiers must always be typed with a
consistent capitalization of letters.
You can define arrays using the array literal as follows −
var x = []; var y = [1, 2, 3, 4, 5];
43. How to read elements of an array in JavaScript?
An array has a length property that is useful for iteration. We can read elements of an array
as follows −
Applet classes need to be declared as a public becomes the applet classes are access from
HTML document that means from outside code. Otherwise, an applet will not be accessible
from an outside code i.e an HTML.
1. Create/Edit a Java source file. This file must contain a class which extends Applet
class.
2. Compile your program using javac Execute the appletviewer, specifying the name of
your applet's source file or html file. In case the applet information is stored in html file
then Applet can be invoked using java enabled web browser.
• public void init() : Initialization method called only once by the browser.
• public void start() : Method called after init() and contains code to start processing.
If the user leaves the page and returns without killing the current browser session, the start
() method is called without being preceded by init ().
• public void stop() : Stops all processing started by start (). Done if user moves off
page.
• public void destroy() : Called if current browser session is being terminated. Frees
all resources used by the applet.
Applets are small programs transferred through Internet, automatically installed and run
as part of web-browser. Applets implements functionality of a client. Applet is a dynamic
and interactive program that runs inside a Web page displayed by a Java-capable browser.
We don?t have the concept of Constructors in Applets. Applets can be invoked either
through browser or through Applet viewer utility provided by JDK.
54. What tags are mandatory when creating HTML to display an applet?
55. What packages are mandatory when creating an applet to display something?
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Color;
MODULE 1 &2
1. Briefly explain different operations of UDP.
The user datagram protocol - UDP is the datagram oriented protocol without overhead for
opening the connection with the help of 3 way handshake, closing the connection and
maintaining the connection. This UDP is very efficient for the multicast or broadcast type
of the network transmission. It has only the error checking mechanism with the help of
checksums. There are no sequencing of the data in the UDP and the delivery of the data
cannot be guaranteed in that. It is simpler, more efficient and faster than the TCP.
Although, UDP is less robust than the TCP. Here demultiplexing and multiplexing are
possible in the UDP by means of the UDP port numbers. Additionally, there is no
transmission of the lost packets in the UDP.
During the connection, accomplishment both server and client agree upon the sequence
and also acknowledge numbers. The implicit client notifies the server of its source ports.
The sequence is the characteristic of the TCP data segment. This sequence begins with
the random number and each time the new packet is sent, then the sequence is
incremented by a number of bytes sent in the previous segment of the TCP. Acknowledge
segment is moreover the same, but from a receiver side. This does not comprise data and
are equal to the sender's sequence numbers increased by the number of the received
bytes. The ACK segment acknowledges that the host has got the sent data.
TCP is the connection oriented protocol, that means the devices must open the connection
before transferring data and must lose a connection gracefully after transferring the data.
It also assures the reliable data delivery to the destinations.
3. Compare Open loop Congestion Control and Close loop Congestion Control.
These two types of control system have contrast with each other. They have dissimilarities some
of which are discussed below:
Effect of output
– An open loop control system acts completely on the basis of input and the output has no effect
on the control action.
– A closed loop control system considers the current output and alters it to the desired condition.
The control action in these systems is based on the output.
Stability
– Open loop control systems are mostly stable.
– In closed loop control systems stability is a major issue.
Effect on gain
– There is no effect on gain.
– There is no-linear change in system gain.
Implementation
– The structure of open loop control system is rather easy to construct. These systems can be
easily implemented.
– The working principle and structures of closed loop control systems are rather complex and
they are often difficult to implement.
Cost
– As an open loop control system is easy to implement, it needs lesser number of components to
be constructed. Such systems need good calibration and lesser power rating. The overall cost of
these systems is low.
– As the principle is complex, a closed loop control system needs larger number of components
than an open loop control systems. These systems comparatively need less calibration and higher
power rating. The overall cost of these systems is higher.
RARP is available for Ethernet, Fiber Distributed-Data Interface, and token ring LANs.
6. What is Network address translation ? Explain.
A NAT (Network Address Translation or Network Address Translator) is the
virtualization of Internet Protocol (IP) addresses. NAT helps improve security and
decrease the number of IP addresses an organization needs.
NAT gateways sit between two networks, the inside network and the outside network.
Systems on the inside network are typically assigned IP addresses that cannot be routed
to external networks (e.g., networks in the 10.0.0.0/8 block). A few externally valid IP
addresses are assigned to the gateway. The gateway makes outbound traffic from an
inside system appear to be coming from one of the valid external addresses. It takes
incoming traffic aimed at a valid external address and sends it to the correct internal
system. This helps ensure security, since each outgoing or incoming request must go
through a translation process that also offers the opportunity to qualify or authenticate
incoming streams and match them to outgoing requests, for example.
NAT conserves the number of globally valid IP addresses a company needs, and in
combination with Classless Inter-Domain Routing (CIDR) has done a lot to extend the
useful life of IPv4 as a result. NAT is described in general terms in IETF RFC 1631.
The NAT mechanism ("natting") is a router feature, and is often part of a corporate
firewall. NAT gateways can map IP addresses in several ways:
What is Supernetting?
Supernetting is the process of combining several IP networks with a common network
prefix. Supernetting was introduced as a solution to the problem of increasing size in
routing tables. Supernetting also simplifies the routing process. For example, the
subnetworks 192.60.2.0/24 and 192.60.3.0/24 can be combined in to the supernetwork
denoted by 192.60.2.0/23. In the supernet, the first 23 bits are the network part of the
address and the other 9 bits are used as the host identifier. So, one address will represent
several small networks and this would reduce the number of entries that should be
included in the routing table. Typically, supernetting is used for class C IP addresses
(addresses beginning with 192 to 223 in decimal), and most of the routing protocols
support supernetting. Examples of such protocols are Border Gateway Protocol (BGP)
and Open Shortest Path First (OSPF). But, protocols such as Exterior Gateway Protocol
(EGP) and the Routing Information Protocol (RIP) do not support supernetting.
11. Write short note on IGMP.
The Internet Group Management Protocol (IGMP) is an Internet protocol that provides a
way for an Internet computer to report its multicast group membership to adjacent
routers. Multicasting allows one computer on the Internet to send content to multiple
other computers that have identified themselves as interested in receiving the originating
computer's content. Multicasting can be used for such applications as updating the
address books of mobile computer users in the field, sending out company newsletters to
a distribution list, and "broadcasting" high-bandwidth programs of streaming media to an
audience that has "tuned in" by setting up a multicast group membership.
12. What is autonomous system ? Explain Intra and Inter-domain routing protocol.
On the Internet, an autonomous system (AS) is the unit of router policy, either a single
network or a group of networks that is controlled by a common network administrator (or
group of administrators) on behalf of a single administrative entity (such as a university,
a business enterprise, or a business division). An autonomous system is also sometimes
referred to as a routing domain. An autonomous system is assigned a globally unique
number, sometimes called an Autonomous System Number (ASN).
13. What are the advantage of IPV6 over IPV4 ?
These are at the highest level in the DNS structure of the Internet. There are several different types of
TLD's, being:
Two letter domains established for geographical locations; for example; .au signifies Australia. When
originally designated, usually only residents of a country could register their corresponding ccTLD; but
over the years quite a few countries have allowed parties outside their shores to register website names. An
example of this is Tuvalu (.tv).
In the case of .au domain names, strict rules are still in place (and that's a good thing). For example,
.com.au registrants must still be Australians or have registered business interests in Australia. The
registration eligibility criteria for au names has meant .au is still strongly associated with Australia and has
fostered a great deal of trust and confidence in local and even overseas online shoppers.
The best known generic TLD's include .com, .net, .biz, .org and .info - these can be registered by anyone,
anywhere in the world. However, some of the new gTLD's more recently released have various
restrictions.
A top-level name with a specially encoded format that allows it to be displayed in a non-Latin character
set (i.e. special characters).
Second level
The difference between second and third level can be a little confusing. For example, hotmail.com is
considered a second level domain, but hotmail.com.au would be classed as a third level.
Subdomain
DNS means "Domain Name System". Basically it's the system that translates an domain
name (www.google.com) into an IP address (173.194.40.174) which is the unique
identifier of some piece of hardware on a network.
You can understand the use for such a system : it's much easier to remember the name
than the address. Moreover, a name can translate to several address depending on the
time, the load of the server etc.
The first step is to register you domain name. To put it simply, you buy it so that you are
the one who will be able to make the association name <-> address. Once you are the
proud owner of the domain name, you have access to what is called the "DNS zone",
which is basically a list of pairs name <-> IP. It's a list because when you own a domain
name, you can also use sub-domains (mail.google.com, plus.google.com, ...), each of
them can be associated to a different address. Once you have configured the DNS zone, it
is stored on your registar's server.
What is left to explain is how the queries are made. How does your computer knows the
IP address for a given name ? When you type www.google.com in your browser, the
browser starts by asking the translation to a root nameserver. There are 13 of them, and
they are the entry points of the DNS protocol.
When they receive a request, they usually don't know the answer (as there are too many
domain names) but they know who to ask. For example, they know that
www.google.com depends on the "com" DNS server (which handles the domain names
with the .com TLD). So the request in then sent to this server, which will in its turn know
who to ask, and this continues until the request is sent to your registar's server, which will
know the answer your computer is looking for.
Now in reality, this is not the real process. As you can imagine, the number of requests is
overwhelmingly huge, and the 13 servers would create a bottleneck a lot too small for
every request. There are complex caching systems used to relieve the pressure on these
servers and they are, in fact, involved in only a small part of the traffic.
Caching DNS servers will store the answer to DNS queries for a given time, and answer
directly if the same query arrives again in this time frame. In practice, your computer will
ask these caching servers, and the caching server will ask the authoritative servers for the
answer (if it's not in the cache).
18. Explain WWW.
The World Wide Web (WWW) is a network of online content that is formatted in HTML
and accessed via HTTP. The term refers to all the interlinked HTML pages that can be
accessed over the Internet. The World Wide Web was originally designed in 1991 by Tim
Berners-Lee while he was a contractor at CERN.
The World Wide Web is most often referred to simply as "the Web."
The World Wide Web is what most people think of as the Internet. It is all the Web
pages, pictures, videos and other online content that can be accessed via a Web browser.
The Internet, in contrast, is the underlying network connection that allows us to send
email and access the World Wide Web. The early Web was a collection of text-based
sites hosted by organizations that were technically gifted enough to set up a Web server
and learn HTML. It has continued to evolve since the original design, and it now includes
interactive (social) media and user-generated content that requires little to no technical
skills.
We owe the free Web to Berners-Lee and CERN’s decision to give away one of the
greatest inventions of the century.
19. Write short note on Digital Signature.
A digital signature is a mathematical technique used to validate the authenticity and
integrity of a message, software or digital document. The digital equivalent of a
handwritten signature or stamped seal, a digital signature offers far more inherent
security, and it is intended to solve the problem of tampering and impersonation in digital
communications.
Digital signatures can provide the added assurances of evidence of origin, identity and
status of an electronic document, transaction or message and can acknowledge informed
consent by the signer.
In many countries, including the United States, digital signatures are considered legally
binding in the same way as traditional document signatures. The United States
Government Publishing Office publishes electronic versions of the budget, public and
private laws, and congressional bills with digital signatures.
20. Explain the format of HTTP Request Message.
HTTP Request Structure from Client
A simple request message from a client computer consists of the following components:
HTTP Status Code (For example HTTP/1.1 301 Moved Permanently, means the
requested resource was permanently moved and redirecting to some other
resource).
Headers (Example – Content-Type: html)
An empty line.
A message body which is optional.
All the lines in the server response should end with a carriage return and line feed.
Similar to request, the empty line in a response also should only have carriage return and
line feed without any spaces.
22. Develop and demonstrate a XHTML file that includes JavaScript script for the
following problem:
i. Input: A number n obtained using prompt.
ii. Output: The first n Fibonacci numbers.
<html>
<head>
<title>Program 2a</title>
</head>
<script type="text/javascript">
<!--
function fib() {
var n = prompt("Enter N: ","");
fib1=0;
fib2=1;
fib=0;
document.write("<h2>" +fib1 +"
\n</h2>");
document.write("<h2>" +fib2 +"
\n</h2>");
for(i=0;i<n;i++) {
fib = fib1+fib2;
fib1=fib2;
fib2=fib;
document.write("<h2>" +fib +"
\n</h2>");
}}
--
>
</script>
<body onload="fib()">
</body>
23. Develop and demonstrate a XHTML file that includes JavaScript script for the
following problem:
i. Input: A number n obtained using prompt.
ii. Output: A table of numbers from 1 to n and their squares using alert.
<html>
<head>
<title>Program 2b</title>
</head>
<script type="text/javascript">
<!--
function sqr()
{
var n = prompt("Enter N: ","");
msgstr ="The square of numbers from 1 to "+n +" is: \n";
for(i=1;i<=n;i++)
{
msgstr = msgstr +i +"------->" +i*i +"\n";
}
alert(msgstr);
}
-->
</script>
<body onload="sqr()">
</body
24. a) Develop and demonstrate a XHTML file that includes JavaScript script for the
following problem:
· Celsius to Fahrenheit
b) Explain different types of operators present in JavaScript.
<!DOCTYPE html>
<html>
<title>Fahrenheit to Celcius Temperature Converter</title>
<body>
<h2>Temperature Converter</h2>
<p>Type a value in the Fahrenheit field to convert the value to Celsius:</p>
<p>
<label>Fahrenheit</label>
<input id="inputFahrenheit" type="number" placeholder="Fahrenheit"
oninput="temperatureConverter(this.value)" onchange="temperatureConverter(this.value)">
</p>
<p>Celcius: <span id="outputCelcius"></span></p>
<script>
function temperatureConverter(valNum) {
valNum = parseFloat(valNum);
document.getElementById("outputCelcius").innerHTML=(valNum-32)/1.8;
}
</script>
</body>
</html>
b)
JavaScript supports the following types of operators.
Arithmetic Operators
Comparison Operators
Logical (or Relational) Operators
Assignment Operators
Conditional (or ternary) Operators
25. Change background color of a web page depending on time of day using JavaScript.
<script type="text/javascript">
var now = new Date();
var hours = now.getHours();
//18-19 night
if (hours > 17 && hours < 20){
document.write ('<body style="background-color: orange">');
}
//20-21 night
else if (hours > 19 && hours < 22){
document.write ('<body style="background-color: orangered">');
}
//22-4 night
else if (hours > 21 || hours < 5){
document.write ('<body style="background-color: #C0C0C0;">');
}
//9-17 day
else if (hours > 8 && hours < 18){
document.write ('<body style="background-color: #616D7E">');
}
//7-8 day
else if (hours > 6 && hours < 9){
document.write ('<body style="background-color: skyblue">');}
//5-6 day
else if (hours > 4 && hours < 7){
document.write ('<body style="background-color: steelblue">');
}
else {
document.write ('<body style="background-color: white">');
}
</script
26. How will you sort an array in perl? What is the purpose of next statement?
The sort function sorts each element of an array according to the ASCII Numeric
standards. This function has the following syntax −
sort [ SUBROUTINE ] LIST
This function sorts the LIST and returns the sorted array value. If SUBROUTINE is specified
then specified logic inside the SUBTROUTINE is applied while sorting the elements.
#!/usr/bin/perl
# define an array
@foods = qw(pizza steak chicken burgers); print "Before: @foods\n";
next: It causes the loop to skip the remainder of its body and immediately retest its condition
prior to reiterating. last statement.
27. What is the purpose of −> operator? Write a program that generates random integers
between 1 and 10 using perl.
The arrow operator is mostly used in dereferencing a method or variable from an object or a
class name.
If you want to make sure your random number also has a lower limit, you'll have to take care of
this manually, but it's simple also.
For example, let's assume you need a random number that is greater than or equal to 1, but less
than or equal to 10. This Perl random code will do the trick:
my $random_number = int(rand(10)) + 1;
The Perl rand function returns a number between 0 and 9, so by adding 1 to that result, we will
get a number that is greater than or equal to 1 and less than or equal to 10.
$lower_limit = 1;
$upper_limit = 11;
my $random_number = int(rand($upper_limit-$lower_limit)) + $lower_limit;
print $random_number, "\n";
28.Write a program that prints the elements of a list using perl. What are Hashes in perl?
Refer:https://www.tutorialspoint.com/perl/perl_arrays.htm
Hashes: Hashes are unordered sets of key/value pairs that you access using the keys as
subscripts. They are preceded by a percent sign .
<!-- Here respective button when clicked, calls only respective artimetic function. -->
<input type="button" value="ADD" onclick="javascript:addition();">
<input type="button" value="SUB" onclick="javascript:subtraction();">
<input type="button" value="MUL" onclick="javascript:multiply();">
<input type="button" value="DIV" onclick="javascript:division();">
<input type="button" value="MOD" onclick="javascript:modulus();">
</form>
</body>
</html>
30. Describe the methods used to display something in webpage in JavaScript.
Using innerHTML
To access an HTML element, JavaScript can use the document.getElementById(id)
method.
The id attribute defines the HTML element. The innerHTML property defines the HTML
content:
Example
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = 5 + 6;
</script>
</body>
</html>
Using document.write()
For testing purposes, it is convenient to use document.write():
<!DOCTYPE html>
<html>
<body>
<script>
document.write(5 + 6);
</script>
</body>
</html>
Using window.alert()
You can use an alert box to display data:
Example
<!DOCTYPE html>
<html>
<body>
<script>
window.alert(5 + 6);
</script>
</body>
</html>
Using console.log()
For debugging purposes, you can use the console.log() method to display data.
Example
<!DOCTYPE html>
<html>
<body>
<script>
console.log(5 + 6);
</script>
</body>
</html>
30. Describe the methods used to display something in webpage.
The write() method writes HTML expressions or JavaScript code to a document.
The write() method is mostly used for testing: If it is used after an HTML document is
fully loaded, it will delete all existing HTML.
Example:
<!DOCTYPE html>
<html>
<body>
<script>
document.write("Hello World! <br>");
document.write("Have a nice day!");
</script>
</body>
</html>
31. Explain the life cycle of an Applet indicating the functions
Applet Life Cycle
Brief Description of Life Cycle Methods
init(): The applet's voyage starts here. In this method, the applet object is created by the
browser. Because this method is called before all the other methods, programmer can
utilize this method to instantiate objects, initialize variables, setting background and
foreground colors in GUI etc.; the place of a constructor in an application. It is equivalent
to born state of a thread.
start(): In init() method, even through applet object is created, it is in inactive state. An
inactive applet is not eligible for microprocessor time even though the microprocessor is
idle. To make the applet active, the init() method calls start() method. In start() method,
applet becomes active and thereby eligible for processor time.
paint(): This method takes a java.awt.Graphics object as parameter. This class includes
many methods of drawing necessary to draw on the applet window. This is the place
where the programmer can write his code of what he expects from applet like animation
etc. This is equivalent to runnable state of thread.
stop(): In this method the applet becomes temporarily inactive. An applet can come any
number of times into this method in its life cycle and can go back to the active state
(paint() method) whenever would like. It is the best place to have cleanup code. It is
equivalent to the blocked state of the thread.
destroy(): This method is called just before an applet object is garbage collected. This is
the end of the life cycle of applet. It is the best place to have cleanup code. It is
equivalent to the dead state of the thread.
32. What is the difference between Java applets and Java application programs?
33. List any three attributes of Applet tag used in HTML. Explain the purpose of
these attributes.
https://www.tutorialspoint.com/html/html_applet_tag.htm
34. What is a prompt box? Explain the working of timers in JavaScript? Also
elucidate the drawbacks of using the timer, if any?
(2+2+1)
The prompt() method displays a dialog box that prompts the visitor for
input.
A prompt box is often used if you want the user to input a value before entering a
page.
Note: When a prompt box pops up, the user will have to click either "OK" or
"Cancel" to proceed after entering an input value. Do not overuse this method, as it
prevents the user from accessing other parts of the page until the box is closed.
The prompt() method returns the input value if the user clicks "OK". If the user
clicks "cancel" the method returns null.
Timers are used to execute a piece of code at a set time or also to repeat the
code in a given interval of time. This is done by using the
functions setTimeout, setInterval and clearInterval.
The setTimeout(function, delay) function is used to start a timer that calls a
particular function after the mentioned delay. The setInterval(function,
delay) function is used to repeatedly execute the given function in the mentioned
delay and only halts when cancelled. The clearInterval(id) function instructs the
timer to stop.
Timers are operated within a single thread, and thus events might queue up,
waiting to be executed.
35. Explain the difference between "==" and "==="?What are all the types of
Pop up boxes available in JavaScript? What is the use of Void(0)?
(2+2+1)
1. "==" checks only for equality in value whereas "===" is a stricter equality test and
returns false if either the value or the type of the two variables are different.
2. The types of Pop up boxes available in JavaScript are:
o Alert
o Confirm and
o Prompt
3. Void(0) is used to prevent the page from refreshing and parameter "zero" is passed
while calling.Void(0) is used to call another method without refreshing the page.
The push method is used to add or append one or more elements to the end of an Array.
Using this method, we can append multiple elements by passing multiple arguments
38. How are DOM utilized in JavaScript? Display your name using JavaScript
alert box. (2+3)
DOM stands for Document Object Model and is responsible for how various objects in a
document interact with each other. DOM is required for developing web pages, which
includes objects like paragraph, links, etc. These objects can be operated to include
actions like add or delete. DOM is also required to add extra capabilities to a web page.
On top of that, the use of API gives an advantage over other existing models.
<h1>My First Web Page</h1>
<p>My first paragraph.</p>
<script>
window.alert(‘Sudeshna’);
</script>
</body>
</html>
39. Write about the errors shown in JavaScript? How are JavaScript and
ECMA Script related?
ECMA Script are like rules and guideline while Javascript is a scripting
language used for web development.
40.How to merge two array in perl? Name two the prefix dereferencer in perl?
Because an array is just a comma-separated sequence of values, you can combine them together
as shown below.
#!/usr/bin/perl
@numbers = (1,3,(4,5,6));
numbers = 1 3 4 5 6
41.What is the difference between for & foreach? What is eval in perl?
https://stackoverflow.com/questions/2279471/whats-the-difference-between-for-and-foreach-in-
perl
eval: eval in all its forms is used to execute a little Perl program, trapping any errors encountered
so they don't crash the calling program.
https://www.perlmonks.org/?node_id=198959
44. What is the difference between chop & chomp functions in perl? Write a perl script to
validate email address.
chomp() checks whether the last characters of a string or list of strings match the input line
separator defined by the $/ system variable. If they do, chomp removes them.
For details:https://www.linuxnix.com/perl-difference-between-chop-and-chomp-functions-
explained/
Assuming $email_address holds the address to be checked, you can check its validity using:
#!/usr/bin/perl
use Email::Valid
$email_address = 'me@@example.com';
if (Email::Valid->address($email_address)) {
# The email address is valid
} else {
# The email address is not valid
}
You can also have Email::Valid check for valid top-level domains (making sure ".com", ".net",
".cn" or another valid domain name is at the email address's very end). Make sure the
Net::Domain::TLD module is installed.
#!/usr/bin/perl
use Email::Valid
$email_address = 'me@@example.com';
if (Email::Valid->address(-address => $email_address,
-tldcheck => 1)) {
# The email address is valid
} else {
# The email address is not valid
}
45. How to get Hash size in perl. How to add or remove elements in Hashes. How many loop is
supported by perl.
To get the size of a Perl hash (the Perl hash size), use the Perl "keys" function, and assign it to a
scalar value, like this:
$size = keys %my_hash;
The variable $size will now contain the number of keys in your Perl hash, which is the size of the
hash, i.e., the total number of key/value pairs in the hash.
Adding a new key/value pair can be done with one line of code using simple assignment
operator.
#!/usr/bin/perl
%data = ('John Paul' => 45, 'Lisa' => 30, 'Kumar' => 40); @keys = keys %data;
$size = @keys;
print "1 - Hash size: is $size\n";
1 - Hash size: is 3
2 - Hash size: is 4
To remove an element from the hash you need to use delete function as shown below in the
example−
#!/usr/bin/perl
%data = ('John Paul' => 45, 'Lisa' => 30, 'Kumar' => 40); @keys = keys %data;
$size = @keys;
print "1 - Hash size: is $size\n";
1 - Hash size: is 3
2 - Hash size: is 2
Loop Supported:
while loop
until loop
for loop
foreach loop
nested loop
46. Create an html page to explain the use of various predefined functions of string and
math object in java script.
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML =
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
var txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
document.getElementById("demo").innerHTML = txt.length;
</script>
</body>
</html>
MODULE 1 &2
1. Explain the various field of TCP header and the working principle of the TCP
protocol.
https://www.tutorialspoint.com/data_communication_computer_network/transmission_contro
l_protocol.htm
POP: Post Office Protocol (POP) is a type of computer networking and Internet
standard protocol that extracts and retrieves email from a remote mail server for
access by the host machine.
POP is an application layer protocol in the OSI model that provides end users the
ability to fetch and receive email. Post Office Protocol is the primary protocol behind
email communication. POP works through a supporting email software client that
integrates POP for connecting to the remote email server and downloading email
messages to the recipient’s computer machine.
POP uses the TCP/IP protocol stack for network connection and works with Simple
Mail Transfer Protocol (SMTP) for end-to-end email communication, where POP
pulls messages and SMTP pushes them to the server. As of 2012, Post Office
Protocol is in its third version known as POP 3 and is commonly used in most email
client/server communication architecture.
SMTP: SMTP is one of the most common and popular protocols for email
communication over the Internet and it provides intermediary network services
between the remote email provider or organizational email server and the local user
accessing it.
1. Local user or client-end utility known as the mail user agent (MUA)
2. Server known as mail submission agent (MSA)
3. Mail transfer agent (MTA)
4. Mail delivery agent (MDA)
SMTP works by initiating a session between the user and server, whereas MTA and
MDA provide domain searching and local delivery services.
For Details : https://www.geeksforgeeks.org/simple-mail-transfer-protocol-smtp/
FTP: https://www.geeksforgeeks.org/computer-network-file-transfer-protocol-ftp/
7. Differentiate between routers and bridge? State there working principle? (8+7)
a) https://www.geeksforgeeks.org/network-layer-introduction-ipv4/
b) The binary representation of the given address is
11001101 00010000 00100101 00100111
If we set 32−28 rightmost bits to 0, we get
11001101 00010000 00100101 0010000
or
205.16.37.32 (First Address)
9. What is IPV6? Explain its advantage over IPV4. Also explain its frame
format.
Internet Protocol version 6 is a new addressing protocol designed to incorporate
all the possible requirements of future Internet known to us as Internet version 2.
This protocol as its predecessor IPv4, works on the Network Layer (Layer-3).
Along with its offering of an enormous amount of logical address space, this
protocol has ample features to which address the shortcoming of IPv4.
• IPv4 addresses are 32 bit length where as IPv6 addresses are 128 bit length.
• IPv4 addresses are binary numbers represented in decimals and IPv6
addresses are binary numbers represented in hexadecimals.
• Checksum field is available in IPv4 header and no checksum field in IPv6
header.
• Broadcast messages are available in IPv4. Broadcast messages are not
available in IPv6. Instead a link-local scope "All nodes" multicast IPv6
address is used for broadcast similar functionality.
• Manual configuration (Static) of IPv4 addresses or DHCP (Dynamic
configuration) is required to configure IPv4 addresses.Auto-configuration of
addresses is available in IPv6.
https://www.geeksforgeeks.org/computer-network-internet-protocol-version-6-ipv6 -header/
(For frame format)
10. In cases where reliability is not of primary importance, UDP would make a
good transport protocol. Give examples of specific cases. What are the
responsibilities of the network layer in the Internet model ?
(8+7)
https://www.chegg.com/homework-help/tcp-ip-protocol-suite-4th-edition-chapter-14-
solutions-9780073376042
The network layer is the third layer from the bottom in the OSI (Open Systems
Interconnection) seven layer model.Also called the OSI reference model, this model
was originally developed in 1977 in order to standardize and simplify definitions
with regard to computer networks. It divides the networking process into seven
logical layers, starting at the physical level (i.e., cable and network interface cards)
and ascending to the application level (i.e., the layer that interfaces with application
programs on computers), specifying services and protocols for each layer.
The network layer is the layer at which IP (Internet protocol) operates. Other
protocols in the TCP/IP suite of protocols, which forms the basis of the Internet and
most other networks that also operate in this layer are ICMP, IPsec, ARP, RIP,
OSPF and BGP.
The network layer is responsible for routing, which is moving packets (the
fundamental unit of data transport on modern computer networks) across the
network using the most appropriate paths. It also addresses messages and
translates logical addresses (i.e., IP addresses) into physical addresses (i.e., MAC
addresses).
This contrasts with the data link layer below it, which is responsible for the device-
to-device delivery of packets using MAC addresses. Above the network layer is
the transport layer, which is responsible for making certain that packets are
delivered in sequence and without errors, loss or duplication.
11. a) What is JavaScript? State the difference between JavaScript and Java.
How to develop JavaScript? Explain with example.
b) Write a java script code to verify authenticity of EMAIL ADDRESS in a
given text box.
(2+3+5+5)
a) JavaScript is a lightweight, interpreted programming language with object-oriented
capabilities that allows you to build interactivity into otherwise static HTML pages.
The general-purpose core of the language has been embedded in Netscape, Internet
Explorer, and other web browsers.
JAVA JAVASCRIPT
<!DOCTYPE html>
<html>
<body>
<h2>What Can JavaScript Do?</h2>
<p id="demo">JavaScript can change HTML content.</p>
<button type="button" onclick='document.getElementById("demo").innerHTML =
"Hello JavaScript!"'>Click Me!</button>
</body>
</html>
b) We can validate the email by the help of JavaScript.
There are many criteria that need to be follow to validate the email id such as:
o email id must contain the @ and . character
o There must be at least one character before and after the @.
o There must be at least two characters after . (dot).
Let's see the simple example to validate the email field.
<script>
functionvalidateemail()
{
var x=document.myform.email.value;
varatposition=x.indexOf("@");
vardotposition=x.lastIndexOf(".");
if (atposition<1 || dotposition<atposition+2 || dotposition+2>=x.length){
alert("Please enter a valid e-mail address \n atpostion:"+atposition+"\n
dotposition:"+dotposition);
return false;
}
}
</script>
<body>
<form name="myform" method="post" action="#" onsubmit="return
validateemail();">
Email: <input type="text" name="email"><br/>
Window object − Top of the hierarchy. It is the outmost element of the object
hierarchy.
Document object − Each HTML document that gets loaded into a window becomes a
document object. The document contains the contents of the page.
Form object − Everything enclosed in the <form>...</form> tags sets the form object.
Form control elements − The form object contains all the elements defined for that
object such as text fields, buttons, radio buttons, and checkboxes.
<!DOCTYPE html>
<html>
<body>
<h2>What Can JavaScript Do?</h2>
<p id="demo">JavaScript can change HTML content.</p>
<button type="button" onclick='document.getElementById("demo").innerHTML =
"Hello JavaScript!"'>Click Me!</button>
</body>
</html>
13. a) How scripting language is differs from HTML.
b) Define function in Java Script with example.
c)Write the complete JavaScript to prompt the user for the radius of the sphere
and call function sphere Volume to calculate and display the volume of the
sphere. Use thestatement. Volume=(4.0/3.0)*Math.PI*Math.pow(radius,3).
(4+5+6)
a) HTML is actually a markup language and not a scripting language.
Scripting implies decision making capabilities (the code can actually evaluate and
take an action based on what it finds) – PHP, PERL, Ruby, Javascript are examples of
scripting languages.
Markup languages create structure for a document … they only describe data. For
example: HTML, XHTML, XML
b) Code can be reused: Define the code once, and use it many times. The same code
many times with different arguments, to produce different results.
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Functions</h2>
<script>
functiontoCelsius(f) {
return (5/9) * (f-32);
}
document.getElementById("demo").innerHTML = toCelsius(77);
</script>
</body>
</html>
c)
HTML Code:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Volume of a Sphere</title>
<style>
body{padding-top:30px;}
label,input{display:block;}
</style>
</head>
<body>
<p>Input radius value and get the volume of a sphere.</p>
<form action="" method="post" id="MyForm">
<label for="radius">Radius</label><input type="text" name="radius" id="radius"
required>
<label for="volume">Volume</label><input type="text" name="volume"
id="volume">
<input type="submit" value="Calculate" id="submit"></form>
</body>
</html>
JavaScript Code:
functionvolume_sphere()
{
var volume;
var radius = document.getElementById('radius').value;
radius = Math.abs(radius);
volume = (4/3) * Math.PI * Math.pow(radius, 3);
volume = volume.toFixed(4);
document.getElementById('volume').value = volume;
return false;
}
window.onload = document.getElementById('MyForm').onsubmit = volume_sphere;
14. a) Explain the various event handlers in java script. Give an example of each.
b) Develop a JavaScript program to display a message “HI ! GOOD MORNING
TO YOU “when a page is loaded and displays a message “THANKS TO VISIT
OUR WEB PAGE” when a page is unloaded. (8+7)
Event Handlers:
onclick: Use this to invoke JavaScript upon
clicking (a link, or form boxes)
onload: Use this to invoke JavaScript after the
page or an image has finished loading.
onmouseover: Use this to invoke JavaScript if the
mouse passes by some link
onmouseout: Use this to invoke JavaScript if the
mouse goes pass some link
onunload: Use this to invoke JavaScript right after
someone leaves this page.
<script>
function inform(){
alert("You have activated me by clicking the grey button! Note that the event handler
is added within the event that it handles, in this case, the form button event tag")
}
</script>
<form>
<input type="button" name="test" value="Click me" onclick="inform()">
</form>
<html>
<head><title>Body onload example</title>
</head>
<body onload="alert('This page has finished loading!')">
Welcome to my page
</body>
</html>
<html>
<head>
<script type="text/JavaScript">
function load() {
alert("HI ! GOOD MORNING TO YOU");
}
function unload(){
alert("THANKS TO VISIT OUR WEB PAGE");
}
</script>
</head>
</body>
</html>
15. a) With an example describe java scripts Control structure.
b) Design a web page with a text box (username) where the user can enter a
name and
Another text box (ID) where the user enter an only four digit ID.NO and a
button “validate”. Validate the entered username and ID field for the following
using java script.
· Both the fields should not be empty
· Name field should have alphabets
· ID field should have numeric.
(7+8)
<!DOCTYPE html>
<html>
<body>
<script>
function myFunction() {
var id = document.getElementById("id").value;
var uname = document.getElementById("uname").value;
submitOK = "true";
if (isNaN(id)) {
alert("The id contain numeric value only!!");
submitOK = "false";
}
else{
if (id.length != 4 ) {
alert("The id contain 4 digits only !!");
submitOK = "false";
}}
}
if (submitOK == "false") {
return false;
}
}
</script>
</body>
</html>
a) Conditional statements are used to perform different actions based on different
conditions.
Very often when you write code, you want to perform different actions for different
decisions.
In JavaScript we have the following conditional statements:
Use if to specify a block of code to be executed, if a specified condition is true
Use else to specify a block of code to be executed, if the same condition is false
Use else if to specify a new condition to test, if the first condition is false
Use switch to specify many alternative blocks of code to be executed
Example:
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
function myFunction() {
var greeting;
var time = new Date().getHours();
if (time < 10) {
greeting = "Good morning";
} else if (time < 20) {
greeting = "Good day";
} else {
greeting = "Good evening";
}
document.getElementById("demo").innerHTML = greeting;
}
</script>
</body>
16. a) What are Style Sheets? List down the ways of including style information
in a document. Explain about types of cascading style sheet? Explain with
example.
A Style Sheet is a collection of style rules that that tells a browser how the various
styles are to be applied to the HTML tags to present the document. Rules can be
applied to all the basic HTML elements, for example the <p> tag, or you can define
you own variation and apply them where you wish to.
There are three types of Style Sheets:
Embedded: the style rules are included within the HTML at the top of the Web page
- in the head.
Inline: the style rules appear throughout the HTML of the Web page - i.e. in the
body.
Linked: The style rules are stored in a separate file external to all the Web pages.
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-color: lightblue;
}
h1 {
color: white;
text-align: center;
}
p{
font-family: verdana;
font-size: 20px;
}
</style>
</head>
<body>
b) Design a webpage with a textbox where the user can enter a four digit number
and button “validate”. Validate the entered number for the following using java
script. No zeroes the first digit Entered number must be in ascending order of
digits (Ex:1234,5678…).
(7+8)
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
function validate()
{
var cars=form1.demo.value;
vari = 0;
varlen = cars.length;
var text = "";
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
function myFunction() {
var greeting;
var time = new Date().getHours();
if (time < 10) {
greeting = "Good morning";
} else if (time < 20) {
greeting = "Good day";
} else {
greeting = "Good evening";
}
document.getElementById("demo").innerHTML = greeting;
}
</script>
</body>
B) Advantages of Scripting
A scripting language is a form of programming language that is used to create scripts
or bits of code. Scripting languages are often written to facilitate enhanced features of
websites, these features are processed on the server but the script of a specific page
runs on the user’s browser. The origin of the term was similar to its meaning in “a
movie script tells actors what to do”: a scripting language controlled the operation of
a normally-interactive program, giving it a sequence of work to do all in one batch.
For instance, one could put a series of editing commands in a file, and tell an editor to
run that “script” as if those commands had been typed interactively.
18. Write JavaScript for the following. Provide a text box for the user enter user
name. Validate the username for the no. of characters (assume some no. say 6).
Provide a SUBMIT button for the validation to happen. On successful validation
display a new page with an image and two text boxes for entering the width and
height of the image respectively with a RESIZE button below. On clicking the
Resize button validate the width and height numbers and on successful
validation display the image with the requested width and height.
(15)
First page refer to question no. 15.
Second Page:
<!DOCTYPE html>
<html>
<body>
Width:
<input type="text" id="width"><br><br>
Height:
<input type="text" id="height"><br><br>
<br><br>
<img src="img_girl.jpg" id="gl" alt="Girl in a jacket" width="100"
height="100"><br>
<button onclick="myFunction()">Resize</button>
<script>
function myFunction() {
var myImg = document.getElementById("gl");
var x = document.getElementById("width").value;
var y = document.getElementById("height").value;
myImg.width=x;
myImg.height=y;
}
</script>
</body>
</html>
19. a) Create an html page named as “validate_registration.html”
A) Define a method name as “reset()” to be called when reset button is clicked
and manually set all values of fields to default.
B) Define a method name as “check()” to be called when check button is clicked.
C) here check for blank entry, name, age, email, phone no, radio button,
checkbox.
D) Once all the valuables are properly filled make the submit button to be
visible.
E) Define the various fields in form using table.
(15)
<html>
<script>
function reset1()
{
x=confirm("It will clear all the text entered")
if(x==true)
{
document.form1.t1.value=""
document.form1.t2.value=""
document.form1.ta.value=""
document.form1.t3.value=""
document.form1.r1[0].checked=false
document.form1.r1[1].checked=false
document.form1.c1.checked=false
document.form1.c2.checked=false
document.form1.c3.checked=false
document.form1.c4.checked=false
document.form1.c5.checked=false
document.form1.c6.checked=false
document.form1.t1.focus()
}
}
function check()
{
if((document.form1.t1.value=="")||(!(isNaN(document.form1.t1.value))))
{alert("please enter the correct name")
document.form1.t1.value=""
document.form1.t1.focus()
}
else if((document.form1.t2.value=="")||(isNaN(document.form1.t2.value)))
{
alert("please enter the age correctly")
document.form1.t2.value=""
document.form1.t2.focus()
}
else if(document.form1.t2.value>40)
{
alert("Sorry you age is beyound the limit")
document.form1.t2.value=""
document.form1.t2.focus()
}
else if(document.form1.ta.value=="")
{
alert("please enter the address")
document.form1.ta.focus()
}
else
if((document.form1.r1[0].checked==false)&&(document.form1.r1[1].checked==false
))
{
alert("please select the radio button")
document.form1.r1[0].focus()
}
else
if((document.form1.c1.checked==false)&&(document.form1.c2.checked==false)&&(
document.form1.c3.checked==false)&&(document.form1.c4.checked==false)&&(do
cument.form1.c5.checked==false))
{
alert("please select the the languages known")
document.form1.c1.focus()
}
else if(document.form1.t3.value=="")
{
alert("please enter the password")
document.form1.t3.focus()
}
else
if((document.form1.t1.value!="")&&(document.form1.t2.value!="")&&(document.fo
rm1.t3.value!="")&&(document.form1.ta.value!="")&&((document.form1.r1[0].chec
ked!=false)||(document.form1.r1[0].checked!=false))&&((document.form1.c1.checke
d!=false)||(document.form1.c2.checked!=false)||(document.form1.c3.checked!=false)||
(document.form1.c4.checked!=false)||(document.form1.c5.checked!=false)))
{
x=confirm("you have entered the datascorrectly,want to submit the form")
if(x)
{
document.lay.visibility="show"
}
}
}
</script>
<body bgcolor="lightblue" text="red" style="font-size:15pt;font-family:Garamond"
onload=document.form1.t1.focus()><center>
<h2>ENTRY FORM</h2></center>
<form name=form1 method=post >
<table name=tab cellspacing=30pt>
<tr><td align=left><h2>Enter your Name :</h2></td><td align=right><input
type=text name=t1 size=18>
<tr><td align=left><h2>Enter your Age :</h2></td><td align=right><input type=text
name=t2 maxlength=3 size=18>
<tr><td align=left><h2>Enter your Address :</h2></td><td align=right><textarea
name=ta rows=5 cols=15></textarea>
<tr><td align=left><h2>Sex :</h2></td><td align=left><input type=radio name=r1
value="female">Female<br>
<input type=radio name=r1 value=male>Male</td>
<tr><td align=left><h2>Languages Known :</h2></td><td
align=left><center>(select more than one)</center>
<input type=checkbox name=c1 value=c>C<br>
<input type=checkbox name=c2 value=c++>C++<br>
<input type=checkbox name=c3 value=vb>VB<br>
<input type=checkbox name=c4 value=java>JAVA<br>
<input type=checkbox name=c5 value=asp>ASP<br>
<input type=checkbox name=c6 value=others>OTHERS<br></td>
<tr><td align=left><h2>Enter your Password :</h2></td><td align=right><input
type=password name=t3 size=18>
</table><center>
<input type=button value=" reset "onClick=reset1()>
<input type=button value=" check "onClick=check()>
<h3>Before submitting the datas please click the check Button</h3>
<input type="submit" value=" submit "></center>
</form>
</body>
</html>
(15)
<html>
<head>
<script type="text/javascript">
varnum=0;
number=0;
varnumarray=new Array();
functionarray_size()
{
num=prompt("Enter how many number to be sorted","000");
number=parseInt(num);
get_numbers();
}
functionget_numbers()
{
if (number!=null && number!="")
{
for(i=0;i<number;i++)
{
n=prompt("Enter the number to be sorted","1");
numarray[i]=parseInt(n);
}
}
sorting()
}
function sorting()
{
document.writeln("<h1>Sorted Array<h1>");
document.writeln(numarray.sort(sortNumber));
}
functionsortNumber(a,b )
{
return a - b;
}
</script>
</head>
<body>
<h1> Click the button to get the Number sorted</h1>
<input type="button" onclick="array_size()" value="Get Array Size" />
</body>
</html>
22. a) Explain the following HTML tags with all attributes.
i) <a>(ii)<img> (iii)<table> (iv)<p>
b) Create an html page named as openwindow.html. Define a method called as
openwin() which is to be called when a button is clicked. Within this method
specify the necessary code to open a new window with some message as well as
images.
(8+7)
i) The <a> tag defines a hyperlink, which is used to link from one page to another.
The most important attribute of the <a> element is the href attribute, which indicates
the link's destination.
By default, links will appear as follows in all browsers:
<html>
<head>
<script language="javascript">
functionopenwin()
{
msg=window.open("","Displaywindow","height=200,width=200,status=yes,toolbar=
yes,directories=no,menubar=yes,location=yes");
msg.document.write("<html><title>A new Window</title>");
msg.document.write("<imgsrc='nathan.gif'><p><form><input type=button
value=close onclick=self.close()></form></html>");
}
</script>
</head>
<body bgcolor="blue">
<form>
<input type=button value=click name=b1 onclick=openwin()>
</form>
</body>
</html>
23. a) Explain importance of Frame tag in HTML.
b) Create an html page named as changebackground_color.html
Define a method named as random_color() which is to be called when you click
on the body. This method should generate random number, which is used to set
the background colour. (5+10)
a)
HTML frames are used to divide your browser window into multiple sections where
each section can load a separate HTML document. A collection of frames in the
browser window is known as a frameset. The window is divided into frames in a
similar way the tables are organized: into rows and columns.
To use frames on a page we use <frameset> tag instead of <body> tag. The
<frameset> tag defines, how to divide the window into frames. The rows attribute of
<frameset> tag defines horizontal frames and cols attribute defines vertical frames.
Each frame is indicated by <frame> tag and it defines which HTML document shall
open into the frame.
Example:
<!DOCTYPE html>
<html>
<head>
<title>HTML Frames</title>
</head>
<noframes>
<body>Your browser does not support frames.</body>
</noframes>
</frameset>
</html>
b)
<!DOCTYPE html>
<html>
<body onclick="random_bg_color()">
<script>
functionrandom_bg_color() {
var x = Math.floor(Math.random() * 256);
var y = Math.floor(Math.random() * 256);
var z = Math.floor(Math.random() * 256);
varbgColor = "rgb(" + x + "," + y + "," + z + ")";
console.log(bgColor);
document.body.style.background = bgColor;
}
</script>
</body>
</html>
24. (a) What is an applet? What are the demerits of an applet?
An applet (little application) is a small software program that supports a larger
application program. In the past, the term applet was often associated with the Java
programming language.
A Java applet may have any of the following disadvantages:
o Some browsers, notably mobile browsers running Apple iOS or Android do not
run Java applets at all.
o If an applet requires a newer JRE than available on the system, or a specific JRE,
the user running it the first time will need to wait for the large JRE download to
complete.
o Java automatic installation or update may fail if a proxy server is used to access
the web. This makes applets with specific requirements impossible to run unless
Java is manually updated. The Java automatic updater that is part of a Java
installation also may be complex to configure if it must work through a proxy.
start − This method is automatically called after the browser calls the init method. It is
also called whenever the user returns to the page containing the applet after having
gone off to other pages.
stop − This method is automatically called when the user moves off the page on
which the applet sits. It can, therefore, be called repeatedly in the same applet.
destroy − This method is only called when the browser shuts down normally. Because
applets are meant to live on an HTML page, you should not normally leave resources
behind after a user leaves the page that contains the applet.
paint − Invoked immediately after the start() method, and also any time the applet
needs to repaint itself in the browser. The paint() method is actually inherited from
the java.awt.
25. (a) What is an applet? Explain functionalities of stop (), paint() and repaint()
method. (b) Discuss the steps involved in developing and running an applet?
(c) Write an Applet program to show status message in Status Window.((2+3)
+5+5)
https://www.javatpoint.com/java-applet
(c) Write an applet to add two numbers and display the result using drawstring
(). (4+6+5)
https://www.javatpoint.com/java-applet
https://www.javatpoint.com/java-applet
28. (a) Using the FROM tag of HTML create a registration form containing the
below mentioned fields :
(i) First Name (Using text boxes)
(ii) Last Name (Using text boxes)
(iii) E-mail ID (Using text boxes)
(iv) Gender (Using radio button)
(v) Hobbies (Using check boxes)
(vi) Submit Button and Reset Button.
(b) What is the difference between Static and Dynamic WebPages ? What do you
mean by Active Web Pages.
(c) In your browser there will be a textbox to enter your name. There will be a
SUBMIT button. If your name field is empty then on submit this will give an
alert that your name field is empty. If your name is more than10 characters long
then it will give an alert to enter your name properly. Else it will display your
name in capital, bold and in red colour. (4+5+6)
(a) (sample code for FORM)
<!DOCTYPE html>
<html>
<body>
<h2>HTML Forms</h2>
<form action="/action_page.php">
First name:<br>
<input type="text" name="firstname" value="Mickey">
<br>
Last name:<br>
<input type="text" name="lastname" value="Mouse"><br><br>
<input type="radio" name="gender" value="male" checked> Male<br>
<input type="radio" name="gender" value="female"> Female<br>
<input type="radio" name="gender" value="other"> Other
<br><br>
<input type="submit" value="Submit">
</form>
<p>If you click the "Submit" button, the form-data will be sent to a page called
"/action_page.php".</p>
</body>
</html>
(b) Web pages can be either static or dynamic. "Static" means unchanged or constant, while
"dynamic" means changing or lively. Therefore, static Web pages contain the same
prebuilt content each time the page is loaded, while the content of dynamic Web pages
can be generated on-the-fly.
Standard HTML pages are static Web pages. They contain HTML code, which defines the
structure and content of the Web page. Each time an HTML page is loaded, it looks the same.
The only way the content of an HTML page will change is if the Web developer updates and
publishes the file.
Other types of Web pages, such as PHP, ASP, and JSP pages are dynamic Web pages. These
pages contain "server-side" code, which allows the server to generate unique content each
time the page is loaded. For example, the server may display the current time and date on the
Web page. It may also output a unique response based on a Web form the user filled out.
Many dynamic pages use server-side code to access database information, which enables the
page's content to be generated from information stored in the database. Websites that generate
Web pages from database information are often called database-driven websites.
An active web page is a page where the browser performs the logic instead of the server. So
for example when there is a page showing share prices, then it needs to be updated very
frequently, e.g. every 5 seconds. A solution would be to use AJAX with JavaScript. In
contrast to PHP, browser is able to execute JavaScript, so it is happening without reloading
the page. So with an active page, everything is happening inside browser without the need to
reload the page every time information is required.
29. (a) What are the different ways of adding styles ( CSS ) to web page ? Write
the precedence rule for the same. What are subgroup selectors in CSS? Give
example.
(b) Write HTML/JavaScript code for dividing the browser window into two
horizontal parts (left part is content and right part is main). Left part should
contain the anchors clicking on which corresponding page to be displayed at the
right part. Clearly state the assumptions regarding the developed code.
(4+2+3)+6
(a) CSS stands for Cascading Style Sheets.
CSS describes how HTML elements are to be displayed on screen, paper, or in other media.
CSS saves a lot of work. It can control the layout of multiple web pages all at once.
CSS can be added to HTML elements in 3 ways:
• Inline - by using the style attribute in HTML elements
• Internal - by using a <style> element in the <head> section
• External - by using an external CSS file
Inline CSS
An inline CSS is used to apply a unique style to a single HTML element.
An inline CSS uses the style attribute of an HTML element.
This example sets the text color of the <h1> element to blue:
Example:
<h1 style="color:blue;">This is a Blue Heading</h1>
Internal CSS
An internal CSS is used to define a style for a single HTML page.
An internal CSS is defined in the <head> section of an HTML page, within a <style>
element:
External CSS
An external style sheet is used to define the style for many HTML pages.
With an external style sheet, one can change the look of an entire web site, by changing one
file!
To use an external style sheet, add a link to it in the <head> section of the HTML page.
Priority of the CSS property in a HTML document is applied top to bottom and left to right.
Values defined as Important will have the highest priority.
Inline CSS has a higher priority than embedded and external CSS.
So the final order is:
Value defined as Important > Inline >id nesting > id > class nesting > class > tag nesting >
tag.
Subgroup selector for a style sheet rule is most often an HTML element name.
Paragraphs scattered throughout the document to be set apart from running text with
wider left and right margins.
All but one of the h2 elements in the document to be set to the color red; the one
exception must be blue.
In a three-level ordered list (ol) group, you want to assign different font sizes to each
level.
Each of these possibilities calls for a different way of creating a new selector group or
specifying an exception to the regular selectors.
CSS style sheets provide three simple ways of creating subgroups that can handle almost
every design possibility:
Class selectors
ID selectors
Descendant selectors
Using these subgroup selectors requires special ways of defining selectors in style sheet rules.
These selectors also require the addition of attributes to the HTML tags they apply to in the
document. Because all CSS-enabled browsers support these CSS1 subgroup selectors, you
should have these deeply ingrained in your authoring repertoire.
.centered img {
width: 150px;
border-radius: 50%;
}
</style>
</head>
<body>
<div class="split left">
<div class="centered">
<img src="img_avatar2.png" alt="Avatar woman">
<h2>Jane Flex</h2>
<p>Some text.</p>
</div>
</div>
<div class="split right">
<div class="centered">
<img src="img_avatar.png" alt="Avatar man">
<h2>John Doe</h2>
<p>Some text here too.</p>
</div>
</div>
</body>
</html>
<a href="http://www.yahoo.com#YahoosAnchor">blabla</a>
30. (a) Write a DTD and XML for the following customer data :
A) Customer id (must be unique)
B) Customer name (first and last name as to be specified)
C) Mobile no. (can be more than one )
D) Address
i. State
ii. Pin
iii. Country
E) Credit card ( may or may not be there )
i. Credit card no.
ii. Credit card type ( Domestic or International )
(b) Illustrate with example the use of IMAGE swapping using
HTML/JavaScript. Write the HTML code for creating Table with 2 rows and 3
column and first row for the table should be with 3 column merged.
8+(4+3)
(a) (sample code)
<?xml version = "1.0" standalone="yes"?>
<!DOCTYPE document [
<!ELEMENT document (employee)*>
<!ELEMENT employee (name, hiredate, projects)>
<!ELEMENT name (lastname, firstname)>
<!ELEMENT lastname (#PCDATA)>
<!ELEMENT firstname (#PCDATA)>
<!ELEMENT hiredate (#PCDATA)>
<!ELEMENT projects (project)*>
<!ELEMENT project (product,id,price)>
<!ELEMENT product (#PCDATA)>
<!ELEMENT id (#PCDATA)>
<!ELEMENT price (#PCDATA)>
]>
<document>
<employee>
<name>
<lastname>Kelly</lastname>
<firstname>Grace</firstname>
</name>
<hiredate>October 15, 2005</hiredate>
<projects>
<project>
<product>Printer</product>
<id>111</id>
<price>$111.00</price>
</project>
<project>
<product>Laptop</product>
<id>222</id>
<price>$989.00</price>
</project>
</projects>
</employee>
<employee>
<name>
<lastname>Grant</lastname>
<firstname>Cary</firstname>
</name>
<hiredate>October 20, 2005</hiredate>
<projects>
<project>
<product>Desktop</product>
<id>333</id>
<price>$2995.00</price>
</project>
<project>
<product>Scanner</product>
<id>444</id>
<price>$200.00</price>
</project>
</projects>
</employee>
<employee>
<name>
<lastname>Gable</lastname>
<firstname>Clark</firstname>
</name>
<hiredate>October 25, 2005</hiredate>
<projects>
<project>
<product>Keyboard</product>
<id>555</id>
<price>$129.00</price>
</project>
<project>
<product>Mouse</product>
<id>666</id>
<price>$25.00</price>
</project>
</projects>
</employee>
</document>
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
}
</style>
</head>
<body>
<h2>Bordered Table</h2>
<p>Use the CSS border property to add a border to the table.</p>
<table style="width:100%">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
<td>80</td>
</tr>
</table>
</body>
</html>