50% found this document useful (2 votes)
411 views

Css

The document contains details about a question paper for the 5th semester Diploma in Engineering program. It includes instructions for students, with 5 compulsory questions worth a total of 70 marks. Question 1 has 10 marks and asks students to attempt any 5 parts explaining dot syntax, logical operators, identifying browsers, initializing an array, using the 'with' statement, and session cookies. Question 2 has 12 marks and asks students to attempt any 3 parts explaining the prompt method, calculating average marks and assigning grades, and displaying all window object properties. Question 3 also has 12 marks and asks students to attempt any 3 parts differentiating array methods, counting vowels in a string, and explaining the eval() function.

Uploaded by

Hrahaal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
50% found this document useful (2 votes)
411 views

Css

The document contains details about a question paper for the 5th semester Diploma in Engineering program. It includes instructions for students, with 5 compulsory questions worth a total of 70 marks. Question 1 has 10 marks and asks students to attempt any 5 parts explaining dot syntax, logical operators, identifying browsers, initializing an array, using the 'with' statement, and session cookies. Question 2 has 12 marks and asks students to attempt any 3 parts explaining the prompt method, calculating average marks and assigning grades, and displaying all window object properties. Question 3 also has 12 marks and asks students to attempt any 3 parts differentiating array methods, counting vowels in a string, and explaining the eval() function.

Uploaded by

Hrahaal
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Scheme – I

Question Paper Profile


Program Name : Diploma in Engineeering Group
Program Code : CO / CM / CW / IF Semester :
Fifth Course Title : Clint Side Scripting Language (Elective)
Marks : 70 22519
Time: 3 Hrs.

Instructions:
(1) All questions are compulsory.
(2) Illustrate your answers with neat sketches wherever necessary.
(3) Figures to the right indicate full marks.
(4) Assume suitable data if necessary.
(5) Preferably, write the answers in sequential order.

Q.1) Attempt any FIVE of the following. 10 Marks


a) State the use of dot syntax in JavaScript with the help of suitable example.
Ans: -
i. The Properties and methods associated with any object can be accessed by using
the object name with a dot syntax e.g. user.fname, user.lname and
user.fullName().
ii. You use dot syntax to describe to JavaScript how to interact with the object,
properties, functions and event in an application.
Example:-
<!DOCTYPE html>
<html>
<head>
<title></title>
<script>
var student =
{
fristName: "Amit",
lastName: "Gupta",
id: 12,
fullName: function()
{
return this.firstName + " " + this.lastName
}
};

1
student.class="Fifth";
document.write("Student Id= "+student.id)
document.write("<br/>")
document.write("Student Class= "+student.class)
document.write("<br/>")
document.write("Student Name= "+student.name)
</script>
</head>
<body>

</body>
</html>

b) List and explain Logical operators in JavaScript.


Ans: -

Operator Descryption Eg
&&(Logical AND Operator) If the both operands are zero then the (A && B) is true.
condition becomes true.
|| (Logical OR Operator) If any of the operands are zero then the (A || B) is true.
condition becomes true.
! (Logical NOT Operator) Use to reverses the logical state of its ! (A && B) is flase.
operand. If a condition is true then
Logical NOT operator will make false.

c) Write a JavaScript that identifies a running browser.


Ans: -

d) Write a JavaScript that initializes an array called “Fruits” with names of five fruits.
The script then displays the array in a message box.
Ans: -

e) Give syntax of and explain the use of “with” statement/clause in JavaScript using
suitable example.
Ans: -
f) Enlist and explain the use of any two Intrinsic JavaScript functions.
Ans: -

2
g) State and explain what is a session cookie?
Ans: -
1. A session cookie contains information that is stored in a temporary
memory location and then subsequently deleted after the session is
completed or the web browser is closed. This cookie stores information
that the user has inputted and tracks the movements of the user within
the website.
2. A session cookie is also known as transient cookie.
Q.2) Attempt any THREE of the following. 12 Marks
a) Write syntax of and explain prompt method in JavaScript with the help of suitable
example.

