0% found this document useful (0 votes)
9 views4 pages

Java Revision Notes

Uploaded by

229x1a0252
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views4 pages

Java Revision Notes

Uploaded by

229x1a0252
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Java Programming - Complete Revision Notes (Units I to V)

UNIT I: Java Basics & OOP Concepts

1. Introduction to Java

• Platform-independent, object-oriented, secure, multithreaded


• JVM, JDK, JRE

2. Java Program Structure

public class HelloWorld {


public static void main(String[] args) {
System.out.println("Hello, Java!");
}
}

3. OOP Principles

• Encapsulation
• Inheritance
• Polymorphism (Method Overloading/Overriding)
• Abstraction

4. Constructors & Method Overloading

class Student {
int id; String name;
Student(int i, String n) {
id = i; name = n;
}
void display() {
System.out.println(id + " " + name);
}
}

5. Arrays and Command Line Args

public class CmdArg {


public static void main(String[] args) {
System.out.println("Arg: " + args[0]);
}
}

1
UNIT II: Inheritance & Exception Handling

1. Inheritance Types

• Single, Multilevel, Hierarchical

2. Super Keyword and Method Overriding

class Animal {
void sound() { System.out.println("Animal sound"); }
}
class Dog extends Animal {
void sound() { super.sound(); System.out.println("Dog barks"); }
}

3. Exception Handling

try {
int x = 10 / 0;
} catch (ArithmeticException e) {
System.out.println("Error: " + e);
}

4. Custom Exception

class MyException extends Exception {


MyException(String msg) { super(msg); }
}

UNIT III: Applets, Threads, and Packages

1. Applet

import java.applet.Applet;
import java.awt.Graphics;
public class HelloApplet extends Applet {
public void paint(Graphics g) {
g.drawString("Hello Applet", 50, 50);
}
}

2
2. Multithreading

class MyThread extends Thread {


public void run() {
System.out.println("Thread running");
}
}

3. Packages

package mypkg;
public class A {
public void show() {
System.out.println("Package class");
}
}

UNIT IV: GUI (AWT/Swing) & Event Handling

1. AWT Example

Frame f = new Frame("My Form");


Button b = new Button("Click");
f.add(b);
f.setSize(300, 200);
f.setVisible(true);

2. Swing Example

JFrame f = new JFrame("Swing");


JButton b = new JButton("Click");
f.add(b);
f.setSize(300, 200);
f.setVisible(true);

3. Event Handling

b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("Clicked");
}
});

3
UNIT V: JDBC & Networking

1. JDBC Connection

Class.forName("com.mysql.cj.jdbc.Driver");
Connection con = DriverManager.getConnection(url, user, pass);

2. Insert Record using JDBC

PreparedStatement pst = con.prepareStatement("INSERT INTO table VALUES


(?, ?)");
pst.setInt(1, 101);
pst.setString(2, "Buddy");
pst.executeUpdate();

3. Networking - Server

ServerSocket ss = new ServerSocket(5000);


Socket s = ss.accept();

4. Networking - Client

Socket s = new Socket("localhost", 5000);


DataOutputStream dout = new DataOutputStream(s.getOutputStream());
dout.writeUTF("Hello Server");

Next: Mock Model Paper with full solutions

You might also like