0% found this document useful (0 votes)
69 views

CSS (22519)

Client Side Scripting language (22519) Unit Test Questions, Answers PDF, Subject syllabus, Subject Model Answer Paper

Uploaded by

harshdpatil677
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views

CSS (22519)

Client Side Scripting language (22519) Unit Test Questions, Answers PDF, Subject syllabus, Subject Model Answer Paper

Uploaded by

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

BHARATI VIDYAPEETH COLLEGE OF ENGINEERING

(DIPLOMA)
QUESTION BANK (Answers)

Unit Test-I

Program: - Computer Engineering Group Program Code: - CO


Course Title: -Client-Side Scripting Language Semester: - Fifth
Course Abbe &Code: -CSS (22519) Scheme: I
--------------------------------------------------------------------------------------------------
CHAPTER-1 (Basics of JavaScript Programming) (CO1)

2 MARKS
1. Explain any four features of JavaScript.

• Dynamic Typing: JavaScript is a dynamically typed language, meaning you don't need to specify data types
for variables. The type of a variable can change at runtime based on the value assigned to it.

• Object-Oriented: JavaScript supports object-oriented programming principles, allowing developers to create


objects and reuse code, making the code more modular and easier to maintain.

• Asynchronous Programming: JavaScript allows asynchronous operations using call-backs, promises, and
async/await, enabling non-blocking code execution, which is crucial for handling tasks like API calls or time-
consuming computations.

• Cross-Platform Compatibility: JavaScript can run on various platforms (browsers, servers with Node.js, and
even IoT devices), making it a versatile language for both client-side and server-side development.

2. Compare client-side and server-side scripting. (Only two)


Client-Side Scripting Server-Side Scripting
Executes in the user's browser. Executes on the web server.
Ex. JavaScript, HTML, CSS Ex. PHP, Node.js, Python, Ruby

Handles UI interactions, form Handles database operations, session management,


validation, and dynamic content and server-side logic.
updates.
Faster for user interactions; depends Slower due to server processing and network
on client's device. latency.
Less secure; code is visible and More secure; code is executed on the server and
modifiable by users. not exposed to users.
Requires browser support; limited Requires server resources; depends on server's
by client's hardware. hardware and software.

3. List types of operators in JavaScript.

•Arithmetic Operators: Used for mathematical operations like addition (+), subtraction (-), multiplication (*),
division (/), and modulus (%).

•Comparison Operators: Used to compare two values, such as equal to (==), not equal to (! =), greater than
(>), less than (<), and strict equal (===).

•Logical Operators: Used to perform logical operations, including AND (&&), OR (||), and NOT (!).

•Assignment Operators: Used to assign values to variables, like basic assignment (=), addition assignment
(+=), and multiplication assignment (*=).

• Bitwise Operators: Bit operators work on 32 bits numbers.Any numeric operand in the operation is
converted into a 32 bit number. The result is converted back to a JavaScript number
• Conditional or Ternary Operator: JavaScript includes special operator called ternary operator:? that
assigns a value to a variable based on some condition. This is like short form of if-else condition

*Free advice: Description not required

--------------------------------------------------------------------------------------------------

4 MARKS
1. Explain data types in JavaScript.
JavaScript has dynamic types. This means that the same variable can be used to hold different data types:
Example
var x; // Now x is undefined
x = 5; // Now x is a Number
x = "John"; // Now x is a String
JavaScript Strings
A string (or a text string) is a series of characters like "John Doe".
Strings are written with quotes. You can use single or double quotes.
Example
var carName1 = "Volvo XC60"; // Using double quotes
var carName2 = 'Volvo XC60'; // Using single quotes
JavaScript Numbers
JavaScript has only one type of numbers.
Numbers can be written with, or without decimals:
Example
var x1 = 34.00; // Written with decimals
var x2 = 34; // Written without decimals
JavaScript Booleans
Booleans can only have two values: true or false.
Example
var x = 5;
var y = 5;
var z = 6;
(x == y) // Returns true
(x == z) // Returns false
Undefined
In JavaScript, a variable without a value, has the value undefined. The type is also undefined.
Example
var car; // Value is undefined, type is undefined
JavaScript Arrays
• JavaScript arrays are written with square brackets.
• Array items are separated by commas.
• The following code declares (creates) an array called cars, containing three items (car names):
• Example
• var cars = ["Saab", "Volvo", "BMW"];
• JavaScript Objects
• JavaScript objects are written with curly braces {}.
• Object properties are written as name:value pairs, separated by commas.
• Example
• var person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"};
2. Compare client-side and server-side scripting.
Client-Side Scripting Server-Side Scripting
Executes in the user's browser. Executes on the web server.
Ex. JavaScript, HTML, CSS Ex. PHP, Node.js, Python, Ruby
Handles UI interactions, form Handles database operations, session management,
validation, and dynamic content and server-side logic.
updates.
Faster for user interactions; depends Slower due to server processing and network
on client's device. latency.
Less secure; code is visible and More secure; code is executed on the server and
modifiable by users. not exposed to users.
Requires browser support; limited Requires server resources; depends on server's
by client's hardware. hardware and software.
3. Write a JavaScript program to display squares of 1 to 10 numbers using while loop.
<!DOCTYPE html>
<html lang="en">