Ans: - <!DOCTYPE html>


<html>

<head>
<title>
Window prompt() Method
</title>
</head>

<body style="text-align: center;">


<h1 style="color:green;">
GeeksforGeeks
</h1>
<h2>
Window prompt() Method
</h2>

<button onclick="geek()">
Click me!
</button>
<p id="g"></p>

<script>
function geek() {
var doc = prompt("Please enter some text",
"GeeksforGeeks");
if (doc != null) {
document.getElementById("g").innerHTML =
"Welcome to " + doc;
}
}
</script>
</body>

</html>
1. The prompt() method is used to display a dialog with an optional message
prompting the user to input some text. It is often used if the user wants to input a
value before entering a page.
2. It returns a string containing the text entered by the user, or null.

3
b) Write a JavaScript program which compute, the average marks of the following
students Then, this average is used to determine the corresponding grade.
Student Name Marks
Advait 80
Anay 77
Manyata 88
Saanvi 95
Saachi 68

The grades are computed as follows:


Range Grade
<60 F
<70 D
<80 C
<90 B
<100 A
c) Write a JavaScript that displays all properties of window object. Explain the code .
Ans: -
d) Write a JavaScript function that checks whether a passed string is palindrome or not.
Ans: -
html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<title>Check Palindrome with JavaScript Program</title>
<style>
input{
padding: 10px;
}
</style>
<script>

function myFunction()
{
//get the value from textbox
var str = document.getElementById('txtbox').value;

//call checkPalindrome() and pass str


var result = checkPalindrome(str);
alert('The Entered String "'+str +'" is "'+result+'"');
}

function checkPalindrome(str)
{
var orignalStr;

//lowercase the string


str = str.toLowerCase();

//store the str in orignalStr for future use


orignalStr = str;

//reverse the entered string


str = str.split(''); //split the entered string
str = str.reverse(); //reverse the order

4
str = str.join(''); //then join the reverse order array values

var reverseStr = str;

//finally check both the Original string stored in orignalStr


//and reversed to find the palindrom
if(orignalStr == reverseStr){
return 'Palindrome'; // return "Palindrome" if true
}else{
return 'Not Palindrome';
}
}
</script>
</head>
<body>
<form action="http://www.tutorialsmade.com/" method="get">
<h3>JavaScript Palindrome Program from Tutorialsmade.com</h3>
<h4><a href="">Find the program here</a></h4>
<input type="text" id="txtbox" placeholder="Enter String" />
<input type="button" onclick="myFunction()" value="Check Palindrome" />
</form>
</body>
</html>

Q.3) Attempt any THREE of the following. 12 Marks


a) Differentiate between concat() and join() methods of array object.
Ans: -

b) Write a JavaScript function to count the number of vowels in a given string.


Ans: -
<html>
<head>
<title>find number of vowels in a string in JavaScript</title>
<script type="text/javascript">
function GetVowels() {
var str = document.getElementById('txtname').value;

5
var count = 0, total_vowels="";
for (var i = 0; i < str.length; i++) {
if (str.charAt(i).match(/[a-zA-Z]/) != null) {
// findVowels
if (str.charAt(i).match(/[aeiouAEIOU]/))
{
total_vowels = total_vowels + str.charAt(i);
count++;
}
}
}
document.getElementById('vowels').value = total_vowels;
document.getElementById('vcount').value = count;
}
</script>
</head>
<body>
<div >
<table border="1px" cellspacing="0" width="30%" style="background-color: #FF6600; color:White">
<tr><td colspan="2" align="center"><b>Get Vowels from String</b></td></tr>
<tr>
<td>Enter Text :</td>
<td><input type='text' id='txtname' /></td>
</tr>
<tr>
<td>Vowels Count :</td>
<td><input type='text' readonly="readonly" id='vcount'/></td>
</tr>
<tr>
<td>Total Vowels :</td>
<td><input type='text' readonly="readonly" id='vowels' /></td>
</tr>
<tr>
<td></td>
<td><input type='button' value='Get Vowels Count' onclick="javascript:GetVowels();" /></td>
</tr>
</table>
</div>
</body>
</html>

