Java JEMAI 2021 + SCJP 2022 + exams 2017-2024 - explained like you are 5

Le Resume Ultime
de Java

Think of Java as a city of little robots. Classes are robot plans, objects are real robots, files are toy boxes, threads are friends working at the same time, and sockets are phones between computers.

What the two PDFs actually cover

Do not study these chapters as isolated islands. They connect: UI opens files, files throw exceptions, serialization uses files, servers use threads, and sockets use I/O streams.

Topic Best reference 5-year-old idea Exam danger
UI / AWT / Swing JEMAI 2021, chapters III-IV Put buttons and text areas in a window. Forgetting layouts and event listeners.
File / Exceptions SCJP 2022 VI-2 + JEMAI FileDialog A File object is a label on a toy box, not the toys. Thinking new File() creates the real file.
OOP / Blocks / GC / String SCJP 2022 II, III, VI Plans, robots, cleanup truck, and unchangeable words. Wrong execution order or assuming String changes itself.
JTable / Threads / TCP JEMAI 2021 IV + VI Tables show rows; threads serve many children; sockets are phones. Calling run() instead of start().
Collections / sorting / text parsing exams 2017, 2018, 2019, 2024 Put many things in the right bag, then sort or search the bag. Confusing Collection, Collections, List, Set, and Map.

🎯 What the exams repeat

Exam sourceRepeated question shapeWhat your answer must contain
exam24.pdfNotes.obj, SomeNotes.txt, Moyennes.obj, sorted displaySerializable classes, object streams, exception handling, average formula, descending sort.
exams.pdf 2019Notes.txt to Moyennes.txt, text to object, threads, collectionsColon parsing, variable note count, class average, serialization, join(), synchronized, yield().
exams.pdf 2018Employee management from emp.txtEmployee class, collection choice, selection by function code, add/delete, equality rule, serialization.
exams.pdf 2017Count words, count fields, sort employees by salaryLine reading, split("\\s+"), split(":", -1), collection + comparator.
Professor correction The PDFs are old-school Java. Good for exams, but not always good modern style. Example: finalize(), applets, and DataInputStream.readLine() are legacy. Learn them to understand the course; do not copy them blindly into modern production code.
Java 6 exam compatibility The JEMAI material is Java 5/6-era. For exam code, avoid lambdas, diamond syntax, and try-with-resources unless your teacher explicitly accepts newer Java. The exam templates below use old-compatible syntax.

UI means: make a window the user can touch

AWT is the older box of UI toys. Swing is the newer box. Both need containers, components, layouts, and listeners.

🧸 ELI5

A window is like a school desk. Buttons, labels, text fields, and tables are little objects you place on the desk. A layout manager is the teacher saying: "you sit north, you sit center, you sit in rows."

Frame / JFrame
contains
Panel / JPanel
contains
Button, TextArea

πŸ“Œ Exam rules

  • AWT: Frame, Panel, Button, TextArea, FileDialog.
  • Swing: JFrame, JButton, JTable, JScrollPane.
  • Layouts: FlowLayout flows like words, BorderLayout has North/South/East/West/Center, GridLayout makes boxes.
  • Events: a listener waits for the click and runs code.

Mini AWT pattern from the course

  1. Draw the interface. Decide where buttons and text areas go.
  2. Name each component. Example: bOpen, ta.
  3. Create a frame class. Usually it extends Frame or JFrame.
  4. Add components in the constructor. The constructor builds the window.
  5. Add listeners. Buttons are useless if nobody listens.
class MyFrameAWT extends Frame {
    Panel pNorth = new Panel();
    Button bOpen = new Button("Open");
    TextArea ta = new TextArea("");

    MyFrameAWT() {
        pNorth.add(bOpen);
        add(pNorth, BorderLayout.NORTH);
        add(ta, BorderLayout.CENTER);
        bOpen.addActionListener(new MyActionListenerForOpen(this));
        setSize(500, 400);
        setVisible(true);
    }
}

File is a map label, not the treasure

The course describes File as metadata that negotiates with the real file system. Translation: it points to a path and lets you ask questions or start I/O.

πŸ“ File

new File("notes.txt") does not read the file. It creates a Java object that says "maybe there is a thing called notes.txt here."

  • exists(): is it really there?
  • length(): how big?
  • delete(): remove it.
  • renameTo(): change its name/path.

πŸšͺ Streams

A stream is a tiny door where bytes or characters pass one by one.

  • FileInputStream: read bytes.
  • FileReader: read characters.
  • BufferedReader: read more comfortably.
  • PrintWriter: write formatted text.

