Week 10 Programming Assignments 1-5

 Week 10 Programming Assignments 1

Due date on 2026-10-01, 23:59 IST

Your last recorded submission was on 2026-09-22, 05:17 IST.

Q.

Introduction to JDBC and Required Imports


Problem Statement

What is JDBC?
JDBC means Java Database Connectivity, which allows Java programs to work with databases.

Before writing database programs, you must import the correct packages. Without proper imports, the code will not compile.

Programming Assignment:

  • Import the necessary JDBC packages so the program can compile

  • You only need to complete the import section

  • The output "import successful" is printed automatically

This helps you practice the correct way to prepare Java programs for database work.

Complete Program

Java
public class W10_P2 {
    public static void main(String[] args) {
        // --- START OF SOLUTION CODE ---
        String url = "jdbc:sqlite:test.db";
        // --- END OF SOLUTION CODE ---

        // Portal test output
        if (url.equals("jdbc:sqlite:test.db")) {
            System.out.println("connection string ready");
        } else {
            System.out.println("incorrect connection string");
        }
    }
}

Code Snippet to Paste in the Editor

Java
// --- START OF SOLUTION CODE ---
String url = "jdbc:sqlite:test.db";
// --- END OF SOLUTION CODE ---
You may submit any number of times before the due date. The final submission will be considered for grading.

This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program, your assignment will not be graded and you will not see your score after the deadline.

Evaluation Results

CompilationSuccessful|Public Test Cases: 1/1 Passed

Note: These tests may not be considered while scoring.

Public Test Cases

Test Case
Input
Expected Output
Output
Status
Test Case 1

-

import successful
import successful\n
Presentation Error


Week 10 Programming Assignments 2

Due date on 2026-10-01, 23:59 IST

Q.

 Writing a JDBC Connection String


Problem Statement

What is a JDBC Connection String?
To connect a Java program to a database, we use a special sentence called a connection string.
It tells Java:

  • Which database to use

  • Where the database is located

In this assignment, you will practice writing the correct JDBC connection string for SQLite database.

Programming Assignment:

  • Write the correct connection string for an SQLite database called test.db

  • The rest of the program prints "connection string ready" if your string is correct

This helps beginners practice writing JDBC connection strings safely, without actual database access.

Complete Program

Java
public class W10_P2 {
    public static void main(String[] args) {
        // --- START OF SOLUTION CODE ---
        String url = "jdbc:sqlite:test.db";
        // --- END OF SOLUTION CODE ---

        // Portal test output
        if (url.equals("jdbc:sqlite:test.db")) {
            System.out.println("connection string ready");
        } else {
            System.out.println("incorrect connection string");
        }
    }
}

Code Snippet to Paste in the Editor

Java
// --- START OF SOLUTION CODE ---
String url = "jdbc:sqlite:test.db";
// --- END OF SOLUTION CODE ---
You may submit any number of times before the due date. The final submission will be considered for grading.

This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program, your assignment will not be graded and you will not see your score after the deadline.

Evaluation Results

CompilationSuccessful|Public Test Cases: 1/1 Passed

Note: These tests may not be considered while scoring.

Public Test Cases

Test Case
Input
Expected Output
Output
Status
Test Case 1

-

connection string ready
connection string ready\n
Presentation Error


Week 10 Programming Assignments 3

Due date on 2026-10-01, 23:59 IST

Your last recorded submission was on 2026-09-22, 05:24 IST.

Q.

Writing a Simple SQL Insert Statement


Problem Statement

What is an SQL Insert Statement?
When working with databases, we use the INSERT command to add new records (data) into a table.

In this assignment:

  • Imagine there is a table called students with two columns: id and name

  • You will practice writing the correct SQL insert statement as a text string

  • No actual database operation is performed, only the string is checked

Programming Assignment:

  • Complete the SQL insert statement to add a student with id 1 and name 'Alice'

  • The rest of the code checks your string and prints "insert statement ready" if correct

This task helps beginners practice writing SQL commands safely.

Complete Program

Java
public class W10_P3 {
    public static void main(String[] args) {
        // --- START OF SOLUTION CODE ---
        String sql = "INSERT INTO students (id, name) VALUES (1, 'Alice');";
        // --- END OF SOLUTION CODE ---

        // Portal test output
        if (sql.equals("INSERT INTO students (id, name) VALUES (1, 'Alice');")) {
            System.out.println("insert statement ready");
        } else {
            System.out.println("incorrect statement");
        }
    }
}

