Answer Key Pre Halfyearly 2024
Answer Key Pre Halfyearly 2024
Q2:
i. SQL command to modify data in a database:
a) UPDATE
ii. In Java, NOT a primitive data type:
c) String
iii. SQL command to delete a database:
b) DROP DATABASE
iv. SQL clause to filter data based on a condition:
a) WHERE
v. Used to uniquely identify a record in a relational database table:
b) Primary Key
vi. NOT a loop structure in Java:
c) switch
vii. Application program running on multiple devices, communicating with servers over the internet:
Web-based application
Q3:
i. Two services under Digital India initiative:
DigiLocker.
BHIM (Bharat Interface for Money).
ii. Invalid identifier:
d) #Score
iii. Degree and cardinality of Library table:
Degree: 5 (number of columns).
Cardinality: 4 (number of rows).
iv. Primary Key and Foreign Key for CUSTOMERS and ORDERS:
Primary Key: OrderID (in ORDERS table).
Foreign Key: CustID (in ORDERS table linking to CUSTOMERS table).
v. NOT an example of a government ICT-enabled service:
b) Online ticket booking for movies
vi. One way to prevent unauthorized access:
Use strong passwords and multi-factor authentication.
vii. Valid variable names in Java:
b) empName and d) Emp_123
Q4:
i. Sequence for hosting a webinar:
a) B, D, C, A
ii. SQL function to count rows in a table:
b) COUNT()
iii. False statement about online banking:
b) Online banking ensures complete safety from cyberattacks.
iv. TRUE or FALSE:
True (Data encapsulation in OOP).
v. Result of SQL query:
b) Displays the average marks.
vi. Output of Java statement:
b) False
Q5:
i. Valid Foreign Key in a database:
b) A non-unique attribute referring to the primary key of another table.
ii. TRUE or FALSE:
True (Encapsulation in Java).
iii. SQL command to delete all rows without deleting the table structure:
DELETE FROM EMPLOYEES;
iv. SQL command to rename a table or column:
ALTER TABLE (for column).
RENAME TABLE (for table).
v. Difference between Java statements:
Statement #1: int num = 10; declares an integer variable.
Statement #2: double decimalNum = 10.5; declares a double-precision floating-point variable.
vi. Method with the same name as the class:
b) Constructor
Q6:
i. SQL command to change column data type:
ALTER TABLE
ii. Invalid variable declaration in Java:
c) String @Name = "Priya";
iii. Java method without a return value:
Void method
Q 12
int n = 5;
for (int i = 0; i < n; i++) {
System.out.println("Number: " + i);
}
Q 17.
int A = 3, B = 4;
int Product = 1;
int i = 1;
while (i <= B) {
Product *= A;
i++;
}
System.out.println(Product);
Q 19
DROP DELETE
I) Removes an entire table from the database. Removes specific rows from a table.
II) Cannot be rolled back. Can be rolled back using a transaction.
III) DROP TABLE TableName; DELETE FROM TableName WHERE Condition;
Example:
-- DROP command:
DROP TABLE EMPLOYEE;
-- DELETE command:
DELETE FROM EMPLOYEE WHERE Salary < 30000;
Q21.
a) Output of Java Code:
Q22.
a) Platforms offering free coding bootcamps/tutorials:
Codecademy
freeCodeCamp
b) Phases of SDLC:
Requirement Analysis: Gathering and analyzing user needs (e.g., user interviews).
Design: Creating system and architectural designs (e.g., UML diagrams).
Implementation: Writing and compiling code (e.g., using Java or Python).
Testing: Ensuring the system meets requirements (e.g., unit testing).
Deployment: Installing the system for end-users.
Maintenance: Addressing bugs and updates.
Q23.
a) Term "Method" in Java:
A method is a block of code that performs a specific task and is executed when called.
Example:
public int addNumbers(int a, int b) {
return a + b;
}
b) Java Code:
int[] scores = {45, 56, 78, 34, 89, 67};
for (int i = 0; i < scores.length; i++) {
System.out.println(scores[i]);
}
Q24. SQL Queries for BOOK and BORROWER Tables:
a) Count of books borrowed by each borrower:
SELECT BorrowerName, COUNT(BID) AS BooksBorrowed FROM BORROWER GROUP BY BorrowerName;
b) Add a new book to the BOOK table:
INSERT INTO BOOK (BID, Title, Author, Price, Publisher) VALUES (105, 'Machine Learning', 'Tom Mitchell', 900,
'McGraw Hill');
c) Titles of books borrowed on or after "2023-03-01":
SELECT BOOK.Title FROM BOOK, BORROWER WHERE BOOK.BID = BORROWER.BID AND BORROWER.BorrowDate >=
'2023-03-01';
d) Books where price exceeds 600:
SELECT * FROM BOOK WHERE Price > 600;