KEMBAR78
Ultimate Java Notes For UMS | PDF | Class (Computer Programming) | Object Oriented Programming
0% found this document useful (0 votes)
12 views4 pages

Ultimate Java Notes For UMS

Uploaded by

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

Ultimate Java Notes For UMS

Uploaded by

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

Ultimate Java Notes for University

Management System
1. Core Java Fundamentals

- Data Types: int, float, double, char, boolean, String.


- Control Statements: if-else, switch, for, while, do-while.
- Methods:
public int add(int a, int b) { return a+b; }
- Arrays and Strings (immutable, StringBuilder mutable).
- Example:
String s="Hello"; String t=new String("Hello");
StringBuilder sb=new StringBuilder("Hi"); sb.append(" Ila");

2. Object-Oriented Programming (OOP)

- Class & Object: Building blocks of Java.


class Student {
String name;
int roll;
void display() { System.out.println(name+" "+roll); }
}

- Encapsulation: private fields + getters/setters.


class Student {
private String name;
public void setName(String n){ name=n; }
public String getName(){ return name; }
}

- Inheritance: Parent → Child.


class Person { String name; }
class Student extends Person { int roll; }

- Polymorphism:
- Overloading (compile time)
- Overriding (runtime)
class Person { void show(){ System.out.println("Person"); } }
class Student extends Person { void show(){ System.out.println("Student"); } }

- Abstraction: Abstract classes & Interfaces.


abstract class Shape { abstract void draw(); }
class Circle extends Shape { void draw(){ System.out.println("Circle"); } }

3. Exception Handling

- try-catch-finally blocks.
try { int x=10/0; }
catch(Exception e){ System.out.println("Error: "+e); }
finally{ System.out.println("Executes always"); }

- throw & throws keywords.


void check(int age) throws Exception {
if(age<18) throw new Exception("Not valid");
}

- Custom Exceptions:
class MyException extends Exception {
MyException(String msg){ super(msg); }
}

4. Collections Framework

- List (ArrayList, LinkedList).


ArrayList<String> list=new ArrayList<>();
list.add("Alice");

- Set (HashSet, TreeSet).


HashSet<Integer> set=new HashSet<>();
set.add(1); set.add(2);

- Map (HashMap, TreeMap).


HashMap<Integer,String> map=new HashMap<>();
map.put(1,"CSE"); map.put(2,"ECE");

- Iteration using for-each and Iterator.


5. Java I/O

- FileReader/FileWriter.
FileWriter fw=new FileWriter("out.txt");
fw.write("Hello"); fw.close();

- BufferedReader/BufferedWriter for efficient reading/writing.

- Serialization for saving objects.

6. Java Swing (UI for UMS)

- JFrame, JPanel, JButton, JTextField, JTable, JLabel.


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

- Layouts: BorderLayout, FlowLayout, GridLayout.

- Event Handling:
b.addActionListener(e->System.out.println("Button clicked"));

7. JDBC (Database Connectivity)

Steps:
1. Load Driver:
Class.forName("com.mysql.cj.jdbc.Driver");
2. Create Connection:
Connection con=DriverManager.getConnection(url,user,pass);
3. Create Statement/PreparedStatement.
4. Execute Query.
5. Close Connection.

Example Insert:
String q="INSERT INTO student VALUES(?,?,?,?)";
PreparedStatement ps=con.prepareStatement(q);
ps.setInt(1,rollno);
ps.setString(2,name);
ps.setString(3,course);
ps.setInt(4,year);
ps.executeUpdate();

8. SQL Queries for UMS

- CREATE TABLE student(rollno INT PRIMARY KEY, name VARCHAR(50), course


VARCHAR(50), branch VARCHAR(50));
- INSERT INTO student VALUES(1,'Ila','CSE','AI');
- UPDATE student SET course='ECE' WHERE rollno=1;
- DELETE FROM student WHERE rollno=1;
- SELECT * FROM student;

9. Advanced Topics

- Multi-threading: Threads in Swing (for responsiveness).


- Synchronization: Locking shared resources.
- Lambda Expressions: Used for event handling.
- Stream API: For processing collections (Java 8+).
list.stream().filter(x->x.startsWith("A")).forEach(System.out::println);

You might also like