Code Snippet to Paste in the Editor

Java
// --- START OF SOLUTION CODE ---
String sql = "INSERT INTO students (id, name) VALUES (1, 'Alice');";
// --- END OF SOLUTION CODE ---
You may submit any number of times before the due date. The final submission will be considered for grading.

This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program, your assignment will not be graded and you will not see your score after the deadline.

Evaluation Results

CompilationSuccessful|Public Test Cases: 1/1 Passed

Note: These tests may not be considered while scoring.

Private Test Cases

Private Test cases used for Evaluation
Status
Test Case 1
Passed



Week 10 Programming Assignments 4

Due date on 2026-10-01, 23:59 IST

Q.


Writing a Simple SQL SELECT Statement 


Problem Statement

What is a SQL SELECT Statement?
The SELECT statement is used to get data from a database table.
You can choose to fetch all columns or specific columns.

In this assignment:

  • Imagine a table called students with two columns: id and name

  • You will practice writing a SQL statement to fetch all columns for all students

Programming Assignment:

  • Write a SQL SELECT statement as a text string to get all data from students table

  • The rest of the program checks your string and prints "select statement ready" if correct

This task helps beginners practice safe SQL reading commands.

Complete Program

Java
public class W10_P4 {
    public static void main(String[] args) {
        // --- START OF SOLUTION CODE ---
        String sql = "SELECT * FROM students;";
        // --- END OF SOLUTION CODE ---

        if (sql.equals("SELECT * FROM students;")) {
            System.out.println("select statement ready");
        } else {
            System.out.println("incorrect statement");
        }
    }
}

Code Snippet to Paste in the Editor

Java
// --- START OF SOLUTION CODE ---
String sql = "SELECT * FROM students;";
// --- END OF SOLUTION CODE ---
You may submit any number of times before the due date. The final submission will be considered for grading.

This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program, your assignment will not be graded and you will not see your score after the deadline.

Evaluation Results

CompilationSuccessful|Public Test Cases: 1/1 Passed

Note: These tests may not be considered while scoring.

Public Test Cases

Test Case
Input
Expected Output
Output
Status
Test Case 1

-

select statement ready
select statement ready\n
Presentation Error


Week 10 Programming Assignments 5

Due date on 2026-10-01, 23:59 IST

Q.

Writing a Simple SQL UPDATE Statement 

Problem Statement

What is an SQL UPDATE Statement?
The UPDATE command is used to change existing data in a database table.

In this assignment:

  • Imagine a table called students with two columns: id and name

  • You will write a SQL statement to update the name of the student with id 1 to 'Bob'

Programming Assignment:

  • Write the correct SQL UPDATE statement as a text string

  • The rest of the code checks your string and prints "update statement ready" if correct

This helps beginners practice safe SQL update syntax.

Complete Program

Java
public class W10_P5 {
    public static void main(String[] args) {
        // --- START OF SOLUTION CODE ---
        String sql = "UPDATE students SET name = 'Bob' WHERE id = 1;";
        // --- END OF SOLUTION CODE ---

        // Portal test output
        if (sql.equals("UPDATE students SET name = 'Bob' WHERE id = 1;")) {
            System.out.println("update statement ready");
        } else {
            System.out.println("incorrect statement");
        }
    }
}

Code Snippet to Paste in the Editor

Java
// --- START OF SOLUTION CODE ---
String sql = "UPDATE students SET name = 'Bob' WHERE id = 1;";
// --- END OF SOLUTION CODE ---
You may submit any number of times before the due date. The final submission will be considered for grading.

This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of Public test cases. Assignment will be evaluated only after submitting using Submit button below. If you only save as or compile and run the Program, your assignment will not be graded and you will not see your score after the deadline.

Evaluation Results

CompilationSuccessful|Public Test Cases: 1/1 Passed

Note: These tests may not be considered while scoring.

Public Test Cases

Test Case
Input
Expected Output
Output
Status
Test Case 1

-

update statement ready
update statement ready\n
Presentation Error






No comments

Week 09 Programming Assignments 1-5

  W09 Programming Assignments 1 Due date on 2026-09-24, 23:59 IST Your last recorded submission was on 2026-09-14, 13:43 IST. Q. Write suita...