πŸ”₯ Exceptions

Files are messy. They can be missing, locked, forbidden, or broken. Java forces you to handle checked exceptions.

  • FileNotFoundException: cannot find/open.
  • IOException: read/write problem.
  • finally: old way to close.
File file = new File(nomComplet);
FileInputStream in = null;
try {
    in = new FileInputStream(file);
    byte[] data = new byte[(int) file.length()];
    int count = in.read(data);
    String text = new String(data, 0, count);
    textArea.setText(text);
} catch (FileNotFoundException e) {
    System.out.println("The file is missing: " + e);
} catch (IOException e) {
    System.out.println("The file was found, but reading failed: " + e);
} finally {
    try {
        if (in != null) in.close();
    } catch (IOException e) {
        System.out.println("Cannot close file: " + e);
    }
}
Trap Do not write catch(IOException) before catch(FileNotFoundException). The big parent exception would catch everything first, and the child catch becomes unreachable.

Classes are plans; objects are real toys

Inheritance says "a Dog is an Animal." Composition says "a Car has an Engine." Initialization blocks decide what runs before the object is ready.

🧬 Inheritance

If class Dog extends Animal, a Dog can reuse Animal behavior. That is an IS-A relationship.

  • override: child replaces parent method behavior.
  • overload: same method name, different parameter list.
  • final method: cannot be overridden.
  • static method: hidden, not truly overridden.

βš™οΈ Blocks order

Static blocks run when the class wakes up. Instance blocks run every time you build a new object, before the constructor finishes.

ThingWhen it runsHow often
static { }Class loadingOnce per class
{ }Object creationEvery new object
ConstructorAfter instance blocksEvery new object
class Init {
    static { System.out.println("static first"); }
    { System.out.println("instance before constructor"); }

    Init() {
        System.out.println("constructor");
    }

    public static void main(String[] args) {
        new Init();
        new Init();
    }
}
Output order static first prints once. Then each new Init() prints the instance block, then the constructor. If you get that wrong, you lose easy exam points.

Garbage Collection is Java's cleanup truck

When no reference can reach an object anymore, the object becomes eligible for garbage collection. Eligible does not mean "deleted now"; it means "the truck may pick it up later."

🧹 ELI5

You built a toy robot. If nobody has its remote anymore, the robot is lost. Java may clean it from memory later.

Robot r = new Robot();
r = null;       // no remote points to the robot now
// robot is eligible for GC

⚠️ About finalize()

The SCJP PDF mentions finalize() as code that may run before deletion. That is legacy knowledge.

  • You cannot know when GC will run.
  • You cannot trust finalize() for closing files or sockets.
  • Modern Java deprecated finalization for removal; see OpenJDK JEP 421.
Blunt rule If your plan is "I will close the file in finalize()", the plan is bad. In Java 6 exam code, close in finally; in modern Java, try-with-resources is cleaner.

String is a word written in stone

The confusing part is this: methods like concat(), toLowerCase(), and replace() do not edit the same String. They return a new String.

πŸͺ¨ Immutable String

Imagine a word carved on a stone. You cannot erase it. If you want a new word, Java gives you a new stone.

String x = "Java";
x.concat(" Rules!");
System.out.println(x);  // Java

x = x.concat(" Rules!");
System.out.println(x);  // Java Rules!

🧡 Builder vs Buffer

When you change text many times, use a mutable builder.

ClassMutable?Thread-safe?Use when
StringNoYes, because immutableNormal text
StringBuilderYesNoFast local building
StringBufferYesYesOld synchronized code
Methods to know charAt(), concat(), equalsIgnoreCase(), length(), replace(), substring(), toLowerCase(), toUpperCase(), trim().

Assertions are tiny alarms for the developer

An assertion says: "I believe this must be true here." If it is false while testing, Java shouts.

🚨 Use for internal promises

Good assertion: after sorting, the list should be ordered. Bad assertion: checking if the user typed a password. User mistakes need real exceptions or validation, not assertions.

int age = readAgeFromTrustedTestData();
assert age >= 0 : "age cannot be negative";

▢️ Enable / disable

Assertions are disabled by default, exactly as the SCJP PDF says.

java -ea com.insat.TestClass   // enable assertions
java -da com.insat.TestClass   // disable assertions
Trap Do not put required program behavior inside assert. If assertions are off, that behavior disappears.

Serialization freezes an object into a file

