Chapter 13: Database Programming using JDBC – Exam Revision Notes

1. Introduction 2. JDBC Architecture Component Purpose DriverManager Manages database drivers Connection Represents a connection to the database Statement Used to execute SQL queries ResultSet Holds data returned from queries 3. Steps to Connect Database Class.forName(“com.mysql.cj.jdbc.Driver”); Connection con = DriverManager.getConnection(“jdbc:mysql://localhost:3306/dbname”,”user”,”password”); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery(“SELECT * FROM Students”); while(rs.next()) {     System.out.println(rs.getString(“name”) +…

Read More

Chapter 12: Java Applets – Exam Revision Notes

1. Definition 2. Applet Lifecycle Methods Method Purpose init() Initialize applet; called once at start start() Called after init() or when applet restarts paint(Graphics g) Draws text or graphics on the screen stop() Called when applet is stopped or browser leaves destroy() Cleanup resources before applet removal 3. Running Applets 4. GUI Components in Applets…

Read More

Unit 11: Java Applications – Exam Revision Notes

1. Introduction to Java GUI Applications 2. JFrame – Top-Level Window JFrame frame = new JFrame(“My Window”); frame.setSize(400, 300); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 3. Swing Components Component Description JLabel Displays text or images JTextField Single-line input field JButton Clickable button JCheckBox Toggle option JRadioButton Select one option from group JComboBox Drop-down list JTextArea Multi-line text input JTable…

Read More

Unit 10: Unfolding Collection of Data – Exam Revision Notes

1. Introduction 2. Core Interfaces Interface Description Collection Root interface for most collection classes List Ordered collection, allows duplicates Set Unordered, no duplicates Map Key-value pair mapping Queue FIFO structure, supports priority queue 3. List Interface List<String> list = new ArrayList<>(); list.add(“Java”); list.add(“Python”); for(String s : list) System.out.println(s); 4. Set Interface Set<Integer> set = new…

Read More

Unit 8: I/O and Streams – Exam Revision Notes

1. Introduction 2. java.io Package 3. Byte Streams Example: FileInputStream fis = new FileInputStream(“input.txt”); int i; while((i = fis.read()) != -1) {     System.out.print((char)i); } fis.close(); 4. Character Streams Example: FileWriter fw = new FileWriter(“output.txt”); fw.write(“Hello Java I/O”); fw.close(); 5. Console Input/Output Scanner sc = new Scanner(System.in); System.out.print(“Enter name: “); String name = sc.nextLine(); 6. File…

Read More

Unit 7: Threads – Exam Revision Notes

1. Introduction to Threads 2. Creating Threads There are two ways to create threads in Java: class MyThread extends Thread {     public void run() {         System.out.println(“Thread running”);     } } MyThread t = new MyThread(); t.start();  // starts the thread, calls run() class MyRunnable implements Runnable {     public void run() {         System.out.println(“Runnable thread running”);     } }…

Read More

Unit 5: Handling Errors / Exceptions – Exam Revision Notes

1. Introduction to Exceptions Example: Division by zero, file not found, null reference. 2. Types of Exceptions 3. Exception Handling Keywords Syntax Example: try {     int result = 10 / 0; } catch (ArithmeticException e) {     System.out.println(“Cannot divide by zero: ” + e); } finally {     System.out.println(“Execution completed.”); } 4. User-Defined Exceptions class MyException extends…

Read More