0% found this document useful (0 votes)
20 views6 pages

Pyq1 FSD

Uploaded by

ntrnadamuri9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views6 pages

Pyq1 FSD

Uploaded by

ntrnadamuri9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

USN No:

III Semester B.Tech Mid Semester Examination – II


Department of Computer Science and Engineering

Course Title: Full Stack Development Course Code: 22CS/CT2305


Duration: 75 Mins. Date: 20/12/2023
Start Time: 10:00 to 11:15 am Max Marks: 40
Instructions to Candidates:
1. Answer all the five full questions.
2. Each full question carries 10 marks.

BT
Q No. Question Description Marks COs POs
Level
1) a. Develop a JavaScript program to fetch and display 5 L3 CO3 PO3
various parts of the date using ‘Date’ object.
b. Utilize JavaScript syntax to define and initialize an 5 L3 CO3 PO3
object. Explain with an example.
2) a. Make use of following html events and write JavaScript 5 L3 CO3 PO3
program with example. a) Onclick b) Onload
b. Develop a JavaScript program that uses the ‘prompt ()’ 5 L3 CO3 PO3
method to accept the number as input from user and add
5 to the same input and display the result.
3) a. Utilize JavaScript array methods to explain the 5 L3 CO3 PO5
following operations a)Push b)Pop
b. Develop a Java script programme to read two passwords 5 L3 CO3 PO5
and validate those password, If not same password, ask
user to enter password again else show password match
alert message.
4) a. Identify and brief various ‘core modules’ of node.js with 5 L3 CO4 PO12
example.
b. Develop a simple server program in Node.js that returns 5 L3 CO4 PO12
the message ‘Welcome to DSU’ to the client at port
number-8080.
***********
USN No:

III Semester B.Tech Internal Assessment -II


Computer Science and Engineering
Scheme of valuation

Course Title: FULL STACK DEVELOPMENT Course Code: 22CS2305


Duration:75 Mins. Date: 20/12/2023
Time: 10-11.15 am Max Marks: 40
Scheme:
Q.No Marks
Q. 1(a) Fetching -2.5 marks, Displaying 2.5 marks 5
// Create a new Date object
var currentDate = new Date();
// Fetch and display various parts of the date
var year = currentDate.getFullYear();
var month = currentDate.getMonth() + 1; // Months are zero-based, so add 1
var day = currentDate.getDate();
var hours = currentDate.getHours();
var minutes = currentDate.getMinutes();
var seconds = currentDate.getSeconds();
// Display the date and time
console.log("Current Date and Time:");
console.log("Year: " + year);
console.log("Month: " + month);
console.log("Day: " + day);
console.log("Hours: " + hours);
console.log("Minutes: " + minutes);
console.log("Seconds: " + seconds);
Q. 1(b) Defining and initializing 3 marks, example-2M 5
// Define and initialize an object using object literal syntax
var person = {
firstName: "John",
lastName: "Doe",
age: 30,
isStudent: false,
address: {R
city: "New York",
zipCode: "10001"
},
sayHello: function() {
console.log("Hello, my name is " + this.firstName + " " + this.lastName + ".");
}
};
// Access and modify object properties
console.log("First Name:", person.firstName); // Output: John
console.log("Age:", person.age); // Output: 30
// Modify a property
person.age = 31;
// Access nested object property
console.log("City:", person.address.city); // Output: New York
// Call a method
person.sayHello(); // Output: Hello, my name is John Doe.

Q. 2(a) Onclick Event Example: 5

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Onclick Event Example</title>
</head>
<body>

<!-- Button that triggers the onclick event -->


<button id="clickMeButton" >Click Me!</button>

<!-- Script to handle the onclick event -->


<script>
// Function to be executed when the button is clicked
function handleClick() {
alert("Button clicked!");
}

// Attach the handleClick function to the onclick event of the button


document.getElementById("clickMeButton").onclick =
handleClick;
</script>

</body>
</html>
Onload Event Example:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Onload Event Example</title>
</head>
<body>

<!-- Script to handle the onload event -->


<script>
// Function to be executed when the page is loaded
function handleLoad() {
alert("Page loaded!");
}

// Attach the handleLoad function to the onload event of the window


window.onload = handleLoad;
</script>

</body>
</html>
Q. 2(b) Proper code for Input- 2 marks, adding-1 marks, display -2marks 5
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Add 5 Program</title>
</head>
<body>

<!-- Script to get user input, add 5, and display the result -->
<script>
// Prompt the user for input
var userInput = prompt("Enter a number:");

// Convert the input to a number (assuming the user enters a valid number)
var inputNumber = parseFloat(userInput);

// Check if the conversion was successful and the input is a valid number
if (!isNaN(inputNumber)) {
// Add 5 to the input number
var result = inputNumber + 5;

// Display the result


alert("Original number: " + inputNumber + "\nAfter adding 5: " + result);
} else {
// Display an error message if the input is not a valid number
alert("Invalid input. Please enter a valid number.");
}
</script>

</body>
</html>
Q. 3(a) 10
Push method-2.5M, pop method-2.5M
a) push Method:
The push method adds one or more elements to the end of an array. It modifies the
original array and returns the new length of the array.
// Initialize an array
var fruits = ['apple', 'banana', 'orange'];

// Use push to add a new element to the end


var newLength = fruits.push('grape');

// Display the updated array and its length


console.log('Updated Array:', fruits);
console.log('New Length:', newLength);

b) pop Method:
The pop method removes the last element from an array. It modifies the original array,
and the removed element is returned. If the array is empty, pop returns undefined.
// Initialize an array
var fruits = ['apple', 'banana', 'orange'];

// Use pop to remove the last element


var removedElement = fruits.pop();

// Display the updated array, the removed element, and the new length
console.log('Updated Array:', fruits);
console.log('Removed Element:', removedElement);
Q. 3(b) Read two passwords-2M, validate those password -2M,Alert
message-1M
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Password Validation</title>
</head>
<body>

<!-- Script to read and validate passwords -->


<script>
// Prompt the user to enter the first password
var password1 = prompt("Enter the first password:");

// Prompt the user to enter the second password


var password2 = prompt("Enter the second password:");
// Validate if passwords match
if (password1 === password2) {
// Passwords match, display success message
alert("Password Match: Both passwords are the same!");
} else {
// Passwords do not match, ask user to enter passwords again
alert("Password Mismatch: Please enter the passwords again.");
}
</script>

</body>
</html>

Q. 4(a) 5
Any two modules explained with proper example code 2.5M for each module
Core Module Description

http http module includes classes, methods and events to create Node.js http server.

url url module includes methods for URL resolution and parsing.

querystring Querystring module includes to deal with query string.

Path Path module includes methods to deal with file paths

Util Util module includes utility functions useful for programmers

Fs fs module includes classes ,methods and events to work with file I/O

Q. 4(b) Creating server- 2.5 marks, response and port -2.5M 5


// Importing the 'http' module
const http = require('http');
// Creating a simple HTTP server
const server = http.createServer((req, res) => {
// Setting the response header with a 200 OK status and plain text content type
res.writeHead(200, { 'Content-Type': 'text/plain' });
// Sending the response body
res.end('Welcome to DSU\n');
});
// Listening on port 8080
const PORT = 8080;
server.listen(PORT, () => {
console.log(`Server running at http://localhost:${PORT}/`);
});

You might also like