BCA Web Programming Exam Guide
BCA Web Programming Exam Guide
Prof. K Adisesha
www.onlinebu.com
Downloaded by SATHYA PoLo (sathyashiva9148@gmail.com)
lOMoARcPSD|6953214
Prof. K Adisesha
www.onlinebu.com
Downloaded by SATHYA PoLo (sathyashiva9148@gmail.com)
lOMoARcPSD|6953214
Prof. K Adisesha
Prof. K Adisesha
Prof. K Adisesha
Prof. K Adisesha
Illlililtilil[tiltlt]!ffiffi sM - 626
s6
Vl Semester B.C.A. Examination, May/June2O1
(CBCS) (F+R) (2016 - 17 & Onwards)
COMPUTER SCIENCE
BCA 604 : Web Programming
Time : 3 Hours
SECTION _ B
e) Diffenentlate < span > and < div > tags with examples. 2
P.T.O.
sM -- 626 rfl]tiltililillrlllililffillIt
, .*:]': '
-,
" :ll'
14. a) What is e.SS ? Explain the different levels of CSS with examples. 5
b) write at' Javascript program to imprement all string operations. 5
. ,.j
15, a) What is selector in CSS ? Distinguish class and lD selectors with examples. 5
b) What is a form ? lllustrate the major attributes of form with examples. 5
16. a) What is an array in JavaScript ? How to create an array object ? Give an
example. 5
b) What is the general syntax of a JavaScript function ? Give an example. 5
17. Explain pattern matching using regurar expressions in Javascript. 10
18. a) lllustrate DOM. 5
b) write a Javascript program to implement keyboard events. 5
'19.
a) What is DTD ? Explain the type of DTD. 5
b) Write a JavaScript program to find factorial of a list of numbers, reading input
as command line argument. 5
20. a) Explain CSS box model. Prof. K Adisesha
5
b) Describe XML processors. 5
Prof. K Adisesha
Prof. K Adisesha
[May/June 2016]
1. What is protocol? State any two protocols.
A protocol is a set of rules defined when two entities are communicating so that they can have
uniformity, security, efficiency etc in their communication. While HTML is a markup
language, the basic element of a web page.
Two protocols are:
FTP, telnet, mailto, news, https, etc.
2. What is the use of <img>tag? Give the syntax of <img> tag.
The image tag is written as <img>. It is used to insert an images in an XHTML document.
It is necessary to close the <img> tag in XHTML. It is done so by putting a (/) backslash after
the word img i.e.<img/>.
Syntax: If the image is present in the local drive.
<img src==c:\images\img1.jpeg=/>
3. What are forms?
A form is simply an area that can contain form fields, form fields are objects that allow
the visitor to enter the information.
Prof.buttons.
Ex: text-boxes, drop-down menus or radio K Adisesha
4. What is MIME? Explain.
MIME, also known as Multipurpose Internet Mail Extensions, a specification for formatting
non ASCII messages so that they can be sent over the Internet.
Syntax : main_mime_type/mime_subtype
Example : image/gif
[May/June 2017]
1. What is web browser? Mention any three web browsers.
A web browser is a software application used to locate and display web pages. It is able
to retrieve, find, view, and send information over the internet.
Web browsers are:
1. Internet Explorer 4. Google Chrome
2. Netscape Navigator 5. Mozilla Firefox
3. Opera 6. Safari
[May/June 2018]
1.What do you mean by IP address?
Every machine on the internet has a unique identifying number called an IP address. The IP
stands for Internet Protocol, which is the language that computers used to communicate over
the internet.
IP address looks like 216.27.61.136
2.Define URL? Give an example.
Uniform Resource Locator or URL is a fancy name for address. It contains
information about where a file is and what a browser should do while it. Each file on the
Internet has a unique URL.
Ex: ftp://ftp.site.com/pub/prog.exe
When the user clicks this URL, the browser will begin an FTP transfer of the file
prog.exe.
3.Give any two differences between HTML and XHTML.
Prof. K Adisesha
[May/June 2019]
1. What is HTML event with example?
Interaction with HTML is handled through events that occur when the user or the browser
manipulates a page. When the page loads, it is called an events. When the user clicks a button,
that click too is an event.
Examples: Include event like pressing any key, closing a window, resizing a window etc.
2. Define <pre> tag with example?
The <pre> tag defines preformatted text. Text in a <pre> element is displayed in a fixed-
width font and it preserves both spaces and line breaks.
Ex: <body>
<p>
<pre>
Book Price
------------------------------------
WP 300
</pre>
</p>
</body>
UNIT II
[May/June 2015]
1. What are <div> and <span> tags and their uses?
<span> tag is a paired tag means it has both open(<) and closing (>) tag and it is mandatory
to close the tag. The span tag is used to grouping of inline-elements.
<div> tag used in HTML to make divisions of content in the web page like (text, images,
etc),div tag has both open(<div>) and closing (</div>) tag and it is mandatory to close the tag.
Prof.selector
2. What is universal selector or universal K Adisesha
in CSS?
[May/June 2016]
1. What is ID selector in CSS? How it will be represented.
ID selector are similar to class selector. It used to select any HTML element that has an ID
attribute, regardless of their position in the document tree. # character followed by the ID of
the element.
Example: #para1{
text-align: center;
color: red;
}
UNIT III
[May/June 2015]
1. What are the composite data types in Java script?
A composite data type in JavaScript has multiple values, which grouped together. It works
the same as the object in the class.
[May/June 2016]
1. What do you mean by an object in java script?
The web page document is an object. Any table, forms, button, or link on the page is also
an object, each object has an certain properties like background color etc.
[May/June 2017]
1. What do you mean by an Math and date object in java script?
Math object: Javascript Math object is used to perform mathematical tasks. Math
object need not be defined. Math object in Javascript has two main attributes:
Properties and Methods.
Prof. K Adisesha
Date object: To display date in Javascript we use Date object. A Date object contains
date information. The Date object is created using new operator . Methods are:
getSeconds(), getMinutes(), getHours(),etc.
[May/June 2018]
1. What is constructor in java script?
A constructor is a function in JavaScript. It9s not the function declaration what separates
a function from constructor but the function invocation. A constructor is called with new
keyword. A constructor names must start with a capital letter.
[May/June 2019]
1. Explain any 2 string methods in java script or methods of string in object?
1. charAt() : Returns the character at the specified index.
Ex: var b=9 I am a Java script learner.9
document.write(b.charAt(5))
2. indexOf() : Returns the index with the calling string object of the first occurrence of
the specified
value, or -1 if not found.
Ex: var a = 8Hello world!9;
document.write(a.indexOf(8w9))
UNIT VI
[May/June 2015]
1. What is the use of focus and blur events?
The important events associated with textbox and password elements are onfocus and
onblur.
onfocus is when we give a focus to an element by clicking on it, makes it the active
element.
onblur is when something loses focus by clicking on tabbing out of it, or doing
something that makes another element the active element.
2. What is the use of navigator object?
The Navigator object represents the particular browser and allows script functions to access
information about the browser being used to access the document. The Navigator object
provides information about the browser that the user is currently using. All the properties are
read-only and cannot be dynamically changed.
[May/June 2016]
1. What are mouse events. Mention mouse events?
Prof. K Adisesha
Java script programs have the ability to track mouse movement and button clicks as they
relate to the web page and controls inside.
List of Mouse events are:
1.mousedown 4.mousemove
2.mouseup 5.mouseout
3.mouseover 6.click 7.dbclick
[May/June 2017]
1. What is an event and event handler?
Event: An event is something that triggers a specific action in the browser.
Event handler: An event handler is a java script code that is designed to run each time a
particular event occurs.
UNIT V
[May/June 2015]
1. What is DHTML and explain?
DHTML stands for Dynamic Hyper Text Markup Language. DHTML is not a language or a
web standard. DHTML is a term used to describe the technologies used to make web pages
dynamic and interactive.
2. What is XML?
The eXtensible Markup Language is a text document used mainly for distributing the
data on internet between different applications. It9s a structured document for storing and
transporting the data, mainly used for the interchanging the data on internet.
[May/June 2016]
1. What do you mean by relative positioning?
Relative positioning places the element in a position relative to the element where it is
defined within the document. This type of positioning is used to control the way elements
appear in relation to other element in the document.
Prof. K Adisesha
[May/June 2017]
1. What is DTD? Mention its types.
A DTD is a Document Type Definition. A DTD defines the structure and the legal
elements and attributes of an XML document.
Types of DTD :
1.DTD <!DOCTYPE> 4. DTD Elements
2.Internal and External DTD 5.DTD Attributes
3.DTD Entities 6.DTD Examples
2. What is XML schema?
An XML Schema describes the structure of an XML document. The XML Schema
language is also referred to as XML Schema Definition (XSD). The purpose of an XML
Schema is to define the legal building blocks of an XML document.
1. the elements and attributes that can appear in a document.
2. the number of (and order of) child elements.
3. data types for elements and attributes.
4. default and fixed values for elements and attributes.
[May/June 2018]
1. What do you mean by namespaces?
A namespace is used as additional information to differentiate similar functions, classes,
variables etc. with the same name available in different libraries. Using namespace, we can
define the context in which names are defined. In essence, a namespace defines a scope.
2. What is XSLT style sheet?
XSLT is an xml based language for transforming XML documents into other XML or HTML
or XHTML documents. XSLT stands for eXtensible Styles Language Transformations.
[May/June 2019]
1. What do you mean by absolute positioning of an element?
Absolute positioning is one way that an element can be positioned with CSS. If an element is
positioned absolutely, the box of an element is taken out completely from the document9s flow,
it is placed in relation to its containing block.
Prof. K Adisesha
2. Explain the basic table tags with different attributes with example?
Basic table tags:
There are three basic components of any table.
Table:<table>
Table row:<tr>(<tr> is always enclosed within <table>).
Table(data)cell:<td>(<td> is always enclosed within <tr>).
Example:
<table border==1=>
<tr>
<td>Row 1 Cell 1</td>
<td>Row 1 Cell 2</td>
<td>Row 1 Cell 3</td>
Prof. K Adisesha
</tr>
<tr>
<td>Row 2 Cell 1</td>
<td>Row 2 Cell 2</td>
<td>Row 2 Cell 3</td>
</tr>
</table>
Table Headers(<th>): Table heading can be defined using <th> element. This
tag will be put to replace <td> tag which is used to represent actual data.
Example:
<table border==1=>
<tr>
<th>Name</th>
<th>Class</th>
</tr>
<tr>
<td>Monika</td>
<td>I BCA</td>
</tr>
</table>
Table with border attribute: To display a table with border we need to specify
the border attribute. The tags to add a border to a table is border==X=. X is
replaced with the size of the border we want ranging from 0 to 1000.
Example:
<table border==5=> // table with border value is 5
<tr>
<th>Name</th>
<th>Class</th>
</tr>
<tr>
<td>Monika</td>
<td>I BCA</td>
</tr>
</table>
Table width: Table width specifies the width for the entire table. To specify the
width, we will need to add the lines width==X= to the <table> tag.
Example:
<table width==300= border==2=> Prof. K Adisesha
<tr> <td> Cell 1 </td> Cell 2 </td> </tr>
<tr> <td> Cell 3 </td> Cell 4 </td> </tr>
</table>
3. What is the role of web server? Explain about Apache and IIS web servers.
The role of web servers is:
1. Web servers: the computer or the program have a vital role on the internet.
The server machine hosts the web site while the server program helps deliver
the web pages and their associated files like images and flash movies.
2. The process of loading a web site/page in a web browser starts with the user
either entering the URL in the address bar or clicking on a link.
3. The browser broke the URL into three parts:
The protocol(<http=)
The server name(<www.irctc.co.in=)
The file name(<index.html=)
Apache Http Server:
The input tag is the most commonly used tag within HTML forms. It
allows to specify various types of user input fields such as text, radio
buttons, checkboxes etc.
The <input/> tag is used to define the controls for the form.
The controls are the data fields or selectable options that allows the user
Prof. K Adisesha
to enter information into the form.
1. Button: This allows buttons to be included in the form that perform tasks
other than submitting or resetting the form.
3. Reset: This creates a button that automatically resets form control to their
initial values.
7. Password: This denotes a text field where the content is masked, such as
password fields.
8. File: This allows the user to select of files on their computer for submission
to the server.
Prof. K Adisesha
Ex: <input type==file= name==fileupload= />
5. What are the list in XHTML and different types of lists supported in
XHTML with an example? Give an example to implement various types of
lists.
Lists are frequently used for products offered by the site, or members currently
on the site, or form controls.
Example: <list>
<item> item text </item>
</list>
Different types of lists are:
1. Unordered list:
It is used to group a set of related items not in a particular order.
Each bullet point or line we want to write should then be contained
between opening <li> tags and closing </li>tags
We should always close the <li> and <ul> elements.
Example:
<html>
<head>
<title> Unordered list </title>
</head>
<body>
<h4> My Grocery List</h4>
<ul>
<li>Sugar</lis>
<li>Eggs</lis>
<li>Rice </lis>
</ul>
</body>
</html>
2. Ordered list:
Used to group a set of related items in a specific order.
Prof. K Adisesha
The ordered lists use the <ol> tag to delimit the entire list and the list item
<li> tag to delimit each individual items.
Example:
<html>
<head>
<title> Ordered list </title>
</head>
<body>
<h4> IT companies List </h4>
<ol>
<li>TCS</lis>
<li>Infosys</lis>
<li>Wipro</lis>
</ol>
</body>
</html>
3. Definition list:
Used to display name/value pairs such as terms and definitions.
Definition lists are contained inside the <dl> element.
The definition list is a special kind of list for providing terms followed by
a short text definition or description for them.
Example:
<html>
<head>
<title> Definition list </title>
</head>
<body>
<dl>
<dt> html </dt>
<dd> the root element in every HTML document </dd>
<dt> head </dt>
</dl>
</body>
</html>
[May/June 2016]
1. What is DNS? Explain domain andKsubdomain
Prof. Adiseshawith suitable examples.
Domain Name System [DNS]:
DNS is a database system that translates a computer9s fully qualified domain
name into an IP address. The domain name system is used to resolve human
readable hostnames, such as www.amazon .com, into machine readable IP
addresses, such as 207.171.166.48.
DNS also provides other information about domain names, such as mail
services.
Domain:
The COM, ORG, EDU and UK portions of these domain names are
called the top-level domain or first-level domain.
Within every top-level domain there is a huge list of second level domain.
Example: yahoo, msn, Microsoft, etc..,
Every name in the COM top level domain must be unique, but there can
be duplication across domains.
Example: yahoo.com and yahoo.org
Sub-domains:
Sub-domains are the third level domains that are used to organize the web
site content in systematic manner. They are just like folders under the
root directory. But they will have a special URL to access.
Example:
http://www.yoursite.com is the regular URL without a sub-domain.
http://products.yoursite.com is an URL with sub-domain <products=.
Here the:
com is the first level domain.
your site is the second level domain.
products is the third level domain.
2. What is a frame? Explain <frame> and <frameset> tags with its attributes
and examples?
Frame:
Frames allow a web page to be divided into several independent sections.
A page using frames is actually made up of several .html files.
There is one file for each frame on the page and one additional file that
contains the frameset information
5. What is form? What are the major attributes of the form? Explain form
components with example.
Form:
A frame is simply an area that can contain form fields.
Prof. the
Form fields are objects that allows K Adisesha
visitors to enter information
Example: text boxes, drop-down menus or radio buttons.
<form> ….</form>
2. Method: The method attribute tells the browser how to send the form
content when we submit the form
Example:
If the method value is <get= then it looks like this :
<form action==http://www.skyword.com//login.java=method==get=>
In this case, the form data will be sent through the URL.
1. Buttons:
Example:
<p>
</p>
</form>
2. Images:
Example:
</form>
3. Labels:
Example:
<form name>
</form>
[May/June 2017]
1. What are the different levels of headings in HTML?
Any document starts with a heading. We can use different sizes for the
headings.
XHTML supports six levels of headings, which use the elements
<h1>,<h2>,<h3>,<h4>,<h5>, and <h6>. While displaying any headings,
browsers adds one line before and after that headings.
Each headings uses a large, usually bold characters formatting style to
identify itself as a heading.
Prof. K Adisesha
Example:
<body>
<h1> This is heading 1 </h1>
<h2> This is heading 2 </h2>
<h3> This is heading 3</h3>
<h4> This is heading 4</h4>
<h5> This is heading 5</h5>
<h6> This is heading 6 </h6>
</body>
[May/June 2018]
MENTIONED ABOVE QUESTIONS ARE REPEATED
[May/June 2019]
1. Explain any 5 network protocol?
UNIT II
Prof. K Adisesha
[May/June 2015]
1. What are the different levels of CSS? Explain with examples.
There are three levels of CSS they are:
1. Inline Styles:
It is possible to create CSS styles that only work for the single tag it is
defined for. Single tag CSS is used when the style is used in a single
place on the entire site.
The inline styles are applied to each individual element using style
attribute of the tag.
Applying style to each individual element increases the code and it is
difficult to maintain.
Example:
<b style==font size:16px;=> Web Programming </b>
In the above code, we have used style attribute for <b>(bold) tag. This
tells the browser to display <Web Programming= in bold and font size 16px.
2. Internal or Document Styles:
The internal or document level styles are used to define the style for
whole page. This works only for the page it is defined.
To apply internal CSS, we need to put all CSS rules in the
<head>….<//head> part of the XHTML document and enclosed it with
<style type==text/css=>….</style> tags
Example:
<head>
<style type==text/css=>
h1 {color:red;}
p {color:yellow;}
body {background-color: black;}
</style>
</head>
3. External Styles:
External style is used more than a single page. Adding styles that are
defined once for the entire site.
The external style sheets can be defined for entire web pages by simply
writing the CSS definition in a plain text file(file with extension .css) that
is referred to form each of the pages in the web site.
To include one or more style sheets into the XHTML document we can
use the <link> tag Prof. K Adisesha
Example:
<link rel==stylesheet= type==text/css= href==/style.css=/>
2. Class selectors: Class selectors can used to select any XHTML element that
has a class attribute, regardless of their position in the document tree.
The class selectors are created by a period followed by the class name.
8. Pseudo – classes : Pseudo classes are used when we may want to style
something where there is no CSS selector available, like the state of a
hyperlink (eg.active or visited).
[May/June 2016]
1. What is CSS? What are the advantages and disadvantages of using CSS
in XHTML?
CSS: CSS (cascading style sheet) is a language that applies style on a HTML
document and its element to change the look and feel and is usually stored in
separate .css style sheet which can be re used for all the web pages.
Advantages of CSS:
CSS saves time: we can write CSS once and then reuse same sheet
in multiple HTML pages.
Pages load later: if we are using CSS, we do not need to write
HTML tag attributes every time. Just write one CSS rule of a tag
and apply to all the occurrence of that tag. So less code means
faster download time.
Easy maintenance: to make global change, simply change the
style, and all elements in all the web pages will be updated
automatically.
Smaller file size: separating content from presentation helps keep
Prof. K Adisesha
HTML file sizes down and improves page loading times.
Consistency: with CSS it is easy to keep a consistent look
throughout the website.
Accessibility: having content separated from presentation is a great
help t people with viewing disabilities who often benefits from
well structured HTML to understand the page.
Design without tables: with CSS we can position any elements
exactly where we want without using tables.
Superior styles to HTML: CSS has a much wider array of
attributes than HTML so we can give far better look to the HTML
page in comparison of HTML attributes.
Multiple device compatibility: style sheets allow content to be
optimized for more than one type of device.
Global web standards: it is a good idea to start using CSS in all
the HTML pages to make them compatible to future browsers.
Disadvantages of CSS:
[May/June 2017]
MENTIONED ABOVE QUESTIONS ARE REPEATED
[May/June 2018]
1. Differentiate <span> and <div> tags with examples.
<div> tag:
div(short for division) divides the content into individual sections. Each
section can then have its own formatting, as specified by the CSS. Div is
a block-level container, meaning that there is a line feed after the </div>
tag.
The XHTML div tag is used for defining a section of the web page. With
the div tag, we can group large sections of XHTML elements together
and format them with CSS.
Div tag is used with block level content.
Example:
div.relative {
position: relative; Prof. K Adisesha
left: 30px;
border: 3px solid #73AD21;
}
<span> tag:
The XHTML <span> tag is used for grouping and applying styles
to inline elements.
Span tag is used with inline elements.
The span tag goes into a finer level, so we can span to format a
single character if needed.
Example:
<p>My mother has <span style="color:blue">blue</span> eyes.</p>
Class selectors:
Class selectors can used to select any XHTML element that has a class
attribute, regardless of their position in the document tree.
The class selectors are created by a period followed by the class name.
Example:
<body>
<p class==big=>this is some <em>text</em></p>
<p> this is some text </p>
<ul>
<li class==big=> list item </li>
<li> list item </li>
<li> list <em> item </em></li>
</ul>
</body>
ID selectors:
ID selectors is an individually identified selectors to which a specific
style is declared.
Using the ID attribute the declared style can then be associated with one
and only one XHTML element per document as to differentiate it from all
other elements.
ID selectors are created by a character # followed by the selector9s name
Prof.#333}
#navigation {width: 12em; color: K Adisesha
1. Content Area:
the innermost part of the box is the xhtml element itself or content,
such as <<div>=,=<p>=,=<h1>=,=<ul>=….etc.
The CSS width and height property defines the width and height of
this element.
Example:
CSS code:
P {width:100px; height:50px}
XHTML code:
<p> this is content area </p>
2. Padding:
3. Border:
The middle layer in the box model is the element9s border. The
space used by the border in the box model is the thickness of the
border.
The border outlines the visible portion of the element.
Example:
P {border: 5px solid #EFD5B4;}
The above code add a solid 5 pixel thick border with #EFD5B4 color
4. Margin:
Margin is the space just outside the border. The margin completely invisible.
It has no background color, and will not contain any elements behind it.
Example:
P {margin: 30px;}
[May/June 2019]
MENTIONED ABOVE QUESTIONS ARE REPEATED
UNIT III
[May/June 2015]
5. Explain the various looping statements in javascript.
The various looping statements in javascript are:
While loop: In a while loop, a code block is executed if a condition is
true and executes as long as that condition remains true.
Syntax:
While(condition)
{
Code to be executed Prof. K Adisesha
}
Example:
<script type==text/javascript=>
i=1;
while(i<11){
document.write(i+=x4==+(i*4)+=<br/>=);
i++;
}
</script>
do…while loop: A do while loop executes a block of code once and then
checks a condition. As long as the condition is true it continues to loop.
Syntax:
do{
code to be executed
}while(condition)
Example:
<script type==text/javascript=>
i=12;
do{
document.write(i+=x4==+(i*4)+=<br/>=);
i++;
}
while(i<11)
</script>
for loop: The for statement executes a block of code a specified number
of times.
Syntax:
Prof. K Adisesha
for(startingValue;condition;iterationValue){
Javascript statements that we want to execute repeatedly
}
Example:
<script type==text/javascript=>
for(i=0;i<11;i++){
document.write(i+=x4==+(i*4)+=<br/>=);
}
</script>
6. Create a form for student information. Write a java script code to find
total, average, result and grade.
<?xml version = <1.0= encoding==ISO-8859-1=?>
<!DOCTYPE html PUBLIC=.//W3C//DTD XHTML 1.0 Transitional//EN=
<http://www.w3.org/TR/xhtml1/DTD/xhtml-transitional.dtd=>
<html xmlns=http://www.w3.org/1999/xhtml>
<head>
<title>Student Data Example</title>
<script type = <text/javascript=>
function showResults(){
var name=document.getElementById(<name=).value;
var cls=document.getElementById(<class=).value;
var marks1=parseInt(document.getElementById(<sub1=).value);
var marks2=parseInt(document.getElementById(<sub2=).value);
var marks3=parseInt(document.getElementById(<sub3=).value);
var total=marks1+marks2+marks3;
var avg=total/3;
var grade, result;
if(avg>=60){
Prof. K Adisesha
grade==A=;
result==First Class=
}
else if(avg<60 && avg>=50){
grade = <B=;
result = <Second Class=
}
else if(avg<50 && avg>=40){
grade = <C=;
result = <Third Class=
}
else {
grade = <D=;
result = <Fail=;
}
document.write("<body bgcolor=pink>"); document.write("<h2>Student Marks
Report </h2>"); document.write("<hr>");
document.write(<<b>Name :=+name+=</b><br/><br/>=);
document.write(<<b>Class :=+cls+=</b><br/></br>=);
document.write(<<b>Total Marks :=+total+=</b><br/></br>=);
document.write(<<b>Average :=+avg+=</b><br/></br>=);
document.write(<<b>Grade:=+grade+=</b><br/></br>=);
document.write(<<b>Result :=+result+=</b><br/></br>=); } </script>
</head>
<body>
<form>
<table border==5=>
<tr><th>Student Details</th></tr>
<tr>
Prof. K Adisesha
<td> Student Name: </td>
<td> <input type==text= id = <name=/></td>
</tr>
<tr>
<td>Subject1 Marks</td>
<td><input type = <text= id = <sub1=/ ></td>
</tr>
<tr>
<td> Subject2 Marks</td>
<td>input type = <text= id = <sub2=/></td>
</tr>
<tr>
<td>Subject3 Marks</td>
[May/June 2016]
1.Explain screen output and keyboard input methods in java script.
Methods to show output:
1.document.write() or document.writeln(): These two methods is used for
displaying text on a web page.
Example for write method:
<script type==text/javascript=> Prof. K Adisesha
document.write(<<pre>Line 1=);
document.write(<Line 2</pre>=);
</script>
Example for writeln method:
<script type==text/javascript=>
document.writeln(<<pre>Line 1=);
document.writeln(<Line 2</pre>=);
</script>
2.window.alert(): The alert method is part of window object. The alert()
method show the message in a small message box. This method is used to send
a warning to the user or alert him or her to do something.
Example:
<script type==text/javascript=>
An array is a special variable, which can hold more than one value at a time.
Creating an Array. Using an array literal is the easiest way to create a
Javascript Array.
Using the Javascript keyword new, can create a array.
1. yes or no
2. ON or OFF
3. positive or negative
4. true or false
4.Undefined type: The undefined type refers to those variables or object
properties that are either undefined or do not exist.
Example: var MyAge;
5.Null type: The null type indicates an empty value. When a variable is
assigned the value null, its type becomes null. A null type variable is a
placeholder that represents nothing.
Example: var MyAge=null;
[May/June 2018]
1.Write a java script program to implement all string operations?
<html>
Prof. K Adisesha
<body>
<h1>String Operation Program</h1>
<p id==demo=></p>
<script>
var txt==String Method=;
var str==Please locate where 8locate9 occurs=;
var pos=str.indexOf(<locate=);
var pos=str.search(<locate=);
var str==Apple,Banana,Kiwi=;
var res=str.slice(7,13)
document.getElementById(<demo=).inner HTML=txt.length;
document.getElementById(<demo=).inner HTML=pos;
document.getElementById(<demo=).inner HTML=pos;
document.getElementById(<demo=).inner HTML=res;
</script>
</body>
</html>
2.What is function give the general syntax of a java script function with
example.
A function is series of commands that either calculates a value or performs an
action. It consists of function name, parameters, the values passed to the
function and the set of commands that run when the function is called.
The general syntax of a Javascript function is:
function functionName (parameters) {
Javascript commands
}
where,
functionName = name of the function
Prof. K Adisesha
parameters = values sent to the functions
Javascript commands = commands that run when the function is called or used
Example:
<html>
<head>
<title>Function Demo</title>
<script type==text/javascript=>
function isEven(num){
if(num%2==0){
return num;
}
}
function printMessage(num){
if(num>1){
document.write(num+==);
}
}
var evenNum;
document.write(<Even Numbers:=);
for(i=1;i<=20;i++){
evenNum=isEven(i);
printMessage(evenNum);
}
</script>
</head>
</html>
3.Explain pattern matching using regular expression in java script?
Prof. K Adisesha
1. The match() Method: This method is used to search for a pattern of
characters in a string and returns an array where each element of the array
contains each matched pattern that was found. If no match is found, returns null.
With the g flag, match() search globally through the string for all matching
substrings.
Example:
<script type==text/javascript=>
var matchArray=new Array();
var string==I love the smell of clover=
var regex=/love/g;
matchArray=string.match(regex);
</script>
2. The search() Method: This method is used to search for a pattern of
characters within a string, and returns the index position of where the pattern
was found in the string. The index starts at zero. If the pattern is not found,-1 is
returned.
Example:
<script type==text/javascript=>
var myString==I love the smell of clover=
var regex=/love/;
var index=myString.search(regex);
document.write(<Found the pattern=+regex+=at position=+index+=<br/>=);
</script>
3.The replace() Method: This method is used to search for a string and replace
the string with another string. The i modifier is used to turn off case sensitivity
and the g modifier makes the replacement global. The replace() method is also
used with the grouping metacharacters.
Example:
<script type==text/javascript=>
var myString==Tommy has a stomatch ache=
var newString=myString.replace(regex,=Mom=);
Prof. K Adisesha
document.write(newString+=<br/>=);
</script>
4.The split() Method: This method splits a single text string into an array of
substrings. If the word in a string are separated by commas, then the comma
would be the delimiter and if the words are separated by colons, then the colon
is the delimiter. The delimiter can contain more complex combinations of
characters if regular expression metacharacter is used.
Example:
<script type==text/javascript=>
var splitArray=new Array();
var string==apples:grapes:banana:plums:oranges=;
var regex=/:/;
splitArray=string.split(regex);
for(i=0;i<splitArray.length;i++){
document.write(splitArray[i]+=<br/>=);
}
</script>
4.Write a java script program to find factorial of a number.
<html>
<head>- - - - -</head>
<script type==text/javascript=>
function factorial(n)
{
If (n==0)
return 1;
else
return n*factorial(n-1);
}
Var num;
Prof. K Adisesha
num=parseInt(window.prompt(<Enter Number=));
window.alert(<Factorial of a number <+num+=is:=+factorial(num));
</script>
</html>
[May/June 2019]
1.Write a java script code to evaluate mathematical expression and display the
result.
<?xml version = <1.0= encoding==ISO-8859-1=?>
<!DOCTYPE html PUBLIC=.//W3C//DTD XHTML 1.0 Transitional//EN=>
http://www.w3.org/TR/xhtml1/DTD/xhtml-transitional.dtd>
<html xmlns==http://www.w3.org/1999/xhtml=>
<head>
<script type="text/javascript">
function Evaluate()
{
var enteredExpr=document.getElementById("expr").value;
document.getElementById("result").value=eval(enteredExpr); } </script>
</head>
<body bgcolor=cyan>
<h1 align=center> Evaluating Arithmetic Expression</h1>
<hr>
<form name = <myForm=>
Enter any Valid Expression :<input type="text" id="expr"/><br><br> <input
type="button" value="Evaluate" onclick="Evaluate()"/> <br><br>
Result of the Expression : <input type="text" id="result"/>
</form>
</body>
</html>
UNIT VI Prof. K Adisesha
[May/June 2015]
1.Write a short note on DOM?
The Document Object Model (DOM) is an application programming interface
(API) for XHTML documents. The DOM represents a document as a
hierarchical tree of nodes, allowing developers to add, remove and modify
individual parts of web page.
The DOM allows a developer to access the document via a common set of
objects, properties, methods, events and to alter the contents of the web page
dynamically using scripts.
Levels of DOM:
1. DOM 0: All browsers have a Document Object Model, which gives you
access to various parts of the document. The Level 0 DOM is the oldest of
them. It was implemented in Netscape 2 and 3 and still works in all java script
browsers. It gives easy access to forms and their elements, images and links.
2. DOM 1: The initial DOM standard, known as DOM Level 1, was
recommended by W3C in 1998. DOM Level 1 provided a complete model for
2.Mouse Events: The seven mouse events listed in the following table all relate
to actions taken by the user using the mouse. Java script programs have the
ability to track mouse movement and button clicks as they relate to the web
pages and controls inside.
Event name Event handler Applicable tags
name/Tag attribute
Mousedown onmouse down Most of the tags support
mouse events
Mouseup onmouseup Most of the tags support
mouse events
3.Key Events: In a few situations where we might want to use keyboard events,
this type of events handling is more commonly found in Windows applications.
There are three main key events in HTML.
Event name Event handler Applicable tags
name/Tag attribute
keypress onkeypress <body>,form elements
Keydown onkeydown <body>,form elements
keyup onkeyup <body>,form elements
Prof. K Adisesha
4.XHTML Events: It means any events that do not belong in the user interface,
mouse, or key event categories. Some XHTML events are triggered directly by
the user action, while others are fired only as in indirect result of a user action.
Event name Event handler Fires When Applicable tags
name/Tag
attribute
load onload Browser finishes <body>
loading
document
unload onunload Browser about to <body>
unload document
submit onsubmit Form about to <form>
submitted
reset onreset Form about to be <form>
reset
select onselect Text box <input>,<textarea>
contents selected
change onchange Form control <input>,<textarea>,<select>
contents changed
[May/June 2016]
1.Write a java script code to find sum of N natural numbers using user defined
functions.
<?xml version==1.0=encoding==ISO-8859-1=?>
<!DOCTYPE html PUBLIC=//W3C//DTD XHTML 1.0 Transitional//EN=
http://www.w3org/TR/xhtml1/DTD/xhtml1-transitional.dtd=>
<html xmlns==http://www.w3org/1999/xhtml=>
<head>
<title>Sum of Natural Numbers</title>
<script type==text/javascript=>
function sum(){
var num=window.prompt(<Enter the value of N=);
var n=parseInt(num);
var sum=(n*(n+1))/2;
Prof. KNumber
window.alert(<Sum of First <+n+=Natural Adisesha
is: =+sum);
}
</script>
</head>
<body>
<form>
<input type==button=value==Find Sum of Natural Numbers=onClick==sum()=/>
</form>
</body>
</html>
[May/June 2017]
1.Explain XHTML events?
XHTML Events: It means any events that do not belong in the user interface,
mouse, or key event categories. Some XHTML events are triggered directly by
the user action, while others are fired only as in indirect result of a user action.
Event name Event handler Fires When Applicable tags
name/Tag
attribute
load onload Browser finishes <body>
loading
document
unload onunload Browser about to <body>
unload document
submit onsubmit Form about to <form>
submitted
reset onreset Form about to be <form>
reset
select onselect Text box <input>,<textarea>
contents selected
change onchange Form control <input>,<textarea>,<select>
contents changed
Load event: The onload event handler is called when the HTML document
Prof. K Adisesha
finishes loading into the browser window.
Unload event: The unload event fires when a browser is leaving the current
document.
Submit event: The submit event occurs just before a form is submitted to a web
server.
Reset event: The reset event occurs when the reset button on a form is clicked.
Select event: The select event occurs when the user selects text inside a text
box or text area.
Change event: The change event occurs when a control loses focus and its
value has been altered.
[May/June 2018]
1.Write a java script program to implement keyboard events?
<html>
<head>
<script>
[May/June 2019]
MENTIONED ABOVE QUESTIONS ARE REPEATED
UNIT V
[May/June 2015]
1.Write the differences between XML schema and DTD?
<body>
<div style = "position:fixed; left:80px; top:20px; background-color:yellow;">
This div has fixed positioning.
</div>
</body>
</html>
4.Static positioning: The default or 'natural' position of block elements on the
page. This is the normal positioning scheme in which elements are positioned as
they occur in the normal document flow.
Example:
#box-1 {
width: 150px;
}
#box-2 {
width: 150px;
} Prof. K Adisesha
#box-3 {
width: 150px;
}
Prof.
1.Elements can be simple or complex K Adisesha
type.
2.Simple type elements can only contain text. They cannot have child element
or attributes.
4.Schema developers can derive simple types by restricting another simple type.
7.By default, complex-type elements have complex content, meaning that they
have child elements.
9. Complex types can be limited to having no content, meaning they are empty,
but they have attributes.
10.Complex types may have mixed content-a combination of text and child
elements.
[May/June 2016]
1.Write a note on XML name spaces.
In XML, a namespace is used to prevent any conflicts with element
names. Because XML allows to create our own element names, there9s
always the possibility of naming an element exactly the same as one in
another XML document, this is possible when they never use both
documents together.
We can create a name conflict by creating a namespace for the XML
document. To use XML namespace, elements are given qualified
names. These qualified names consists of two parts:
1.The local part is the same as the names we have been given
elements.
2.The namespace prefix specifies to which namespace this name
belongs.
Ex: <bk:books xmlns:bk==http://www.mysite.com=/>
Prof. K Adisesha
Where, xmlns stands for XML Namsespace.
bk is the namespace prefix.
http:// www.mysite.com is the URL of the namespace.
Example:
<?xml version==1.0=encoding==UTF-8=?>
<!DOCTYPE books SYSTEM <bookrules dtd=>
<bk:books xmlns:bk==http://www.musite.com=>
<bk:book type==programming=>
<bk:title>Web programming</bk:title>
<bk:author>Srikanth.S</bk:author>
</bk:book>
</bk:books>
[May/June 2017]