Imagine taking a photo of your toy with all its current colors and numbers. Later, Java can load the photo and rebuild the toy.

πŸ“Έ Save object

The class must implement Serializable. Then ObjectOutputStream can write the object.

class Employee implements Serializable {
    String name;
    transient String secret; // not saved
}

ObjectOutputStream out = null;
try {
    out = new ObjectOutputStream(new FileOutputStream("employees.ser"));
    out.writeObject(new Employee());
} catch (IOException e) {
    System.out.println(e);
} finally {
    try {
        if (out != null) out.close();
    } catch (IOException e) {
        System.out.println(e);
    }
}

πŸ“¦ Restore object

ObjectInputStream reads the saved bytes and returns an object. You cast it back to the real type.

ObjectInputStream in = null;
try {
    in = new ObjectInputStream(new FileInputStream("employees.ser"));
    Employee e = (Employee) in.readObject();
} catch (IOException e) {
    System.out.println(e);
} catch (ClassNotFoundException e) {
    System.out.println(e);
} finally {
    try {
        if (in != null) in.close();
    } catch (IOException e) {
        System.out.println(e);
    }
}
Blunt rule Serialization is easy to write and easy to abuse. For course exercises it is fine. For real apps, think hard about compatibility, security, and whether JSON/database storage is a better fit.

JTable is a spreadsheet-looking Swing component

The JEMAI Swing chapter builds a table using a TableModel. The table asks the model: how many rows, how many columns, and what value is at row X column Y?

🧾 TableModel questions

MethodQuestion it answers
getColumnCount()How many vertical columns?
getRowCount()How many horizontal rows?
getValueAt(row, col)What is inside this cell?
getColumnName(col)What is the column title?
getColumnClass(col)What type of object is in this column?
TableModel model = new AbstractTableModel() {
    public int getColumnCount() { return columnNames.length; }
    public int getRowCount() { return rows.length; }
    public Object getValueAt(int row, int col) { return rows[row][col]; }
    public String getColumnName(int col) { return (String) columnNames[col]; }
    public Class getColumnClass(int col) { return getValueAt(0, col).getClass(); }
};

JTable table = new JTable(model);
JScrollPane scrollPane = new JScrollPane(table);
frame.getContentPane().add(scrollPane);
Exam memory trick JTable shows. TableModel knows. JScrollPane lets you move when the table is bigger than the window.

Parsing means cutting a big sentence into useful pieces

The SCJP PDF uses regex with Pattern and Matcher. Tokenizing is the general idea of breaking input into smaller tokens.

πŸ” Regex search

A regex is a tiny search language. It can find pieces that match a pattern.

Pattern p = Pattern.compile("ab");
Matcher m = p.matcher("abaaaba");

while (m.find()) {
    System.out.print(m.start() + " ");
}
// output: 0 4

βœ‚οΈ Tokenizing

If input is "Ali;20;INSAT", tokens are Ali, 20, and INSAT.

String line = "Ali;20;INSAT";
String[] tokens = line.split(";");
System.out.println(tokens[0]); // Ali
Trap Regex symbols have special meanings. "." means "any character"; to split on a real dot, use "\\.".

Collections are bags for many objects

The exams ask collections almost every year. If you cannot choose the right collection and sort it, you are not ready.

πŸ›οΈ The big families

FamilyUse it whenExample
ListYou keep order and allow duplicates.ArrayList, LinkedList
SetYou want unique elements.HashSet, TreeSet
MapYou search by key: id to employee, code to list.HashMap, TreeMap
QueueYou process first-in-first-out tasks.LinkedList

🧠 Course answer

Collection is the root interface for groups like List and Set. Collections is a utility class with static methods like sort(), reverse(), and synchronizedList().

Collection c = new ArrayList(); // broad, old style
List names = new ArrayList();   // ordered bag
Set ids = new HashSet();        // unique bag
Map byId = new HashMap();       // key -> value bag

Exam-safe declarations with generics

Use the interface on the left and the concrete class on the right. That is clean design and exam-friendly.

List<Employee> employees = new ArrayList<Employee>();
Set<Integer> uniqueIds = new HashSet<Integer>();
Map<Integer, Employee> employeeById = new HashMap<Integer, Employee>();

employees.add(new Employee(1, "Ali", "BEN ALI", 2, "Dev"));
Employee e = employeeById.get(new Integer(1));

Sorting pattern used in 2017, 2018, 2019, 2024

When the question says "tri croissant selon salaire" or "tri dΓ©croissant des moyennes", use Collections.sort with a Comparator.