<head>
<title>Sqr of Numbers</title>
</head>

<body>
<script>
let temp = 0;
let i = 1;
while (i <= 10) {
temp = i * i;
document.write("<br>" + temp);
i++;

}
</script>
</body>

</html>

4. Write a JavaScript program to generate Armstrong number between 1 to 100.


<!DOCTYPE html>
<html lang="en">

<head>

<title>Armstrong</title>
</head>

<body>
<script>
let num;
for ( num = 1; num <= 100; num++) {
let sum = 0;
let temp = num;

while (temp > 0) {


let digit = temp % 10;
sum += digit * digit * digit;

temp = temp / 10;


}
if (sum === num) {
document.write(num);
}
}
</script>
</body>

</html>

5. Write a JavaScript program to check whether entered number is prime or not.


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
// Function to check if a number is prime
function isPrime(number) {
// A prime number is greater than 1 and divisible only by 1 and itself
if (number <= 1) {
return false; // Numbers less than or equal to 1 are not prime
}

// Check divisibility from 2 to the square root of the number


for (let i = 2; i <= Math.sqrt(number); i++) {
if (number % i === 0) {
return false; // If divisible by any number other than 1 and itself, it's not
prime
}
}

return true; // If not divisible by any other number, it's prime


}

// Example usage
const inputNumber = parseInt(prompt("Enter a number:")); // Get user input

if (isPrime(inputNumber)) {
document.write(inputNumber + " is a prime number.");
} else {
document.write(inputNumber + " is not a prime number.");
}

</script>
</body>
</html>
6. Differentiate between For-loop and For-in loop.
Feature for Loop for-in Loop
Purpose Used to iterate over a sequence Used to iterate over the
(e.g., arrays, ranges). enumerable properties of an object.
Syntax for (initialization; condition; for (variable in object) { // code }
increment) { // code }
Iteration Iterates a specific number of times, Iterates over the keys (property
usually determined by the loop names) of an object.
condition.
Use Case Ideal for looping through arrays, Ideal for iterating over the
ranges, or when you need a loop properties of an object.
with a defined start and end.
Example for (let i = 0; i < 5; i++) { for (let key in obj) {
console.log(i); } console.log(key); }
Output Type Typically used for numerical Typically used to access object
operations, where i represents the keys and their corresponding
index. values.

7. Write Java script to create person object with properties firstname, lastname, age, executor, delete
eye_color property and display remaining properties of person object.
<html>
<body>
<script>
var person = {
firstname:"John",
lastname:"Doe",
age:50,
eyecolor:"blue"
};
delete person.eyecolor; //delete person eyecolor
document.write("After delete "+ person.firstname +" "+ person.lastname +" "
+person.age +" "+ person.eyecolor);
</script>
</body>
</html>
8. Write a Java script that initializes an array called flowers with the names of 3 flowers. The script then
displays array elements.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
let flowers=["Rose","Lotus","SunFlower"];
flowers.forEach(element => {
document.write("<br>"+element);
});
</script>
</body>
</html>

9. Explain getter and setter properties in Java script with suitable example.
In JavaScript, getter and setter properties allow you to define how an object’s properties are accessed and
modified. They provide a way to control the access to an object’s properties, adding logic when getting or
setting a property value.
1. Getter (get) Properties:
• A getter allows you to define a method that is executed when the property is accessed.
• It's useful when you want to compute a value or return a value in a specific format whenever the
property is accessed.
2. Setter (set) Properties:
• A setter allows you to define a method that is executed when a property is assigned a value.
• It’s useful when you want to validate or modify the value being set to a property.
const person = {
firstName: "John",
lastName: "Doe",
get fullName() {
return `${this.firstName} ${this.lastName}`;
},
set fullName(name) {
const parts = name.split(" ");
this.firstName = parts[0];
this.lastName = parts[1];
}
};

console.log(person.fullName); // Output: John Doe


person.fullName = "Jane Smith";
console.log(person.fullName); // Output: Jane Smith

CHAPTER-2 (Array, Function and String) (CO2)

2 MARKS

1. Write syntax for defining the function.


2. Write a JavaScript to reverse the elements of array.
3. Explain the use of push and pop functions.
4. Define string? How to declare it?
5. List methods used for finding a Unicode of a character?
6. Explain objects as associative array?

4 MARKS

1. Explain the method of calling a function from HTML.


2. Write a JavaScript to convert a string to number.
3. Explain the scope of variable with the help of programming example.
4. How to initialize an array? Explain with example.
5. Differentiate between concat() and join() methods of array object.
6. How to add and sort elements in array? Explain with example.
7. Write a javascript to checks whether a passed string is palindrome or not.
8. Write a javascript function to generate Fibonacci series till user defined limit.
9. Write the use of CharAt() and indexof() with syntax and example.

CHAPTER-3 (Forms and Event Handling) (CO3)

2 MARKS

1. Explain two uses of forms.


2. Write different Mouse events.
3. Write Key events with syntax.
4. What is an event? State any two events of form.

4 MARKS

1. Describe the Form tag with attributes.


2. Design a HTML form to fill the information for registration of a student.
4. Write a JavaScript program to show use of form object and access the value related to form elements.
5. Explain following controls with syntax:
• TEXTAREA
• CHECKBOX
• RADIO
• SELECT

You might also like