6
c) Write a JavaScript that find and displays number of duplicate values in an array.
Ans: -
d) Write a function that prompts the user for a color and uses what they select to set the
background color of the new webpage opened .
Ans: -
<!DOCTYPE HTML>
<html>
<head>
<title>
How to change the background color
after clicking the button ?
</title>
</head>

<body style = "text-align:center;">

<h1 style = "color:green;" >


GeeksForGeeks
</h1>

<p id = "GFG_UP" style =


"font-size: 16px; font-weight: bold;">
</p>

<button onclick = "gfg_Run()">


Click here
</button>

<p id = "GFG_DOWN" style =


"color:green; font-size: 20px; font-weight: bold;">
</p>

<script>
var el_up = document.getElementById("GFG_UP");
var el_down = document.getElementById("GFG_DOWN");
var str = "Click on button to change the background color";

el_up.innerHTML = str;

function changeColor(color) {
document.body.style.background = color;
}

function gfg_Run() {
changeColor('yellow');
el_down.innerHTML = "Background Color changed";
}
</script>
</body>
</html>

7
Q.4) Attempt any THREE of the following. 12 Marks
a) State what is a regular expression? Explain its meaning with the help of a suitable
example.
Ans: -
1. a regular expression is a pattern of characters.
2. JavaScript regular expression are object.
3. When you create a regular expression, you test the regular expression against a
string.
4. Regular expression is a series of characters between two forward slashes(/……/).
5. for e.g., the regular expression /green/ might be matched against the string, “The
green grass”.
6. if green is contained in the string, then there is a successful match.

b) Write a webpage that accepts Username and adharcard as input texts. When the user
enters adhaarcard number ,the JavaScript validates card number and diplays whether
card number is valid or not. (Assume valid adhaar card format to be nnnn.nnnn.nnnn
or nnnn-nnnn-nnnn).
Ans: -
c) Write the syntax of and explain use of following methods of JavaScript Timing Event.
a. setTimeout()
b. setInterval()
d) Develop JavaScript to convert the given character to Unicode and vice versa.
Ans: -
e) List ways of Protecting your webpage and describe any one of them.
Ans: -
1. Keep software up to date
2. Beware of error messages
3. Check your passwords
4. Avoid file uploads
5. Use HTTPS
6. Get website security tools

8
Q.5) Attempt any TWO of the following. 12 Marks
a) Write HTML Script that displays textboxes for accepting Name, middlename,
Surname of the user and a Submit button. Write proper JavaScript such that when the
user clicks on submit button
i) all texboxes must get disabled and change the color to “RED”. and with
respective labels.

ii) Constructs the mailID as <name>.<surname>@msbte.com and displays mail


ID as message. (Ex. If user enters Rajni as name and Pathak as surname mailID
will be constructed as rajni.pathak@msbte.com) .
b) Write a webpage that diplays a form that contains an input for Username and
password. User is prompted to enter the input and password and password becomes
value of the cookie. Write The JavaScript function for storing the cookie . It gets
executed when the password changes.
Ans: -

c) Write a script for creating following frame structure :


FRAME1

FRAME2 FRAME3
• FRUITS
• FLOWERS
• CITIES

Fruits, Flowers and Cities are links to the webpage fruits.html, flowers.html,
cities.html respectively. When these links are clicked corresponding data appears in
“FRAME3”.

Q.6) Attempt any TWO of the following. 12 Marks


a) Write HTML Script that displays dropdownlist containing options NewDelhi,
Mumbai, Bangalore. Write proper JavaScript such that when the user selects any
options corresponding description of about 20 words and image of the city appear in
table which appears below on the same page.
Ans: -
b) Develop a JavaScript Program to Create Rotating Banner Ads with URL Links.