// Ascending salary
Collections.sort(employees, new Comparator<Employee>() {
    public int compare(Employee a, Employee b) {
        return a.salaire - b.salaire;
    }
});

// Descending average
Collections.sort(averages, new Comparator<StudentAverage>() {
    public int compare(StudentAverage a, StudentAverage b) {
        return Double.compare(b.moyenne, a.moyenne);
    }
});
Trap from the exams If you import both java.awt.* and java.util.*, the name List becomes ambiguous because AWT also has java.awt.List. In exam code, write java.util.List or avoid wildcard UI imports.

Threads are little workers inside one program

The TCP server in the 2021 PDF uses Server extends Thread and Connection extends Thread so the server can keep listening while clients are handled.

πŸƒ Start vs run

This is non-negotiable: call start() to create a new worker. Calling run() is just a normal method call on the same worker.

Thread t = new Thread(new Runnable() {
    public void run() {
        System.out.println("work");
    }
});
t.start(); // correct: new thread
t.run();   // not parallel: just calls the method

🚦 Shared data danger

If two workers touch the same toy box at the same time, they can make a mess. That is a race condition. Use synchronization or better design.

  • synchronized protects one critical section.
  • StringBuffer is synchronized; StringBuilder is not.
  • Many threads are useful, but too many threads can slow everything.
Course connection In a socket server, one thread can wait for new clients, while one connection thread talks to one client. That is why thread knowledge and TCP/IP belong together.

Sockets are phones between computers

TCP gives a reliable conversation: connect, talk, close. UDP is faster but not guaranteed. The course focuses on Java sockets: Socket for the client, ServerSocket for the server.

Client
Socket(host, port)
TCP stream
Server
ServerSocket(port)

πŸ“ž Client steps

  1. Create Socket(host, port).
  2. Open output stream to send.
  3. Open input stream to receive.
  4. Close the socket when finished.

🏒 Server steps

  1. Create ServerSocket(port).
  2. Call accept() to wait for a client.
  3. Create streams from the accepted socket.
  4. Often start a new thread per client.
// Client idea
Socket s = null;
try {
    s = new Socket(host, 6061);
    BufferedReader in = new BufferedReader(
        new InputStreamReader(s.getInputStream()));
    PrintWriter out = new PrintWriter(s.getOutputStream(), true);
    out.println("Bonjour");
    System.out.println(in.readLine());
} finally {
    if (s != null) s.close();
}

// Server idea
ServerSocket server = new ServerSocket(6061);
while (true) {
    final Socket client = server.accept();
    new Thread(new Runnable() {
        public void run() {
            handle(client);
        }
    }).start();
}
Port memory trick IP address finds the computer. Port number finds the service inside that computer. Socket = IP + port.

The repeated exam questions and how to answer them

No resume can magically guarantee zero faults if you do not practice. But the old exams repeat the same patterns. Master these templates and you cover the real danger zone.

🎯 The universal answer plan

  1. Define the data class first. Example: StudentNote, StudentAverage, or Employee.
  2. Choose storage. Text file needs BufferedReader/PrintWriter; object file needs ObjectInputStream/ObjectOutputStream.
  3. Parse each line safely. Split by ":", trim fields, convert numbers with Integer.parseInt or Double.parseDouble.
  4. Put objects in a collection. Usually ArrayList because order, duplicates, sorting, add/delete are needed.
  5. Sort with a comparator. Salary ascending or average descending appears directly in exams.
  6. Handle exceptions and close streams. The exam says error and exception controls are considered.
Imports for almost every exam app Start with import java.io.*; and import java.util.*;. If you also use AWT, avoid import java.awt.*; with java.util.* unless you qualify java.util.List.

πŸ“Œ Model classes for 2024 notes

Use this when the question says Notes.obj, DS, Examen, and Moyennes.obj.

class StudentNote implements Serializable {
    int id;
    String nom;
    String prenom;
    double ds;
    double examen;

    StudentNote(int id, String nom, String prenom, double ds, double examen) {
        this.id = id;
        this.nom = nom;
        this.prenom = prenom;
        this.ds = ds;
        this.examen = examen;
    }

    double moyenne() {
        return ds * 0.3 + examen * 0.7;
    }
}

class StudentAverage implements Serializable {
    int id;
    String nom;
    String prenom;
    double moyenne;

    StudentAverage(StudentNote n) {
        id = n.id;
        nom = n.nom;
        prenom = n.prenom;
        moyenne = n.moyenne();
    }
}

