JavaPaper2
JavaPaper2
interface Animal {
// Default method
System.out.println("Dog barks.");
}
}
OUTPUT :-
Dog barks.
// Interface
interface Greetable {
void greet();
// Outer class
class Outer {
Exception Hierarchy
// 2. Override the run() method to define the code the thread will
execute
@Override
public void run() {
OUTPUT :-
import java.sql.*;
import java.util.Scanner;
public class StudentDatabase {
static final String USER = "root"; // replace with your MySQL username
static final String PASS = "password"; // replace with your MySQL password
public static void executeUpdateDelete(String query, int id, String name, int age, String
grade) {
if (query.startsWith("UPDATE")) {
stmt.setString(1, name);
stmt.setInt(2, age);
stmt.setString(3, grade);
stmt.setInt(4, id);
} else if (query.startsWith("DELETE")) {
stmt.setInt(1, id);
se.printStackTrace();
}
while (true) {
if (choice == 3) break;
int id = scanner.nextInt();
if (choice == 1) {
} else if (choice == 2) {
} else {
System.out.println("Invalid option.");
OUPUT:-
Choose operation:
1. Update
2. Delete
3. Exit
Operation successful.
Choose operation:
1. Update
2. Delete
3. Exit
Operation successful.