JAVA • PROGRAMMING • WEEK 11
NPTEL - Programming in Java - Week 11 : Programming Assignments Answers- 2025
NPTEL • Programming in Java • Programming Assignment
Week 11 : Programming Assignments - NPTEL >> Programming In Java - 2025
Week 11 : Programming Assignment 1
Solution :
import java.util.Scanner;
// Answer
import java.sql.*;
//End
public class W11_P1 {
public static void main(String args[]) {
try {
Connection conn = null;
Statement stmt = null;
String DB_URL = "jdbc:sqlite:/tempfs/db";
System.setProperty("org.sqlite.tmpdir", "/tempfs");
~~~THERE IS SOME INVISIBLE CODE HERE~~~
} catch (Exception e) {
System.out.println(e);
}
}
}
Week 11 : Programming Assignment 2
Solution :
import java.sql.*;
import java.util.Scanner;
public class W11_P2 {
public static void main(String args[]) {
try {
Connection conn = null;
Statement stmt = null;
String DB_URL = "jdbc:sqlite:/tempfs/db";
System.setProperty("org.sqlite.tmpdir", "/tempfs");
// Answer
// Open a connection and check connection status
conn = DriverManager.getConnection(DB_URL);
System.out.print(conn.isValid(1));
//End
~~~THERE IS SOME INVISIBLE CODE HERE~~~
conn.close();
} catch (Exception e) {
System.out.println(e);
}
}
}
Week 11 : Programming Assignment 3
Solution :
// Answer
import java.sql.*;
import java.util.Scanner;
public class W11_P3 {
public static void main(String args[]) {
try {
Connection conn = null;
Statement stmt = null;
String DB_URL = "jdbc:sqlite:/tempfs/db";
System.setProperty("org.sqlite.tmpdir", "/tempfs");
conn = DriverManager.getConnection(DB_URL);
conn.close();
System.out.print(conn.isClosed());
//End
~~~THERE IS SOME INVISIBLE CODE HERE~~~
} catch (Exception e) {
System.out.println(e);
}
}
}
Week 11 : Programming Assignment 4
Solution :
~~~THERE IS SOME INVISIBLE CODE HERE~~~
// Answer
// The statement containing SQL command to create table "STUDENTS"
String createTableSQL = "CREATE TABLE STUDENTS (UID INT, Name VARCHAR(45), Roll VARCHAR(12), Age INT)";
// Execute the statement containing SQL command below this comment!
stmt.executeUpdate(createTableSQL);
//End
~~~THERE IS SOME INVISIBLE CODE HERE~~~
}
catch(Exception e){ System.out.println(e);}
}
}
Week 11 : Programming Assignment 5
Solution :
import java.sql.*;
import java.lang.*;
public class W11_P5 {
public static void main(String args[]) {
try {
Connection conn = null;
Statement stmt = null;
String DB_URL = "jdbc:sqlite:/tempfs/db";
System.setProperty("org.sqlite.tmpdir", "/tempfs");
// Open a connection
conn = DriverManager.getConnection(DB_URL);
stmt = conn.createStatement();
~~~THERE IS SOME INVISIBLE CODE HERE~~~
// Answer
// Write the SQL command to rename a table
String renameSQL = "ALTER TABLE STUDENTS RENAME TO GRADUATES";
// Execute the SQL command
stmt.executeUpdate(renameSQL);
//End
~~~THERE IS SOME INVISIBLE CODE HERE~~~
} catch(Exception e){ System.out.println(e);}
}
}