πŸ§‘β€πŸ’Ό Model class for employee exams

2017 and 2018 both ask employee files and sorting/filtering. Equality by function code is strange, but the 2018 exam explicitly asks it.

class Employee implements Serializable {
    int id;
    String nom;
    String prenom;
    int codeFonction;
    String fonction;
    int salaire;

    public boolean equals(Object o) {
        if (!(o instanceof Employee)) return false;
        Employee e = (Employee) o;
        return codeFonction == e.codeFonction;
    }

    public int hashCode() {
        return codeFonction;
    }
}

Recipe 1 - text file to averages file

Use this for CalculMoyenne.java, word counting, field counting, and colon-separated employee files.

public class CalculMoyenne {
    public static void main(String[] args) {
        if (args.length != 2) {
            System.out.println("Usage: java CalculMoyenne Notes.txt Moyennes.txt");
            return;
        }

        BufferedReader br = null;
        PrintWriter pw = null;
        try {
            br = new BufferedReader(new FileReader(args[0]));
            pw = new PrintWriter(new FileWriter(args[1]));

            String line;
            double classSum = 0;
            int studentCount = 0;

            while ((line = br.readLine()) != null) {
                String[] p = line.split(":");
                double sum = 0;
                int noteCount = 0;

                for (int i = 2; i < p.length; i++) {
                    sum += Double.parseDouble(p[i].trim());
                    noteCount++;
                }

                double avg = sum / noteCount;
                pw.println(line + ":" + avg);
                classSum += avg;
                studentCount++;
            }

            pw.println("Moyenne Generale : " + (classSum / studentCount));
        } catch (Exception e) {
            System.out.println("Erreur: " + e);
        } finally {
            try { if (br != null) br.close(); } catch (IOException e) {}
            if (pw != null) pw.close();
        }
    }
}
Fast variants Count words: line.trim().split("\\s+").length, but if the trimmed line is empty, answer is 0. Count fields separated by :: use line.split(":", -1).length to keep empty fields.

Recipe 2 - object files without corrupting serialization

The safest exam design is: read the whole List, modify it, then rewrite the whole object file. Blindly appending objects with a new ObjectOutputStream can corrupt the stream header.

static List<StudentNote> loadNotes(String file)
        throws IOException, ClassNotFoundException {
    ObjectInputStream in = null;
    try {
        in = new ObjectInputStream(new FileInputStream(file));
        return (List<StudentNote>) in.readObject();
    } finally {
        if (in != null) in.close();
    }
}

static void saveNotes(String file, List<StudentNote> notes)
        throws IOException {
    ObjectOutputStream out = null;
    try {
        out = new ObjectOutputStream(new FileOutputStream(file));
        out.writeObject(notes);
    } finally {
        if (out != null) out.close();
    }
}

AddToNotes.java pattern

List<StudentNote> notes = loadNotes("Notes.obj");
BufferedReader br = new BufferedReader(new FileReader("SomeNotes.txt"));
String line;
while ((line = br.readLine()) != null) {
    String[] p = line.split(":");
    notes.add(new StudentNote(
        Integer.parseInt(p[0].trim()),
        p[1].trim(),
        p[2].trim(),
        Double.parseDouble(p[3].trim()),
        Double.parseDouble(p[4].trim())
    ));
}
br.close();
saveNotes("Notes.obj", notes);

Moyennes + CatMoyennes pattern

List<StudentNote> notes = loadNotes("Notes.obj");
List<StudentAverage> avgs = new ArrayList<StudentAverage>();

for (int i = 0; i < notes.size(); i++) {
    avgs.add(new StudentAverage(notes.get(i)));
}

Collections.sort(avgs, new Comparator<StudentAverage>() {
    public int compare(StudentAverage a, StudentAverage b) {
        return Double.compare(b.moyenne, a.moyenne);
    }
});

// then write avgs to Moyennes.obj or print them

Recipe 3 - employee collection operations

Use one ArrayList<Employee> for normal management. Use HashMap<Integer, Employee> only when the question emphasizes fast lookup by id.

List<Employee> employees = new ArrayList<Employee>();

// select by function code
for (int i = 0; i < employees.size(); i++) {
    Employee e = employees.get(i);
    if (e.codeFonction == 2) {
        System.out.println(e.nom + " " + e.prenom);
    }
}

// delete by id
Iterator<Employee> it = employees.iterator();
while (it.hasNext()) {
    Employee e = it.next();
    if (e.id == 80800) {
        it.remove();
    }
}