9
Ans: -
c) Create a slideshow with the group of four images, also simulate the next and previous
transition between slides in your JavaScript.
Ans: -

Scheme – I
Sample Test Paper - I
Program Name : Diploma in Engineeering Group
Program Code : CO / CM / CW / IF Semester :
Fifth Course Title : Clint Side Scripting Language (Elective)
Marks
Time: 1 Hour
: 20 22519

Instructions:
(1) All questions are compulsory.
(2) Illustrate your answers with neat sketches wherever necessary.
(3) Figures to the right indicate full marks.
(4) Assume suitable data if necessary.
(5) Preferably, write the answers in sequential order.

Q.1) Attempt any FOUR. 08 Marks


a) Describe all the tokens of the following statements :
i. document.bgColor
ii. document.write()
b) Differentiate between prompt() and alert() methods.
Ans: -
c) State use of getters and setters
Ans: -
 a JavaScript object is a set of key/value pairs.
 Each pair is called a “property”.
 There are two kinds of property:
o Data property:
 this property most of us are familiar with, and is the property used
in 99% the code.
o Accessor property:

10
 Properties defined by getter and setters are known as accessor
properties.
 Accessor property generates its value dynamically when being
accessed or set.

d) State and explain any two properties of array object


Ans: -
e) Write a JavaScript that displays first 20 even numbers on the document window.
Ans: -
<html>
<head>
<title>JavaScript to print Even Numbers within a Range!</title>
<script>
function printEvenNums(){
//get the start and end range from user
var start = document.getElementById("start").value;
var end = document.getElementById("end").value;
var evenNums = "<br>Even Numbers:<br>";

for(i=start; i<=end; i++){


// let's divide the value by 2
// if the reminder is zero then it's an Even number
if(i % 2 == 0){
evenNums += i + "<br>";
}
}
//print the values
document.getElementById("result").innerHTML = evenNums;
}
</script>
</head>
<body>
<h3>JavaScript to print Even Numbers within a Range!</h3>
Start: <input type="number" min="0" id="start" value="1" />
End: <input type="number" id="end" min="1" value="20" />
<input type="button" onclick="printEvenNums()" value="Print Even Numbers" />
<div id="result"></div>
</body>
</html>

Q.2) Attempt any THREE. 12 Marks


a) Write a program to print sum of even numbers between 1 to 100 using for loop.
Ans: -
b) Write a JavaScript function to insert a string within a string at a particular position
Ans: -
c) Generate college Admission form using html form tag
Ans: -
d) State the use of following methods.

11
i. charCodeAt()
ii. fromCharCode()

Scheme – I
Sample Test Paper - II
Program Name : Diploma in Engineeering Group
Program Code : CO / CM / CW / IF Semester :
Fifth Course Title : Clint Side Scripting Language (Elective)
Marks
Time: 1 Hour
: 20 22519

Instructions:
(1) All questions are compulsory.
(2) Illustrate your answers with neat sketches wherever necessary.
(3) Figures to the right indicate full marks.
(4) Assume suitable data if necessary.
(5) Preferably, write the answers in sequential order.

Q.1) Attempt any FOUR. 08 Marks


a) Design the frameset tag for following frame layout :
FRAME1

FRAME2

FRAME3

b) State the method to put message in web browser status bar?


Ans: -
c) Construct regular expression for validating the phone number in following format
only :
(nnn)-nnnn-nnnn OR nnn.nnnn.nnnn

12
Ans: -

Q.2) Attempt any THREE. 12 Marks


a) Write a JavaScript that creates a persistent cookies of Itemnames. Write appropriate
HTML script for the same.
Ans: -
b) Write a JavaScript function to check whether a given value is valid IP value or not
Ans: -
c) Write a JavaScript program to create rollover effect for three images.
Ans: -
d) Write a JavaScript program that create a scrolling text on the status line of a window.
Ans: -

13

You might also like