// sort salary ascending
Collections.sort(employees, new Comparator<Employee>() {
    public int compare(Employee a, Employee b) {
        return a.salaire - b.salaire;
    }
});

Recipe 4 - thread question template

2019 asks creation possibilities, join(), synchronized, yield(), and creating N threads that call displayMsg() ten times.

class Worker extends Thread {
    public void run() {
        displayMsg();
    }

    static synchronized void displayMsg() {
        for (int i = 0; i < 10; i++) {
            System.out.println(Thread.currentThread().getName() + " message " + i);
            Thread.yield();
        }
    }
}

public class LaunchThreads {
    public static void main(String[] args) throws Exception {
        int n = Integer.parseInt(args[0]);
        Thread[] threads = new Thread[n];

        for (int i = 0; i < n; i++) {
            threads[i] = new Worker();
            threads[i].start();
        }

        for (int i = 0; i < n; i++) {
            threads[i].join();
        }
    }
}

Theory answer bank

QuestionPerfect short answer
SerializationMechanism that converts an object graph into bytes to save or transmit it. Class implements Serializable; use ObjectOutputStream and ObjectInputStream; transient fields are skipped.
Garbage CollectionAutomatic memory cleanup for unreachable objects. Trigger is not guaranteed. Programmer can remove references, call System.gc() as a request, and use finalize() only as legacy course knowledge.
Static block vs instance blockStatic block runs once when the class is loaded. Instance block runs before the constructor every time an object is created.
protectedAccessible in the same package and in subclasses, including subclasses in another package through inheritance.
staticBelongs to the class, not to one object. Shared by all instances.
finalVariable cannot be reassigned, method cannot be overridden, class cannot be subclassed.
synchronizedLocks a method/block so only one thread enters that critical section for the same monitor.
Runnable vs ThreadRunnable is the task contract with run(). Thread is the worker that can execute a task with start().
join()Current thread waits until another thread finishes.
yield()Current thread politely suggests giving another ready thread a chance. It is not guaranteed.
Collection vs CollectionsCollection is an interface; Collections is a utility class with static helper methods.
Blunt exam warning Do not write only theory when the question asks for an application. You must show classes, file reading/writing, collection choice, sorting, and exception handling. That is where the marks are.

Fast revision before the exam

These are the mistakes that cost points. If one sounds unfamiliar, go back to its section.

Question 1

Does String x = "A"; x.concat("B"); change x?

No. Strings are immutable. Without assignment, x is still "A".

Question 2

Does new File("a.txt") create a.txt on disk?

No. It creates a Java path object. Real creation happens through writing or explicit creation methods.

Question 3

Which runs once: static block or instance block?

Static block runs once when the class loads. Instance block runs for every object.

Question 4

In networking, who uses ServerSocket?

The server. The client uses Socket.

Question 5

What is the difference between Collection and Collections?

Collection is an interface. Collections is a utility class with static methods like sort().

Question 6

How do you safely add notes from text into Notes.obj?

Read the serialized List, parse SomeNotes.txt, add objects to the list, then rewrite the whole object file.

One-screen checklist

  • UI: component + container + layout + listener.
  • File: File describes a path; streams read/write content.
  • Exceptions: catch specific before general; close resources.
  • OOP: IS-A uses inheritance; HAS-A uses fields/references.
  • Blocks: static once, instance before constructor each time.
  • GC: eligible is not immediate; do not depend on finalize().
  • String: immutable; use StringBuilder for many edits.
  • Assertions: testing assumptions only, disabled by default.
  • Serialization: class implements Serializable; streams save/restore.
  • JTable: data lives in the model; table displays it.
  • Parsing: regex finds patterns; tokenizing cuts data into pieces.
  • Collections: choose ArrayList for sortable lists, HashSet for uniqueness, HashMap for lookup by key.
  • Threads: start() creates concurrent work; run() alone does not.
  • TCP/IP: server waits with accept(); client connects with Socket.
  • Exam apps: always include data class, file I/O, collection, sort/filter logic, exceptions, and closing streams.
References used Local PDFs: 1-2-3-4-5-6-ALL-Java-JEMAI-2021.pdf for AWT, Swing, JTable, TCP/IP, and threaded server examples; CoursJemaiSCJP_Full2022.pdf for inheritance, initialization blocks, garbage collection, exceptions, assertions, strings, I/O, serialization, parsing, and tokenizing; exam24.pdf and exams.pdf for repeated exam patterns from 2017, 2018, 2019, and 2024.
↑