diff --git a/app/components/CodeBlock.tsx b/app/components/CodeBlock.tsx new file mode 100644 index 0000000..35f6535 --- /dev/null +++ b/app/components/CodeBlock.tsx @@ -0,0 +1,61 @@ +"use client"; + +import { useState } from "react"; +import { Check, Copy } from "lucide-react"; + +interface CodeBlockProps { + title: string; + code: string; +} + +export const CodeBlock = ({ title, code }: CodeBlockProps) => { + const [copied, setCopied] = useState(false); + + const handleCopy = async () => { + try { + await navigator.clipboard.writeText(code); + setCopied(true); + setTimeout(() => setCopied(false), 2000); + } catch (err) { + console.error("Failed to copy code: ", err); + } + }; + + return ( +
+ {/* Block Header Toolbar */} +
+ + {title} + + + +
+ + {/* Code Text Body - Flattened Layout */} +
+        {code}
+      
+
+ ); +}; \ No newline at end of file diff --git a/app/sem1/c/[chapter]/page.tsx b/app/sem1/c/[chapter]/page.tsx index 38e865e..4beb53c 100644 --- a/app/sem1/c/[chapter]/page.tsx +++ b/app/sem1/c/[chapter]/page.tsx @@ -12,12 +12,11 @@ import { ArrowBigLeft, ArrowBigRight } from "lucide-react"; import { Righteous } from "next/font/google"; import BookmarkButton from "../../../components/BookmarkButton"; const righteous = Righteous({ - subsets: ['latin'], - weight: '400', - variable: '--font-righteous', - }); + subsets: ['latin'], + weight: '400', + variable: '--font-righteous', +}); -// Chapter data const chapters = [ { id: "ch0", title: "Course Outline", component: Ch0Content }, { id: "ch1", title: "Introduction to Computing", component: Ch1Content }, @@ -33,12 +32,14 @@ type ChapterProps = { }; export default async function ChapterPage({ params }: ChapterProps) { + // NEXT.JS 15 COMPLIANCE: Await the incoming promise object to target params reliably const { chapter: chapterId } = await params; - const currentIndex = chapters.findIndex((c) => c.id === chapterId); + + const currentIndex = chapters.findIndex((c) => c.id === chapterId); const chapter = chapters[currentIndex]; if (!chapter) { - return

Chapter not found

; + return

Chapter not found

; } const ChapterComponent = chapter.component; @@ -54,23 +55,22 @@ export default async function ChapterPage({ params }: ChapterProps) { ch6: "c-file-memory-preprocessors", }; + // CLEANUP RESOLUTION: Utilizing the pre-awaited chapterId inside the clean synchronous map filter const chapterQuiz = moduleQuizzes.find(async (quiz) => quiz.slug === chapterQuizSlugMap[(await params).chapter]); - return (
- {/* Content */}

Programming in C

-
+ +

{chapter.title}

- - {/* Navigation Buttons */} + {/* Top Pagination Control Interface */}
{prevChapter ? ( - {/* Navigation Buttons */} + {/* Bottom Pagination Control Interface */}
{prevChapter ? (
); -} +} \ No newline at end of file diff --git a/app/sem1/c/content/chapter1.tsx b/app/sem1/c/content/chapter1.tsx index ac626c1..f8845cc 100644 --- a/app/sem1/c/content/chapter1.tsx +++ b/app/sem1/c/content/chapter1.tsx @@ -1,4 +1,7 @@ +"use client"; + import Image from "next/image"; +import { CodeBlock } from "../../../components/CodeBlock"; export const Ch1Content = () => { return ( @@ -22,7 +25,7 @@ export const Ch1Content = () => {
  • Example: Sorting marks to find the highest scorer.
  • -
    +
    Quick Example
    Input: [72, 89, 34, 91]
    @@ -47,11 +50,10 @@ export const Ch1Content = () => { timeline-computing -
    @@ -59,7 +61,6 @@ export const Ch1Content = () => { {/* Early Computers */}

    Early Computers and Machines

    -
    • Mechanical: Difference Engine.
    • Electromechanical: Zuse machines, punched card devices.
    • @@ -69,11 +70,10 @@ export const Ch1Content = () => { eniac-block -

    @@ -81,7 +81,6 @@ export const Ch1Content = () => { {/* Components */}

    Components of a Computer

    -
    • Input devices such as keyboard and mouse.
    • Output devices such as monitors and printers.
    • @@ -94,11 +93,10 @@ export const Ch1Content = () => { computer-block-diagram -

    @@ -106,14 +104,13 @@ export const Ch1Content = () => { {/* Problems */}

    Problems and Algorithm Characteristics

    -
    • Well-defined problem: has clear input, clear output and defined end state.
    • Ill-defined problem: unclear goals or conditions.
    • Algorithm characteristics: finiteness, definiteness, input, output, effectiveness.
    -
    +
    Tip: In exam answers, clearly state if the problem is well-defined and list algorithm characteristics.
    @@ -128,31 +125,28 @@ export const Ch1Content = () => {
  • Flowcharts represent logic using shapes: oval (Start/End), rectangle (process), diamond (decision), parallelogram (I/O).
  • -
    -
    Pseudo-code Example: Sum of first n numbers
    -
    -            {`READ n
    +        
    -        
    + /> -
    +
    Flowchart Structure

    Start → Input n → Initialize sum → Loop (i ≤ n?) → Add → Update → Output sum → End

    flowchart-sum-n - + src="/flowchart-sum-n.png" + alt="flowchart-sum-n" + className="my-6 max-w-full" + width={750} + height={500} + />
    @@ -161,7 +155,6 @@ PRINT sum`} {/* Memory */}

    Memory, Variables and Values

    -
    • Memory stores data and instructions in binary.
    • Variables represent named memory locations.
    • @@ -169,23 +162,21 @@ PRINT sum`}
    • Data types determine size and operations allowed.
    -
    -
    Memory Layout Example
    -
    -            {`Address   Content
    +        
    -          memory-layout
    +        />
     
    -        
    + memory-layout

    @@ -193,7 +184,6 @@ PRINT sum`} {/* Instructions */}

    Instructions

    -
    • Machine instructions are binary codes executed by the CPU.
    • Assembly uses mnemonic symbols.
    • @@ -201,15 +191,13 @@ PRINT sum`}
    • Instruction cycle: Fetch, Decode, Execute, Store.
    -
    -
    Assembly-like Example
    -
    -            {`LOAD R1, 5
    +        
    -        
    + />

    @@ -217,7 +205,6 @@ STORE R3, 0x200`} {/* Programs */}

    Programs

    -
    • A program is a sequence of instructions that performs a task.
    • Lifecycle includes writing, compiling, linking, running, testing and maintaining.
    • @@ -227,13 +214,12 @@ STORE R3, 0x200`} program-lifecycle -
    ); -}; +}; \ No newline at end of file diff --git a/app/sem1/c/content/chapter2.tsx b/app/sem1/c/content/chapter2.tsx index 3309ad3..8ca06ed 100644 --- a/app/sem1/c/content/chapter2.tsx +++ b/app/sem1/c/content/chapter2.tsx @@ -1,4 +1,8 @@ +"use client"; + import Image from "next/image"; +// NEXT.JS 15 FIX: Named import curly braces ke andar perfectly integrated +import { CodeBlock } from "../../../components/CodeBlock"; export const Ch2Content = () => { return ( @@ -31,7 +35,6 @@ export const Ch2Content = () => {
  • Link: `gcc program.o -o program` produces executable.
  • Run: `./program` on Unix-like systems.
  • -
    @@ -57,18 +60,17 @@ export const Ch2Content = () => {
  • Return from `main` typically `return 0;` to signal success.
  • -
    -
    Minimal example
    -
    -{`#include 
    +        {/* ✅ REMOVED OLD PRE: Replaced with the exact matching CodeBlock */}
    +        
     
     int main(void) {
         int a = 10;
    -    printf("Value of a = %d\n", a);
    +    printf("Value of a = %d\\n", a);
         return 0;
     }`}
    -          
    -
    + />
    @@ -82,14 +84,14 @@ int main(void) {
  • Run executable: ./program.
  • Typical compile-time errors: syntax error, undeclared identifier, type mismatch.
  • + compile-run-flow - + src="/compile-run-flow.png" + alt="compile-run-flow" + className="my-6 rounded-lg border border-[#c7a669] shadow-md max-w-full" + width={900} + height={380} + />
    @@ -135,9 +137,10 @@ int main(void) {
  • Buffer overflow with strings; always ensure space for null terminator.
  • -
    Faulty snippet
    -
    -{`#include 
    +          {/* ✅ REMOVED OLD FAULTY PRE: Replaced with premium dynamic CodeBlock */}
    +          
     
     int main() {
         int a;
    @@ -146,16 +149,17 @@ int main() {
         printf("Value is: %d", a)  // wrong: missing semicolon
         return 0;
     }`}
    -          
    + /> -
    Corrected
    -
    -{`scanf("%d", &a);
    +          {/* ✅ REMOVED OLD CORRECTED PRE: Replaced with premium dynamic CodeBlock */}
    +          
    +          />
             
    ); -}; +}; \ No newline at end of file diff --git a/app/sem1/c/content/chapter3.tsx b/app/sem1/c/content/chapter3.tsx index a5b9147..b78a892 100644 --- a/app/sem1/c/content/chapter3.tsx +++ b/app/sem1/c/content/chapter3.tsx @@ -1,4 +1,8 @@ -import Image from 'next/image'; +"use client"; + +import Image from "next/image"; +// NEXT.JS 15 FIX: Named import curly braces ke andar clean link kar diya hai +import { CodeBlock } from "../../../components/CodeBlock"; export const Ch3Content = () => { return ( @@ -37,7 +41,7 @@ export const Ch3Content = () => {

    Standard fundamental types commonly used in exams are listed below.

    -
    +
    Common C types (typical 32-bit system)
      @@ -66,7 +70,6 @@ export const Ch3Content = () => { width={600} height={300} /> -
      @@ -111,6 +114,7 @@ export const Ch3Content = () => { Note: use parentheses to enforce evaluation order when needed.
    + operator-precedence {
  • Always pass address with scanf() for non-array variables: scanf("%d", &x).
  • -
    -
    I/O Example
    -
    -            {`int x;
    +        {/* ✅ UPGRADED: Replaced manual pre with CodeBlock */}
    +        
    -        
    +printf("You entered %d\\n", x);`} + />
    @@ -170,27 +173,25 @@ printf("You entered %d\n", x);`}
  • goto exists but is discouraged; used rarely for error handling in legacy code.
  • -
    -
    if-else example
    -
    -            {`if (a > b) {
    -  printf("a is greater\n");
    +        {/* ✅ UPGRADED: Replaced with premium CodeBlock */}
    +         b) {
    +  printf("a is greater\\n");
     } else {
    -  printf("b is greater or equal\n");
    +  printf("b is greater or equal\\n");
     }`}
    -          
    -
    + /> -
    -
    switch example
    -
    -            {`switch (ch) {
    +        {/* ✅ UPGRADED: Replaced with premium CodeBlock */}
    +        
    -        
    + />
    @@ -206,29 +207,29 @@ printf("You entered %d\n", x);`}
  • Jumpsbreak, continue (skip), and goto (discouraged).
  • -
    -
    Loop examples
    -
    -            {`// for loop
    +        {/* ✅ UPGRADED: Replaced multiple samples inside one premium CodeBlock */}
    +        
    -        
    + sum += j; + j++; +} while (j < n);`} + /> + loop-flowcharts

    Debugging Exercise

    -
    -
    Find and fix the errors
    -
    -            {`#include 
    +        
    +
    Find and fix the errors
    + + {/* ✅ UPGRADED: Faulty code snippet block */} + int main() { char s[5]; printf("Enter string: "); scanf("%s", s); // possible overflow if user types >4 chars - printf("You entered: %s\n", s) + printf("You entered: %s\\n", s) return 0; }`} -
    + /> -
    Correct points
    -
      +
      Correct points
      +
      • Ensure buffer size and use width specifier: scanf("%4s", s);
      • Add missing semicolon after printf.
      • Prefer fgets for safer input.
      • @@ -293,4 +297,4 @@ int main() {
    ); -}; +}; \ No newline at end of file diff --git a/app/sem1/c/content/chapter4.tsx b/app/sem1/c/content/chapter4.tsx index e09af1e..506bb12 100644 --- a/app/sem1/c/content/chapter4.tsx +++ b/app/sem1/c/content/chapter4.tsx @@ -1,4 +1,8 @@ +"use client"; + import Image from "next/image"; +// NEXT.JS 15 FIX: Named import for pixel-perfect integrated component blocks +import { CodeBlock } from "../../../components/CodeBlock"; export const Ch4Content = () => { return ( @@ -22,16 +26,19 @@ export const Ch4Content = () => {
  • Dynamic allocation: use {`malloc`} and {`free`} for runtime sizes.
  • -
    -
    Static vs dynamic
    -
    {`// static
    +        {/* ✅ UPGRADED: Replaced primitive markup with CodeBlock */}
    +        
    -        
    +if (b == NULL) { + /* handle dynamic allocation error */ +} +free(b);`} + /> width={750} height={350} /> -
    @@ -57,21 +63,24 @@ free(b);`}
  • Safety: always ensure space for the terminating {`'\\0'`} and prefer bounded input.
  • -
    -
    String example
    -
    {`char s[6] = "Hello";
    -printf("%s\n", s);
    -if (strcmp(s, "Hello") == 0) { /* equal */ }`}
    -
    + {/* ✅ UPGRADED: Replaced text node with CodeBlock */} + +if (strcmp(s, "Hello") == 0) { + /* Strings evaluation matching evaluation block */ +}`} + /> + string-functions-table
    @@ -89,15 +98,16 @@ if (strcmp(s, "Hello") == 0) { /* equal */ }`}
  • Scope: local variables have block scope; globals have file or external linkage; {`static`} affects lifetime/linkage.
  • -
    -
    Pass by value vs. pointer
    -
    {`void inc_val(int x) { x = x + 1; }     // caller not changed
    -void inc_ref(int *p) { *p = *p + 1; }  // caller changed
    +        {/* ✅ UPGRADED: Replaced custom layout with explicit CodeBlock */}
    +        
    -        
    +inc_val(a); // value tracking: a is still 5 +inc_ref(&a); // reference tracking: a scales to 6`} + />
    @@ -114,21 +124,22 @@ inc_ref(&a); // a becomes 6`}
  • Recursion tree: visualize calls and costs per level for complexity analysis.
  • -
    -
    Factorial (recursive vs iterative)
    -
    {`// recursive
    +        {/* ✅ UPGRADED: Replaced manual pre formatting with CodeBlock */}
    +        
    -        
    +}`} + /> Sorting (intro): be familiar with bubble, insertion, selection; know their basic complexities. -
    -
    Linear search
    -
    {`int linear_search(int a[], int n, int key) {
    -  for (int i = 0; i < n; i++)
    +        {/* ✅ UPGRADED: Replaced with premium CodeBlock */}
    +        
    -        
    +}`} + />
    @@ -167,23 +180,28 @@ int fact_iter(int n) {

    Debugging Exercise

    -
    -
    Find and fix the errors
    -
    {`#include 
    +        
    +
    Find and fix the errors
    + + {/* ✅ UPGRADED: Replaced raw block with unified CodeBlock tracking */} + int sum_rows(int m[][3], int r) { int s = 0; - for (int i = 0; i <= r; i++) { // error: loop bounds (<=) incorrect + for (int i = 0; i <= r; i++) { // error: row index traversal overflow (<=) for (int j = 0; j < 3; j++) s += m[i][j]; } return s; -}`}
    +}`} + /> -
    Correct points
    -
      -
    • Fix row loop to {`for (int i = 0; i < r; i++)`} if {`r`} is the row count.
    • -
    • Array parameter requires known second dimension: {`m[][3]`}.
    • +
      Correct points
      +
        +
      • Fix row loop bound control configuration to {`for (int i = 0; i < r; i++)`}.
      • +
      • Array parameter blocks strictly require defined secondary metrics: {`m[][3]`}.
    @@ -201,4 +219,4 @@ int sum_rows(int m[][3], int r) {
    ); -}; +}; \ No newline at end of file diff --git a/app/sem1/c/content/chapter5.tsx b/app/sem1/c/content/chapter5.tsx index 581a763..ee26786 100644 --- a/app/sem1/c/content/chapter5.tsx +++ b/app/sem1/c/content/chapter5.tsx @@ -1,4 +1,8 @@ +"use client"; + import Image from "next/image"; +// NEXT.JS 15 FIX: Named import linked under unified layout block configuration +import { CodeBlock } from "../../../components/CodeBlock"; export const Ch5Content = () => { return ( @@ -21,13 +25,15 @@ export const Ch5Content = () => {
  • Pointer arithmetic: adding 1 advances by size of pointed type: {`p + 1`}.
  • -
    -
    Pointer example
    -
    {`int x = 10;
    +        {/* ✅ UPGRADED: Replaced manual pre formatting with CodeBlock */}
    +        
    -        
    +printf("%d\\n", *p); // prints 10 + +*p = 20; // directly modifies the original variable x`} + /> -
    @@ -52,12 +57,14 @@ printf("%d\n", *p); // prints 10
  • Pointer types: type of pointer determines arithmetic increment size.
  • -
    -
    Array access via pointer
    -
    {`int a[5] = {1,2,3,4,5};
    -int *p = a; // points to a[0]
    -int x = *(p + 2); // x == a[2] == 3`}
    -
    + {/* ✅ UPGRADED: Replaced primitive template structure with CodeBlock */} +
    @@ -72,13 +79,16 @@ int x = *(p + 2); // x == a[2] == 3`}
  • Pointers and functions: use pointers to pass large data (arrays, structures) efficiently.
  • -
    -
    Function modifies caller via pointer
    -
    {`void inc(int *p) { (*p)++; }
    +        {/* ✅ UPGRADED: Replaced text layout with unified CodeBlock */}
    +        
    -        
    +inc(&x); // explicit memory location address pass: x becomes 6`} + />
    @@ -93,13 +103,15 @@ inc(&x); // x becomes 6`}
  • Functions returning pointers to structures: return dynamically allocated structure pointers with care.
  • -
    -
    Structure pointer example
    -
    {`struct Point { int x, y; };
    -struct Point p = {1,2};
    +        {/* ✅ UPGRADED: Replaced with premium CodeBlock */}
    +        x);`}
    -
    + +printf("%d\\n", pp->x); // arrow pointer evaluation syntax`} + />
    @@ -117,17 +129,18 @@ printf("%d\n", pp->x);`}
  • Self-referential structures: used for linked lists: {`struct Node { int val; struct Node *next; };`}
  • -
    -
    Structure example
    -
    {`struct Student {
    +        {/* ✅ UPGRADED: Replaced old markup structure with dynamic CodeBlock */}
    +        
    -        
    +printf("%s\\n", s.name);`} + /> width={750} height={450} /> -
    @@ -152,17 +164,19 @@ printf("%s\n", s.name);`}
  • Access: use dot or arrow similar to structures.
  • -
    -
    Union example
    -
    {`union Number {
    +        {/* ✅ UPGRADED: Replaced manual pre code element with CodeBlock */}
    +        
    -        
    +n.f = 2.5; // overwrites the same memory coordinates location block`} + /> + union-layout width={700} height={380} /> -
    @@ -179,21 +192,27 @@ n.f = 2.5; // overwrites same memory`}

    Debugging Exercise

    -
    -
    Find and fix the errors
    -
    {`#include 
    +        
    +
    Find and fix the errors
    + + {/* ✅ UPGRADED: Raw block converted to dynamic tracking CodeBlock */} + #include int *make_array(int n) { - int a[n]; // local VLA on stack + int a[n]; // local Variable Length Array initialized strictly on local stack for (int i = 0; i < n; i++) a[i] = i; - return a; // error: returning address of stack memory -}`}
    - -
    Correct points
    -
      -
    • Do not return pointer to local stack array. Allocate with {`malloc`} and return pointer, or pass buffer from caller.
    • -
    • Always check result of {`malloc`} for NULL.
    • + + return a; // error: compilation warning / runtime fatal crash due to stack memory return +}`} + /> + +
      Correct points
      +
        +
      • Do not return pointer to local stack array. Allocate memory explicitly with {`malloc`} and return that pointer, or pass reference buffer directly from caller.
      • +
      • Always check result metrics of {`malloc`} for tracking against NULL conditions.
    @@ -208,6 +227,7 @@ int *make_array(int n) {
  • Create a function that returns a dynamically allocated array (use {`malloc`}) and document proper ownership and free semantics.
  • +
    ); -}; +}; \ No newline at end of file diff --git a/app/sem1/c/content/chapter6.tsx b/app/sem1/c/content/chapter6.tsx index 8ba2ade..aeafd1f 100644 --- a/app/sem1/c/content/chapter6.tsx +++ b/app/sem1/c/content/chapter6.tsx @@ -1,4 +1,8 @@ +"use client"; + import Image from "next/image"; +// NEXT.JS 15 FIX: Named import linked under unified layout block configuration +import { CodeBlock } from "../../../components/CodeBlock"; export const Ch6Content = () => { return ( @@ -23,14 +27,18 @@ export const Ch6Content = () => {
  • Random access: use {`fseek`} and {`ftell`} to move and query file position for binary I/O.
  • -
    -
    File Read (simple)
    -
    {`FILE *fp = fopen("data.bin", "rb");
    -if (fp == NULL) { perror("open"); exit(1); }
    +        {/* ✅ UPGRADED: Replaced manual pre formatting with CodeBlock */}
    +        
    -        
    +fclose(fp);`} + /> width={780} height={400} /> -
    @@ -68,13 +75,18 @@ fclose(fp);`}
  • free: release memory: {`free(ptr)`}. Avoid double-free and use-after-free.
  • -
    -
    Dynamic array (simple)
    -
    {`int *a = malloc(n * sizeof(int));
    -if (a == NULL) { perror("malloc"); exit(1); }
    -... use a ...
    -free(a);`}
    -
    + {/* ✅ UPGRADED: Replaced primitive markup with CodeBlock */} + + malloc-layout width={780} height={380} /> -
    @@ -97,13 +108,15 @@ free(a);`}
  • Common ops: insert at head, delete node, traverse; watch for NULL checks.
  • -
    -
    Insert at head (sketch)
    -
    {`struct Node *n = malloc(sizeof *n);
    +        {/* ✅ UPGRADED: Replaced raw layout structure with dynamic CodeBlock */}
    +        val = v;
     n->next = head;
    -head = n;`}
    -
    +head = n;`} + /> + linkedlist width={800} height={350} /> -
    @@ -127,11 +139,12 @@ head = n;`}
  • Conditional compilation: {`#ifdef`}, {`#ifndef`}, {`#if`}, {`#endif`}.
  • -
    -
    Macro example
    -
    {`#define MAX(a,b) ((a) > (b) ? (a) : (b))
    -int m = MAX(x, y);`}
    -
    + {/* ✅ UPGRADED: Replaced inline node tracking with CodeBlock */} + (b) ? (a) : (b)) +int m = MAX(x, y);`} + />
    @@ -140,22 +153,28 @@ int m = MAX(x, y);`}

    Debugging Exercise

    -
    -
    Find and fix the errors
    -
    {`#include 
    +        
    +
    Find and fix the errors
    + + {/* ✅ UPGRADED: Converted faulty code segment to tracking CodeBlock */} + #include char *make_message() { char buf[64]; snprintf(buf, sizeof(buf), "hello"); - return buf; // error: returning pointer to local stack buffer -}`}
    - -
    Correct points
    -
      -
    • Do not return pointer to local buffer. Allocate with {`malloc`} or let caller provide buffer.
    • -
    • Check allocations and use {`free`} to avoid leaks.
    • -
    • Always close files with {`fclose`} even on error paths.
    • + + return buf; // error: returning raw memory address pointer of local stack space +}`} + /> + +
      Correct points
      +
        +
      • Do not return pointer to local buffer. Allocate memory space explicitly with {`malloc`} or let caller pass external buffer hooks.
      • +
      • Track allocations and invoke explicit {`free`} metrics to avoid dangling memory leaks.
      • +
      • Always close dangling tracking descriptor structures with {`fclose`} even on conditional error branches.
    @@ -178,4 +197,4 @@ char *make_message() {

    ); -}; +}; \ No newline at end of file diff --git a/app/sem2/dsc/[chapter]/page.tsx b/app/sem2/dsc/[chapter]/page.tsx index 494c84d..27a5e77 100644 --- a/app/sem2/dsc/[chapter]/page.tsx +++ b/app/sem2/dsc/[chapter]/page.tsx @@ -27,11 +27,12 @@ const chapters = [ ]; type ChapterProps = { - params: { chapter: string }; + params: Promise<{ chapter: string }>; }; -export default function ChapterPage({ params }: ChapterProps) { - const currentIndex = chapters.findIndex((c) => c.id === params.chapter); +export default async function ChapterPage({ params }: ChapterProps) { + const resolvedParams = await params; + const currentIndex = chapters.findIndex((c) => c.id === resolvedParams.chapter); const chapter = chapters[currentIndex]; if (!chapter) { @@ -129,4 +130,4 @@ export default function ChapterPage({ params }: ChapterProps) {
    ); -} +} \ No newline at end of file diff --git a/app/sem2/dsc/content/chapter1.tsx b/app/sem2/dsc/content/chapter1.tsx index e37a8da..78a72e8 100644 --- a/app/sem2/dsc/content/chapter1.tsx +++ b/app/sem2/dsc/content/chapter1.tsx @@ -1,3 +1,7 @@ +"use client"; + +import { CodeBlock } from "../../../components/CodeBlock"; + export const Ch1Content = () => { return (
    @@ -43,19 +47,12 @@ export const Ch1Content = () => { Arrays are declared using a data type, array name and size.

    -
    - -
    - Code Example -
    - -
    -{`int numbers[5];
    +        
    -
    -        
    + />
    @@ -85,13 +82,12 @@ int values[5] = {10,20,30,40,50};`} Individual elements are accessed using indexes.

    -
    -
    -{`int arr[5]={10,20,30,40,50};
    +        
    -        
    + />

    Time Complexity: O(1) @@ -110,15 +106,12 @@ printf("%d",arr[2]);`} Traversal means visiting each element of the array one by one.

    -
    - -
    -{`for(int i=0;i<5;i++){
    +        
    -
    -        
    + />

    Time Complexity: O(n) @@ -138,18 +131,15 @@ printf("%d",arr[2]);`} Searching is used to find a specific element in an array.

    -
    - -
    -{`int key=30;
    +        
    -
    -        
    + />

    Time Complexity: O(n) @@ -170,17 +160,14 @@ for(int i=0;i<5;i++){ elements.

    -
    - -
    -{`for(int i=n;i>pos;i--){
    +        pos;i--){
        arr[i]=arr[i-1];
     }
     
     arr[pos]=value;`}
    -          
    - -
    + />

    Time Complexity: O(n) @@ -200,15 +187,12 @@ arr[pos]=value;`} Deletion removes an element and shifts remaining elements.

    -
    - -
    -{`for(int i=pos;i
    -
    -        
    + />

    Time Complexity: O(n) @@ -228,13 +212,10 @@ arr[pos]=value;`} Updating changes an existing value using its index.

    -
    - -
    -{`arr[1]=100;`}
    -          
    - -
    +

    Time Complexity: O(1) diff --git a/app/sem2/oops/[chapter]/page.tsx b/app/sem2/oops/[chapter]/page.tsx index 693e000..4a1a051 100644 --- a/app/sem2/oops/[chapter]/page.tsx +++ b/app/sem2/oops/[chapter]/page.tsx @@ -14,41 +14,45 @@ import BookmarkButton from "../../../components/BookmarkButton"; import { ArrowBigLeft, ArrowBigRight } from "lucide-react"; import { moduleQuizzes } from "@/lib/quizData"; import ChapterQuizInline from "../components/ChapterQuizInline"; - +import BookmarkButton from "@/app/components/BookmarkButton"; const righteous = Righteous({ subsets: ["latin"], weight: "400", variable: "--font-righteous", }); +// Syncing meta titles with the absolute C++ Object-Oriented content blocks created inside /content const chapters = [ { id: "ch0", title: "Course Outline", component: Ch0Content }, - { id: "ch1", title: "Introduction to Java", component: Ch1Content }, - { id: "ch2", title: "Classes and Objects", component: Ch2Content }, - { id: "ch3", title: "Inheritance & Polymorphism", component: Ch3Content }, - { id: "ch4", title: "Packages & Interfaces", component: Ch4Content }, - { id: "ch5", title: "Exception Handling", component: Ch5Content }, - { id: "ch6", title: "Threads", component: Ch6Content }, - { id: "ch7", title: "Generics", component: Ch7Content }, - { id: "ch8", title: "Java Library & Swing GUI", component: Ch8Content }, + { id: "ch1", title: "Paradigm Shift: POP vs. OOP", component: Ch1Content }, + { id: "ch2", title: "Classes, Objects, and Access Specifiers", component: Ch2Content }, + { id: "ch3", title: "Constructors and Destructors", component: Ch3Content }, + { id: "ch4", title: "Data Hiding and Encapsulation", component: Ch4Content }, + { id: "ch5", title: "Inheritance Paradigms", component: Ch5Content }, + { id: "ch6", title: "Polymorphism and Virtual Interfaces", component: Ch6Content }, + { id: "ch7", title: "Exception Handling Mechanisms", component: Ch7Content }, + { id: "ch8", title: "Generic Programming & SOLID Principles", component: Ch8Content }, ]; type ChapterProps = { - params: { chapter: string }; + params: Promise<{ chapter: string }> | { chapter: string }; }; -export default function ChapterPage({ params }: ChapterProps) { - const currentIndex = chapters.findIndex((c) => c.id === params.chapter); +export default async function ChapterPage({ params }: ChapterProps) { + // NEXT.JS 15 COMPLIANCE: Awaiting unified async evaluation for incoming segment route parameters + const resolvedParams = await params; + const chapterId = resolvedParams.chapter; + + const currentIndex = chapters.findIndex((c) => c.id === chapterId); const chapter = chapters[currentIndex]; if (!chapter) { - return

    Chapter not found

    ; + return

    Chapter not found

    ; } const ChapterComponent = chapter.component; const prevChapter = currentIndex > 0 ? chapters[currentIndex - 1] : null; - const nextChapter = - currentIndex < chapters.length - 1 ? chapters[currentIndex + 1] : null; + const nextChapter = currentIndex < chapters.length - 1 ? chapters[currentIndex + 1] : null; const chapterQuizSlugMap: Record = { ch1: "oops-intro-java", @@ -60,23 +64,25 @@ export default function ChapterPage({ params }: ChapterProps) { ch7: "oops-generics", ch8: "oops-java-lib-swing", }; - const chapterQuiz = moduleQuizzes.find((quiz) => quiz.slug === chapterQuizSlugMap[params.chapter]); + + // FIXED: Using pre-awaited chapterId here to prevent un-awaited Promise evaluation errors + const chapterQuiz = moduleQuizzes.find((quiz) => quiz.slug === chapterQuizSlugMap[chapterId]); return (
    -

    - Object-Oriented Programming in Java + Object-Oriented Programming

    {chapter.title}

    - +
    - {/* Navigation */} + + {/* Top Navigation */}
    {prevChapter ? ( -
    +
    {chapterQuiz ? ( @@ -142,4 +148,4 @@ export default function ChapterPage({ params }: ChapterProps) {
    ); -} +} \ No newline at end of file diff --git a/app/sem2/oops/content/chapter1.tsx b/app/sem2/oops/content/chapter1.tsx index a732d6c..4248d9d 100644 --- a/app/sem2/oops/content/chapter1.tsx +++ b/app/sem2/oops/content/chapter1.tsx @@ -1,3 +1,7 @@ +"use client"; + +import { CodeBlock } from "../../../components/CodeBlock"; + export const Ch1Content = () => { return (
    @@ -32,19 +36,19 @@ export const Ch1Content = () => {
  • boolean – true or false
  • -
    -
    Code Example
    -
    -{`int age = 19;
    +        
    -        
    + /> -

    - Diagram to add: java-primitive-sizes.png -

    + {/* Conceptual Visual Block replacing raw text link */} +
    +

    [ Memory Architecture: Java Primitive Bit Allocations ]

    +

    1-Byte (byte) → 2-Byte (short, char) → 4-Byte (int, float) → 8-Byte (long, double)

    +

    @@ -63,15 +67,14 @@ boolean isValid = true;`}
  • Narrowing: double to int, long to short (explicit cast)
  • -
    -
    -{`int a = 10;
    -double b = a;        // widening
    +        
    -        
    +int y = (int) x; // narrowing (explicit type truncation), y = 9`} + />
    @@ -85,18 +88,19 @@ int y = (int) x; // narrowing, y = 9`} fixed length determined at creation.

    -
    -
    -{`int[] marks = {85, 90, 75};
    +        
    -        
    + /> -

    - Diagram to add: java-array-memory.png -

    + {/* Heap Layout Mapping to prevent image load crash */} +
    +

    [ Heap Memory Reference Structure ]

    +

    marks Reference (Stack Pointer) ───> [ length: 3 | index 0: 85 | index 1: 90 | index 2: 75 ] (Contiguous Heap Object)

    +

    @@ -110,13 +114,12 @@ for (int i = 0; i < marks.length; i++) { for memory optimization.

    -
    -
    -{`String s = "openCSE";
    +        
    -        
    + />
    @@ -130,16 +133,13 @@ System.out.println(s.toUpperCase());`} operators. Parentheses improve readability and override precedence.

    -
    -
    -{`int a = 2 + 3 * 4;     // 14
    -int b = (2 + 3) * 4;   // 20
    +        
    -        
    - -

    Diagram: operator-precedence-java.png

    + />
    @@ -159,30 +159,34 @@ boolean result = (a < b) && (b < 50);`}
  • Jump: break, continue
  • -
    -
    -{`int n = 7;
    +         0) System.out.println("positive");
    +// Conditional statement evaluation
    +if (n > 0) {
    +    System.out.println("positive");
    +}
     
    -// switch
    +// Multi-way selection execution 
     switch (n) {
    -  case 1: System.out.println("one"); break;
    -  default: System.out.println("other");
    +  case 1: 
    +    System.out.println("one"); 
    +    break;
    +  default: 
    +    System.out.println("other");
     }
     
    -// loop
    +// Loop execution control with dynamic jump logic
     for (int i = 0; i < 5; i++) {
    -  if (i == 3) continue;
    +  if (i == 3) {
    +      continue; // bypass dynamic line terminal step
    +  }
       System.out.println(i);
     }`}
    -          
    -
    - -

    Diagram: loop-flowcharts.png

    + />
    ); -}; +}; \ No newline at end of file diff --git a/app/sem2/oops/content/chapter2.tsx b/app/sem2/oops/content/chapter2.tsx index e27d7a5..c92115b 100644 --- a/app/sem2/oops/content/chapter2.tsx +++ b/app/sem2/oops/content/chapter2.tsx @@ -1,3 +1,7 @@ +"use client"; + +import { CodeBlock } from "../../../components/CodeBlock"; + export const Ch2Content = () => { return (
    @@ -42,10 +46,9 @@ export const Ch2Content = () => { using the new keyword.

    -
    -
    Example: Defining and Using a Class
    -
    -{`class Student {
    +         {
       }
     }
     
    +// Inside main routine
     Student s = new Student();
     s.roll = 101;
     s.name = "Pushkar";
     s.show();`}
    +        />
    +
    +        {/* ✅ FIXED: Cleaned unintended text and mapped strictly to clean English context */}
    +        
    +

    [ Class Blueprint vs Heap Object Mapping ]

    +
    +{`Class Blueprint: Student [int roll, String name, show()]
    +                     │
    +         (Instantiation / new Keyword)
    +                     ▼
    +Heap Instance Memory: Student Object at Address 0x7a30
    +                 ├── roll: 101
    +                 └── name: "Pushkar" ───> Points to String Pool`}
               
    - -

    Diagram: class-object-diagram.png


    @@ -75,29 +90,29 @@ s.show();`} Java supports constructor overloading.

    -
    -
    -{`class Point {
    +        
    -        
    + />

    Java no longer recommends using finalizers. Modern Java uses try-with-resources and - garbage collection. + garbage collection frameworks for automatic resource cleanup.

    @@ -110,28 +125,27 @@ Point p2 = new Point(5, 8);`}

    Java provides four levels of access control:

      -
    • public – accessible everywhere
    • -
    • private – accessible only inside class
    • -
    • protected – class + subclasses + same package
    • -
    • default – class + same package
    • +
    • public – accessible everywhere across packages
    • +
    • private – accessible only inside the enclosing class bounds
    • +
    • protected – accessible to the class, subclasses, and same package components
    • +
    • default – accessible strictly within the same package directory
    -
    -
    -{`class Employee {
    +        
    -        
    + />
    @@ -142,24 +156,23 @@ Point p2 = new Point(5, 8);`}

    Methods operate on object data. The this keyword refers to - the current object and resolves naming conflicts. + the current object instance and resolves global variable naming conflicts.

    -
    -
    -{`class Box {
    +        
    -        
    + />
    @@ -169,31 +182,38 @@ Point p2 = new Point(5, 8);`}

    Useful Built-in Classes (String, Character, StringBuffer)

    - Java provides several commonly used classes for text processing. + Java provides several commonly used classes for advanced text and stream processing.

      -
    • String – immutable text
    • -
    • Character – wrapper for char type
    • -
    • StringBuffer – mutable and thread-safe
    • +
    • String – immutable character sequence stored inside String Pool memory
    • +
    • Character – object-oriented wrapper class for standard primitive char variables
    • +
    • StringBuffer – mutable, synchronized, and completely thread-safe character buffer
    -
    -
    -{`String name = "Pushkar";
    +        
    +
    +        
    +

    [ String Pool Immutability Mechanics ]

    +
    +{`Stack Pointer                     String Constant Pool (Heap Area)
    +   name ─────────────────────────> [ "Pushkar" ] (Address: 0x99)
    +                                      
    +   upper ────────────────────────> [ "PUSHKAR" ] (New memory allocated on modification)`}
               
    - -

    Diagram: string-immutability.png

    ); -}; +}; \ No newline at end of file diff --git a/app/sem2/oops/content/chapter3.tsx b/app/sem2/oops/content/chapter3.tsx index e91526a..00a3942 100644 --- a/app/sem2/oops/content/chapter3.tsx +++ b/app/sem2/oops/content/chapter3.tsx @@ -1,3 +1,7 @@ +"use client"; + +import { CodeBlock } from "../../../components/CodeBlock"; + export const Ch3Content = () => { return (
    @@ -27,26 +31,36 @@ export const Ch3Content = () => {
  • Java supports single inheritance of classes
  • -
    -
    Simple Inheritance Example
    -
    -{`class Animal {
    -  void eat() { System.out.println("eating"); }
    +        
    +
    +        {/* ✅ FIXED: Replaced broken inheritance-tree-basic.png reference */}
    +        
    +

    [ Base Class vs Derived Class Tree ]

    +
    +{`Superclass: Animal [ eat() ]
    +               │
    +               ▼  (extended by subclass)
    +Subclass:   Dog    [ bark() ] ───> inherits eat() automatically`}
               
    - -

    - Diagram: inheritance-tree-basic.png -


    @@ -60,9 +74,9 @@ d.bark(); // own method`} fields, methods, and constructors.

    -
    -
    -{`class Person {
    +        
    +
    +        {/* ✅ FIXED: Replaced broken super-call-flow.png with text trace mapping */}
    +        
    +

    [ Constructor Execution Call Flow ]

    +
    +{`new Student("Raushan", 57) ──> Student Constructor ──> super(name) ──> Person Constructor Initializes Name`}
               
    - -

    Diagram: super-call-flow.png


    @@ -90,18 +109,23 @@ class Student extends Person {

    In multilevel inheritance, a subclass becomes a superclass for another class. - Java supports **multilevel** but not **multiple** inheritance of classes. + Java supports multilevel but not multiple inheritance of classes.

    -
    -
    -{`class A { }
    +         B -> C`}
    +class C extends B { }     // Direct Chain Mapping: A -> B -> C`}
    +        />
    +
    +        {/* ✅ FIXED: Replaced broken multilevel-hierarchy.png map */}
    +        
    +

    [ Class Hierarchy Lineage ]

    +
    +{`[ Class A (Grandparent) ] ───> [ Class B (Parent) ] ───> [ Class C (Child) ]`}
               
    - -

    Diagram: multilevel-hierarchy.png


    @@ -116,22 +140,26 @@ class C extends B { } // A -> B -> C`}

      -
    • Used to provide specific implementation
    • -
    • Must have same method name, return type and parameters
    • -
    • Only instance methods can be overridden
    • +
    • Used to provide specific implementations for derived classes
    • +
    • Must contain the exact same method name, return type, and parameters
    • +
    • Only instance methods can be overridden; static declarations cannot
    -
    -
    -{`class Shape {
    -  void draw() { System.out.println("drawing shape"); }
    +        
    -        
    + />
    @@ -142,19 +170,24 @@ class Circle extends Shape {

    Runtime polymorphism determines the method to execute based on the actual - object type, not reference type. + object type on the heap at runtime, not the reference pointer on the stack.

    -
    -
    -{`Shape s = new Circle();  // reference of Shape, object of Circle
    -s.draw();                 // calls Circle's draw (runtime)`}
    +        
    +
    +        {/* ✅ FIXED: Replaced broken dynamic-dispatch.png with clean trace representation */}
    +        
    +

    [ Runtime Polymorphism Lookup ]

    +
    +{`Stack Reference: Shape s ───────Points to───────> Heap Instance: new Circle()
    +                                                          │
    +   s.draw() ─── Looks up implementation context ──────────┘ ───> Triggers Circle.draw()`}
               
    - -

    - Diagram: dynamic-dispatch.png -


    @@ -164,16 +197,20 @@ s.draw(); // calls Circle's draw (runtime)`}

    final Keyword with Inheritance

      -
    • final class – cannot be inherited
    • -
    • final method – cannot be overridden
    • +
    • final class – restricts the entire class architecture from being extended or inherited
    • +
    • final method – allows inheritance but completely blocks subclasses from overriding the routine
    -
    -{`final class Constants { }       // cannot be extended
    -class A {
    -  final void show() { }
    +        
    +        />
           
     
           
    @@ -183,26 +220,27 @@ class A {

    The Object Class

    - Every Java class implicitly extends Object, the root of the class hierarchy. - Important methods include: + Every Java class implicitly extends Object, which serves as the ultimate root of the class hierarchy. + Important utility methods include:

      -
    • toString() – returns string representation
    • -
    • equals() – compares two objects
    • -
    • hashCode()
    • -
    • getClass()
    • +
    • toString() – returns a string representation of the object instance
    • +
    • equals() – compares memory pointers or custom logical equality criteria
    • +
    • hashCode() – provides hash codes for memory indexing
    • +
    • getClass() – loads class metadata definitions at runtime
    -
    -{`class Demo { }
    +        
    +System.out.println(d.toString());  // Prints structural details (e.g., Demo@7a30)
    +System.out.println(d.getClass());   // Returns class type meta information`}
    +        />
           
     
         
    ); -}; +}; \ No newline at end of file diff --git a/app/sem2/oops/content/chapter4.tsx b/app/sem2/oops/content/chapter4.tsx index a74fc39..5437721 100644 --- a/app/sem2/oops/content/chapter4.tsx +++ b/app/sem2/oops/content/chapter4.tsx @@ -1,3 +1,7 @@ +"use client"; + +import { CodeBlock } from "../../../components/CodeBlock"; + export const Ch4Content = () => { return (
    @@ -25,10 +29,9 @@ export const Ch4Content = () => {
  • User-defined packages: created using the package keyword
  • -
    -
    Example: Creating and Using a Package
    -
    -{`// file: src/com/demo/Calculator.java
    +        
    +
    +        {/* ✅ FIXED: Replaced broken package-folder-structure.png with explicit directory tree */}
    +        
    +

    [ Physical Disk Directory Architecture ]

    +
    +{`src/
    +├── com/
    +│   └── demo/
    +│       └── Calculator.java     ───> declares: package com.demo;
    +└── Main.java                   ───> executes: import com.demo.Calculator;`}
               
    - -

    - Diagram: package-folder-structure.png -


    @@ -66,18 +76,18 @@ public class Main {

      -
    • Specific import: import java.util.ArrayList;
    • -
    • Wildcard import: import java.util.*;
    • +
    • Specific import: import java.util.ArrayList; (Loads single definition)
    • +
    • Wildcard import: import java.util.*; (Loads matches on-demand)
    -
    -
    -{`import java.util.ArrayList;
    +         list = new ArrayList<>();
     list.add(5);`}
    -          
    -
    + />
    @@ -88,33 +98,43 @@ list.add(5);`}

    An interface specifies a set of abstract methods that implementing classes must define. - Interfaces support abstraction and multiple inheritance in Java. + Interfaces support full structural abstraction and multiple inheritance workflows in Java.

      -
    • Methods are abstract by default (before Java 8)
    • -
    • Variables are public, static, and final
    • -
    • A class uses implements to implement an interface
    • +
    • Methods are abstract and public by default (before Java 8 specifications)
    • +
    • Variables are implicitly public, static, and final
    • +
    • A standard class uses the implements keyword to fulfill contracts
    -
    -
    -{`interface Drawable {
    +        
    +
    +        {/* ✅ FIXED: Replaced broken interface-implementation.png with clear contract map */}
    +        
    +

    [ Abstraction Contract Binding ]

    +
    +{`Interface Blueprint: Drawable [ abstract draw() ]
    +                             ▲
    +                             │ (implements contract)
    +Concrete Class:      Circle   [ concrete draw() { print logic } ]`}
               
    - -

    Diagram: interface-implementation.png


    @@ -125,31 +145,35 @@ d.draw();`}

    From Java 8 onwards, interfaces can include default and static methods, - allowing common functionality without breaking existing implementations. + allowing common fallback functionality without breaking existing implementations.

    -
    -
    -{`interface Vehicle {
    -  void start();
    +        
    -        
    +c.show(); // Calls default implementation safely +int v = Vehicle.version(); // Triggers isolated static utility scope`} + />
    @@ -159,16 +183,21 @@ int v = Vehicle.version();`}

    Putting It All Together

    - Packages organize code. Interfaces define contracts. When combined, they allow - large Java applications to be structured cleanly and extended easily. This - module prepares the foundation for frameworks, APIs and modular application design. + Packages organize your underlying code namespaces, while interfaces define structural decoupled contracts. + When combined, they allow large scale Java applications to be structured cleanly, avoiding deep regression dependencies.

    -

    - Diagrams to add: interface-hierarchy.png, package-namespace.png -

    + {/* ✅ FIXED: Bundled final multiple design mappings into a cohesive conceptual terminal visualization */} +
    +

    [ Enterprise Architecture Assembly Flow ]

    +
    +{`[ Domain Namespace Package: com.opencse ]
    +     └── Interfaces (Strict Modular Blueprints)
    +              └── Concrete Classes (Decoupled Scalable Drivers)`}
    +          
    +
    ); -}; +}; \ No newline at end of file diff --git a/app/sem2/oops/content/chapter5.tsx b/app/sem2/oops/content/chapter5.tsx index 054cc20..613c6ab 100644 --- a/app/sem2/oops/content/chapter5.tsx +++ b/app/sem2/oops/content/chapter5.tsx @@ -1,3 +1,7 @@ +"use client"; + +import { CodeBlock } from "../../../components/CodeBlock"; + export const Ch5Content = () => { return (
    @@ -21,16 +25,31 @@ export const Ch5Content = () => {

      -
    • Exception – indicates runtime errors that can be handled
    • -
    • Error – serious issues not expected to be handled (e.g. OutOfMemoryError)
    • -
    • All exceptions derive from the class Throwable
    • +
    • Exception – indicates runtime conditions that a reasonable application might want to catch
    • +
    • Error – indicates serious problems that a reasonable application should not try to catch (e.g., OutOfMemoryError)
    • +
    • All exception and error types derive from the root class Throwable

    - The main advantage of Java's exception system is **separation of error-handling code from normal logic**. + The main advantage of Java's exception system is separation of error-handling code from normal execution logic.

    -

    Diagram: exception-hierarchy.png

    + {/* ✅ FIXED: Replaced broken exception-hierarchy.png with precise ASCII tree */} +
    +

    [ Throwable Class Hierarchy Structure ]

    +
    +{`                  [ Throwable ]
    +                       │
    +        ┌──────────────┴──────────────┐
    +        ▼                             ▼
    +   [ Exception ]                  [ Error ]
    +        │                             │
    +  ┌─────┴──────────────┐              ├── StackOverflowError
    +  ▼                    ▼              └── OutOfMemoryError
    +[ Checked ]     [ RuntimeException ] (Unchecked)
    +(IOException)   (NullPointerException, ArithmeticException)`}
    +          
    +

    @@ -40,24 +59,27 @@ export const Ch5Content = () => {

    Types of Exceptions

      -
    • Checked exceptions – must be caught or declared (IOException, SQLException)
    • -
    • Unchecked exceptions – inherit from RuntimeException (ArithmeticException, NullPointerException)
    • -
    • Errors – not meant to be handled (StackOverflowError)
    • +
    • Checked exceptions – Evaluated at compile-time. The compiler forces the code to either catch or declare them using throws (e.g., IOException,編SQLException).
    • +
    • Unchecked exceptions – Evaluated at runtime. They inherit from RuntimeException and usually imply programmatic or logical bugs (e.g., ArithmeticException, NullPointerException).
    • +
    • Errors – Fatal system failures that are external to the application control and not meant to be intercepted or handled.
    -
    -
    Unchecked Exception Example
    -
    -{`int x = 10 / 0;   // ArithmeticException`}
    -          
    -
    + -
    -
    Checked Exception Example
    -
    -{`FileReader fr = new FileReader("abc.txt");   // must be handled`}
    -          
    -
    +
    @@ -67,26 +89,25 @@ export const Ch5Content = () => {

    Using try, catch, and finally

    - A try block contains statements that may throw an exception. - catch blocks handle the specific exception types. - The finally block executes whether or not an exception occurs. + A try block isolates statements that may throw an anomaly. + catch blocks intercept specific matched exception instances, while the + finally block executes unconditionally, making it ideal for deterministic cleanup steps.

    -
    -
    -{`try {
    +        
    -        
    + />
      -
    • Use multiple catch blocks for multiple exception types
    • -
    • finally is often used to close files, connections, or release resources
    • +
    • Multiple catch blocks must be ordered from specific subclasses to broad superclasses to avoid compilation blocking.
    • +
    • The finally block executes even if a catch block contains a return instruction, ensuring deterministic release of system socket descriptors or file buffers.
    @@ -97,22 +118,28 @@ export const Ch5Content = () => {

    throw and throws

    - throw explicitly throws an exception. - throws declares that a method may throw an exception. + The throw keyword manually triggers an exception instance down the execution thread pipeline. + The throws keyword acts as a method signature contract, signaling callers to handle potential checked exceptions.

    -
    -
    -{`void checkAge(int age) {
    -  if(age < 18)
    -    throw new IllegalArgumentException("Too young");
    -}
    -
    -void readFile() throws IOException {
    -  FileReader f = new FileReader("data.txt");
    +        
    -        
    + />
    @@ -121,14 +148,14 @@ void readFile() throws IOException {

    Java’s Built-in Exceptions

    -

    Commonly asked in exams:

    +

    Frequently encountered runtime anomalies in core frameworks and examinations:

      -
    • ArithmeticException
    • -
    • ArrayIndexOutOfBoundsException
    • -
    • NullPointerException
    • -
    • NumberFormatException
    • -
    • IOException
    • +
    • ArithmeticException – Division operations involving invalid fractional steps or zero dividers.
    • +
    • ArrayIndexOutOfBoundsException – Attempting to reference index boundaries beyond an array bounds configuration.
    • +
    • NullPointerException – Triggering instance methods or reading variable fields over an unallocated null pointer.
    • +
    • NumberFormatException – Failure parsing alphanumeric string inputs into numeric variable containers.
    • +
    • IOException – Unresolved terminal interface drops or failed physical storage device streams.
    @@ -139,23 +166,25 @@ void readFile() throws IOException {

    Creating Custom Exceptions

    - User-defined exceptions extend the Exception class. + User-defined exceptions extend the foundational Exception class to represent explicit domain boundary failures.

    -
    -
    -{`class InvalidMarksException extends Exception {
    -  InvalidMarksException(String msg) {
    -    super(msg);
    +         100)
    -    throw new InvalidMarksException("Invalid marks");
    +class EvaluationEngine {
    +  void check(int m) throws InvalidMarksException {
    +    if (m < 0 || m > 100) {
    +      throw new InvalidMarksException("Provided metric evaluates out of standardized scoring scales.");
    +    }
    +  }
     }`}
    -          
    -
    + />
    @@ -165,17 +194,26 @@ void check(int m) throws InvalidMarksException {

    Summary

    - Exception handling improves program reliability by allowing controlled - error management. Using try-catch-finally, throwing exceptions, - and understanding the exception class hierarchy are essential skills for - robust Java development. + Exception handling enhances program resilience by separating error recovery routines from core business operations. + Mastering try-catch-finally gating, structured exception propagation, and custom class extensions prevents ungraceful process terminations.

    -

    - Diagrams to insert: try-catch-flowchart.png, exception-types-table.png -

    + {/* ✅ FIXED: Replaced p-text reminders and broken flowchart links with a clean ASCII lifecycle flow chart */} +
    +

    [ Try-Catch-Finally Execution Pipeline ]

    +
    +{` [ Try Block Starts ] ─── Anomaly Occurs? ───► (Yes) ───► [ Catch Block Handles Anomaly ]
    +          │                                                               │
    +         (No)                                                             │
    +          ▼                                                               ▼
    +   [ Completes Try ] ───────────────────────────────────────────► [ Finally Block Executes ]
    +                                                                          │
    +                                                                          ▼
    +                                                                [ Normal Flow Resumes ]`}
    +          
    +
    ); -}; +}; \ No newline at end of file diff --git a/app/sem2/oops/content/chapter6.tsx b/app/sem2/oops/content/chapter6.tsx index b10d55d..fdb66b9 100644 --- a/app/sem2/oops/content/chapter6.tsx +++ b/app/sem2/oops/content/chapter6.tsx @@ -1,3 +1,7 @@ +"use client"; + +import { CodeBlock } from "../../../components/CodeBlock"; + export const Ch6Content = () => { return (
    @@ -21,14 +25,27 @@ export const Ch6Content = () => {

      -
    • Thread – a lightweight process
    • -
    • Multithreading – executing multiple threads
    • -
    • Context switching – CPU switching between threads
    • +
    • Thread – a lightweight process with its own call stack
    • +
    • Multithreading – executing multiple tasks concurrently within the same program space
    • +
    • Context switching – the CPU scheduling mechanism shifting between active threads
    -

    - Diagram: thread-life-cycle.png -

    + {/* ✅ FIXED: Replaced broken thread-life-cycle.png with ASCII State Machine */} +
    +

    [ Java Thread Life Cycle States ]

    +
    +{`  [ New ] ─── start() ───► [ Runnable ] ◄───(Scheduled)───► [ Running ]
    +                               ▲                                 │
    +                               │                                 ▼
    +                        Object.notify()                   Object.wait() / sleep()
    +                               │                                 │
    +                               └─────────── [ Blocked ] ◄────────┘
    +                                                │
    +                                         (Task Completes)
    +                                                ▼
    +                                          [ Terminated ]`}
    +          
    +

    @@ -38,20 +55,19 @@ export const Ch6Content = () => {

    The Main Thread

    - Every Java program starts with one thread: the main thread. + Every Java program starts with one default execution point: the main thread, spawned automatically by the JVM.

    -
    -
    -{`public class MainThreadDemo {
    +        
    -        
    + />
    @@ -61,44 +77,44 @@ export const Ch6Content = () => {

    Creating Threads

    - Java supports two ways to create threads: + Java supports two distinct structural implementations to instantiate a custom execution path:

      -
    • Extending the Thread class
    • -
    • Implementing the Runnable interface
    • +
    • Extending the foundational Thread class directly
    • +
    • Implementing the functional Runnable interface wrapper
    -
    -
    Method 1: Extending Thread
    -
    -{`class MyThread extends Thread {
    +        
    -        
    +t.start(); // Allocates machine registers and schedules the run() method`} + /> -
    -
    Method 2: Implementing Runnable
    -
    -{`class MyTask implements Runnable {
    +        
    -        
    + />

    - Runnable is preferred when a class must extend another class. + Design Note: Implementing Runnable is highly preferred in enterprise systems because it saves your single class inheritance slot from being locked down.

    @@ -108,19 +124,18 @@ t.start();`}

    Creating Multiple Threads

    -
    -
    -{`for (int i = 1; i <= 3; i++) {
    +         {
    -    System.out.println("Running: " + Thread.currentThread().getName());
    +    System.out.println("Active Target Workspace: " + Thread.currentThread().getName());
       });
       t.start();
     }`}
    -          
    -
    + />

    - Each thread runs independently. Order of execution is not guaranteed. + Each thread spins up as an isolated execution trace. The exact processing order is entirely governed by the underlying OS thread scheduler.

    @@ -131,14 +146,15 @@ t.start();`}

    Thread Priorities

    - Every thread has a priority (1 to 10). Higher priority increases the chance - of being scheduled first. + Threads carry scheduling weights ranking from 1 up to 10. Higher ranks inform the system to favor allocating CPU slices to these nodes whenever possible.

    -
    -{`Thread t = new Thread(new MyTask());
    -t.setPriority(Thread.MAX_PRIORITY);  // 10`}
    -        
    + System.out.println("High priority stream task.")); +t.setPriority(Thread.MAX_PRIORITY); // Assigns maximum weight threshold = 10 +t.start();`} + />
    @@ -148,25 +164,34 @@ t.setPriority(Thread.MAX_PRIORITY); // 10`}

    Synchronization

    - When multiple threads access shared data, race conditions may occur. - Synchronization ensures only one thread accesses critical code at a time. + When overlapping threads mutating shared variables cause race conditions, the synchronized keyword serializes access to critical segments.

    -
    -{`class Counter {
    +        
    -
    -        

    - Only one thread can execute a synchronized method or block on an object at once. -

    - -

    - Diagram: synchronization-lock.png -

    + /> + + {/* ✅ FIXED: Replaced broken synchronization-lock.png with an ASCII monitor map */} +
    +

    [ Intrinsic Object Monitor Lock Mechanics ]

    +
    +{`Thread A ───(Acquires Lock)───► [ Critical Method Scope ] ───(Releases Lock)───► Complete
    +                                          ▲
    +Thread B ───(Lock Occupied)───────► [ Blocked Queue ] (Waits till object monitor drops)`}
    +          
    +

    @@ -176,18 +201,21 @@ t.setPriority(Thread.MAX_PRIORITY); // 10`}

    Interthread Communication

    - Java provides wait(), notify(), and notifyAll() - for threads to communicate inside synchronized blocks. + Java facilitates cross-thread signaling loops using wait(), notify(), and notifyAll() inside monitor scopes.

    -
    -{`synchronized(obj) {
    -  obj.wait();       // thread waits
    -  obj.notify();     // wakes one thread
    +        
    +        />
     
    -        

    Used in producer-consumer problems and buffering.

    +

    These routines provide low-level synchronization blocks for Producer-Consumer algorithms and concurrent ring buffers.


    @@ -197,10 +225,9 @@ t.setPriority(Thread.MAX_PRIORITY); // 10`}

    Using Multithreading

      -
    • Parallel computation
    • -
    • Animations and background tasks
    • -
    • Real-time systems
    • -
    • Servers handling multiple clients
    • +
    • Asynchronous parallel matrix and batch algorithms
    • +
    • Preventing frame rate drops by isolating UI render threads from heavy disk I/O operations
    • +
    • Distributed server systems spinning up separate request handlers for independent remote sockets
    @@ -211,17 +238,11 @@ t.setPriority(Thread.MAX_PRIORITY); // 10`}

    Summary

    - Threads enable concurrent execution in Java. Learning how to create threads, - synchronize them, and manage communication is essential for advanced Java - programming and real-world applications such as GUI programming, networking, - and server-side processing. -

    - -

    - Add diagrams: thread-cycle.png, synchronization-flow.png + Threads form the backbone of highly performant, responsive systems in Java. + Mastering lifecycle transitions, implementing concurrent task structures, and resolving resource race conditions are vital steps for enterprise framework engineering.

    ); -}; +}; \ No newline at end of file diff --git a/app/sem2/oops/content/chapter7.tsx b/app/sem2/oops/content/chapter7.tsx index 0f599d8..aac6454 100644 --- a/app/sem2/oops/content/chapter7.tsx +++ b/app/sem2/oops/content/chapter7.tsx @@ -1,3 +1,7 @@ +"use client"; + +import { CodeBlock } from "../../../components/CodeBlock"; + export const Ch7Content = () => { return (
    @@ -22,20 +26,28 @@ export const Ch7Content = () => {

      -
    • Eliminates unsafe type casting
    • -
    • Enables strong type-checking
    • -
    • Allows reusable, flexible classes and methods
    • +
    • Eliminates unsafe explicit type casting
    • +
    • Enables strong compile-time type-checking
    • +
    • Allows highly reusable, flexible classes and methods
    -
    -
    -{`ArrayList list = new ArrayList<>();
    +         list = new ArrayList<>();
     list.add("hello");
    -// list.add(10);   // compile-time error`}
    +// list.add(10);   // Compile-Time Error: strong type safety prevents mixing types`}
    +        />
    +
    +        {/* ✅ FIXED: Replaced broken generic-type-parameter.png reference with ASCII diagram */}
    +        
    +

    [ Generic Type Parameter Anatomy ]

    +
    +{`   ArrayList < String >  list  =  new  ArrayList <> ();
    +     │          │                                 │
    +Class Type   Type Argument                Diamond Operator
    +(Container)  (Enforces Type)             (Infers Type automatically)`}
               
    - -

    Diagram: generic-type-parameter.png


    @@ -45,30 +57,31 @@ list.add("hello");

    Generic Class

    - A generic class defines one or more type parameters to be used in the class. + A generic class defines one or more type parameters to be used throughout its properties and signatures.

    -
    -
    Example: A Simple Generic Box
    -
    -{`class Box {
    -  T value;
    +         {
    +  private T value;
     
    -  Box(T value) {
    +  public Box(T value) {
         this.value = value;
       }
     
    -  T get() { return value; }
    +  public T get() { 
    +    return value; 
    +  }
     }
     
    +// Usage with Integer wrappers
     Box b = new Box<>(100);
     System.out.println(b.get());`}
    -          
    -
    + />
      -
    • T, E, K, V are common type parameter names
    • -
    • You can define multiple type parameters, e.g. Box<T, U>
    • +
    • T (Type), E (Element), K (Key), V (Value) are standard naming conventions.
    • +
    • You can define multiple type parameters inside a single diamond schema, e.g., Box<T, U>.
    @@ -78,25 +91,27 @@ System.out.println(b.get());`}

    Generic Class with Two Type Parameters

    -
    -
    -{`class Pair {
    -  K key;
    -  V value;
    +        

    + Useful for multi-value architectural data storage like mappings and tuple containers. +

    + + { + private K key; + private V value; - Pair(K key, V value) { + public Pair(K key, V value) { this.key = key; this.value = value; } + + public K getKey() { return key; } + public V getValue() { return value; } } Pair p = new Pair<>("age", 20);`} -
    -
    - -

    - Useful in maps, key-value data storage, and utility methods. -

    + />

    @@ -106,25 +121,32 @@ Pair p = new Pair<>("age", 20);`}

    Generic Methods

    - A method can declare its own type parameter independent of the class. + A method can declare its own independent type parameters, scope-locked inside its own signature regardless of whether the enclosing class is generic or not.

    -
    -
    -{`class Utils {
    -  static  void print(T value) {
    +         void print(T value) {
         System.out.println(value);
       }
     }
     
    +// Runtime automated inference
     Utils.print("hello");
     Utils.print(123);`}
    +        />
    +
    +        {/* ✅ FIXED: Replaced broken generic-method-flow.png with clean signature map */}
    +        
    +

    [ Generic Method Signature Analysis ]

    +
    +{`public static      void   print (  T value  )
    +                 │              │       │
    +          Type Parameter    Return Type  Parameter Type Scope`}
               
    - -

    - Diagram: generic-method-flow.png -


    @@ -134,24 +156,22 @@ Utils.print(123);`}

    Bounded Type Parameters

    - Bounds restrict the types that can be passed to generics. + Bounds place upper limits on type parameters, restricting the family of classes that can be supplied to a generic argument.

    -
    -
    -{`class Numbers {   // only Number subclasses allowed
    -  T num;
    -  Numbers(T num) { this.num = num; }
    +         {   // restricts types to Number or its subclasses
    +  private T num;
    +  
    +  public Numbers(T num) { 
    +    this.num = num; 
    +  }
     }
     
    -Numbers n1 = new Numbers<>(10);
    -Numbers n2 = new Numbers<>("hi"); // error`}
    -          
    -
    - -

    - Bounded generics are widely used in sorting, comparisons, and collections. -

    +Numbers n1 = new Numbers<>(10); // Compiles fine +// Numbers n2 = new Numbers<>("hi"); // Compile-Time Error: String does not extend Number`} + />
    @@ -161,25 +181,42 @@ Numbers n2 = new Numbers<>("hi"); // error`}

    Wildcards

    - Wildcards allow flexibility when working with unknown or partially known types. + Wildcards represented by the question mark symbol (?) offer polymorphic argument compatibility when dealing with unknown or collections of partially known families.

      -
    • ? – unknown type
    • -
    • ? extends T – upper bounded
    • -
    • ? super T – lower bounded
    • +
    • List<?> – Unbounded wildcard. Accepts list collections of any arbitrary element type.
    • +
    • List<? extends T> – Upper bounded wildcard. Restricts to families extending type T (Safe for reading operations).
    • +
    • List<? super T> – Lower bounded wildcard. Restricts to superclasses above type T (Safe for writing operations).
    -
    -
    -{`void show(List list) { }           // accepts any type
    -void showNum(List l) // only Number or its subclasses`}
    +         list) { }           
    +
    +  // Upper Bounded: Accepts lists of Number, Integer, Double, etc.
    +  void showNum(List l) { } 
    +}`}
    +        />
    +
    +        {/* ✅ FIXED: Replaced broken wildcards-hierarchy.png with bounded tree chart */}
    +        
    +

    [ Wildcard Bounds Structural Hierarchy ]

    +
    +{`         [ Object ]
    +             ▲
    +             │  (? super Number) ── Lower bound limit includes ancestors
    +        [ Number ]
    +             ▲
    +             │  (? extends Number) ── Upper bound limit includes descendants
    +    ┌────────┴────────┐
    +[ Integer ]       [ Double ]`}
               
    - -

    - Diagram: wildcards-hierarchy.png -


    @@ -189,23 +226,23 @@ void showNum(List l) // only Number or its subclasses`}

    Type Erasure

    - Java implements generics using type erasure. After compilation, - all generic type information is removed and replaced with raw types. + Java implements generics strictly at compile time through a compiler technique called type erasure. + To ensure backward compatibility with older legacy codebases, all generic tokens are completely stripped off and replaced with raw types (usually Object or the bound limit) during execution compilation.

      -
    • Generic type parameters exist only at compile time
    • -
    • Ensures backward compatibility with older Java versions
    • -
    • Restrictions: no primitive generics, no runtime type-checking of generic types
    • +
    • Generic parameters exist exclusively for compile-time structural validation checks.
    • +
    • Restrictions: You cannot instantiate generics with primitives (e.g., List<int> is invalid) or carry out runtime type evaluations like instanceof T.
    -
    -{`ArrayList a1 = new ArrayList<>();
    +         a1 = new ArrayList<>();
     ArrayList a2 = new ArrayList<>();
     
    -// at runtime:
    -a1.getClass() == a2.getClass();   // true`}
    -        
    +// Both instances evaluate to the identical underlying raw class at runtime +System.out.println(a1.getClass() == a2.getClass()); // Outputs: true`} + />
    @@ -215,16 +252,11 @@ a1.getClass() == a2.getClass(); // true`}

    Summary

    - Generics help ensure type-safety and reusable code. Understanding generic - classes, methods, wildcards, and type erasure prepares you for Java Collections, - frameworks, and industry-level application development. -

    - -

    - Diagrams to insert: generic-class-diagram.png, wildcard-usage.png + Generics eliminate unsafe casting errors and enforce robust static types over decoupled abstract code structures. + Grasping generic class configurations, bounds, wildcards, and compiler type erasure patterns forms the foundation for writing high-performance frameworks and managing the Java Collections API effectively.

    ); -}; +}; \ No newline at end of file diff --git a/app/sem2/oops/content/chapter8.tsx b/app/sem2/oops/content/chapter8.tsx index 3001f2e..4f3062e 100644 --- a/app/sem2/oops/content/chapter8.tsx +++ b/app/sem2/oops/content/chapter8.tsx @@ -1,3 +1,7 @@ +"use client"; + +import { CodeBlock } from "../../../components/CodeBlock"; + export const Ch8Content = () => { return (
    @@ -22,27 +26,34 @@ export const Ch8Content = () => {

      -
    • String objects cannot be changed once created
    • -
    • StringBuffer is used when thread-safety is required
    • -
    • StringBuilder is faster but not synchronized
    • +
    • String – Content cannot be modified post-allocation (Stored inside String Constant Pool).
    • +
    • StringBuffer – Thread-safe, synchronized buffer mutable allocation (Safe for multi-threaded setups).
    • +
    • StringBuilder – Non-synchronized, faster mutable buffer (Preferred for single-threaded sequential routines).
    -
    -
    -{`String s = "Hello";
    -String s2 = s.replace("H", "Y"); // new object
    +        
    +
    +        {/* ✅ FIXED: Replaced broken string-vs-stringbuffer.png with safe matrix representation */}
    +        
    +

    [ String Sequence Specifications ]

    +
    +{`Feature         │ String           │ StringBuffer     │ StringBuilder
    +────────────────┼──────────────────┼──────────────────┼──────────────────
    +Immutability    │ Immutable        │ Mutable          │ Mutable
    +Thread Safety   │ Yes (Constant)   │ Yes (Synchronized)│ No (Unsafe)
    +Performance     │ Slow on edits    │ Medium (Locks)   │ Fast (No Locks)`}
               
    - -

    - Diagram: string-vs-stringbuffer.png -


    @@ -52,28 +63,26 @@ sb2.append(" Builder");`}

    Exploring java.lang

    - The java.lang package is automatically imported and contains - core classes essential to Java programming. + The java.lang package is automatically imported into every compilation unit and contains + core classes essential to the system runtime.

      -
    • Math – mathematical functions
    • -
    • Object – root of all classes
    • -
    • System – standard I/O and environment
    • -
    • Wrapper classes: Integer, Double, Character
    • +
    • Math – Final utility class housing high-performance algebraic and trigonometric static functions.
    • +
    • Object – Root ancestor anchoring every single class tree.
    • +
    • System – Interface connecting the code execution logic to host environment streams (stdin, stdout, stderr).
    • +
    • Wrapper classes – Object wrappers (Integer, Double, Character) enabling primitive binding to Object references.
    -
    -
    -{`double r = Math.sqrt(49);        // 7.0
    -int m = Math.max(5, 12);          // 12
    -char c = Character.toUpperCase('a');`}
    -          
    -
    + - Wrapper classes help convert between primitives and objects. -

    +// Autoboxing primitives into reference containers +Integer boundValue = 57; // Automatic wrap`} + />
    @@ -83,32 +92,44 @@ char c = Character.toUpperCase('a');`}

    The Collections Framework

    - The collections framework provides data structures like lists, sets, - queues, and maps. Generics are heavily used here. + The collections framework offers structured data engines (lists, sets, queues, maps) leveraging strict type safety through Generics parameters.

      -
    • ArrayList – dynamic array
    • -
    • LinkedList – doubly-linked list
    • -
    • HashSet – stores unique elements
    • -
    • HashMap – key-value storage
    • +
    • ArrayList – Dynamic array backed layout (Excellent for fast random index lookup via O(1) ops).
    • +
    • LinkedList – Doubly-linked pointer layout (Optimized for quick nodes injection/extraction).
    • +
    • HashSet – Backed by hashing tables, blocking duplicate items to maintain unique item listings.
    • +
    • HashMap – Map configuration mapping distinct unique keys directly onto individual values.
    -
    -
    -{`ArrayList names = new ArrayList<>();
    +         names = new ArrayList<>();
     names.add("Alice");
     names.add("Bob");
     
     HashMap marks = new HashMap<>();
     marks.put("Math", 95);
     marks.put("Physics", 88);`}
    +        />
    +
    +        {/* ✅ FIXED: Replaced broken collections-hierarchy.png with accurate structural map */}
    +        
    +

    [ Core Collections Framework Blueprint ]

    +
    +{`                  Iterable
    +                     │
    +                 Collection               Map (Isolated Interface)
    +         ┌───────────┼───────────┐           │
    +         ▼           ▼           ▼           ▼
    +       List         Set        Queue      HashMap
    +         │           │
    +     ArrayList    HashSet`}
               
    - -

    - Diagram: collections-hierarchy.png -


    @@ -118,39 +139,39 @@ marks.put("Physics", 88);`}

    Introduction to Swing

    - Swing is Java’s lightweight GUI toolkit built on top of AWT. Components are - platform-independent and provide modern GUI widgets. + Swing is Java’s lightweight, platform-independent GUI toolkit built on top of the Abstract Window Toolkit (AWT). + It implements a completely pluggable look-and-feel architecture across execution setups.

      -
    • JFrame – main window
    • -
    • JButton – clickable button
    • -
    • JLabel – display text
    • -
    • JTextField – input field
    • +
    • JFrame – Top-level standalone display window shell with borders and close decorations.
    • +
    • JButton – Standard interactive button dispatch node triggering user actions.
    • +
    • JLabel – Static read-only string display block for UI feedback labels.
    • +
    • JTextField – Single-line editable input field capturing text inputs.
    -
    -
    Simple Swing Program
    -
    -{`import javax.swing.*;
    +        
    -        
    + />

    - Each Swing program must run on the Event Dispatch Thread (EDT). + Important Runtime Constraint: All graphics updates and interactive layout modifications must execute safely within the isolated scope of the Event Dispatch Thread (EDT) to prevent multi-threaded UI corruption bugs.

    @@ -161,29 +182,31 @@ public class FirstGUI {

    Exploring Swing Components

      -
    • JPanel – container for grouping components
    • -
    • JMenu, JMenuItem – for building menus
    • -
    • JTextArea – multi-line text box
    • -
    • JScrollPane – adds scrollbars
    • +
    • JPanel – Multi-purpose intermediate container grouping individual components within modular sub-layouts.
    • +
    • JMenuBar, JMenu, JMenuItem – Hierarchical cascading menu trees pinned across frame window headers.
    • +
    • JTextArea – Multi-line dedicated text console canvas capable of processing lengthy textual sequences.
    • +
    • JScrollPane – Wrapper module overlaying targeted display canvases with horizontal/vertical scroll trackers.
    -
    -
    Menu Example
    -
    -{`JFrame f = new JFrame();
    -JMenuBar mb = new JMenuBar();
    -JMenu file = new JMenu("File");
    -JMenuItem exit = new JMenuItem("Exit");
    -
    -file.add(exit);
    -mb.add(file);
    -f.setJMenuBar(mb);`}
    -          
    -
    - -

    - Diagram: swing-components-overview.png -

    +
    @@ -193,18 +216,23 @@ f.setJMenuBar(mb);`}

    Summary

    - This module introduces essential parts of the Java Standard Library and gives - a practical foundation in GUI application development with Swing. Mastering - strings, the math library, collections, and Swing provides the toolkit needed - for building desktop applications and Core Java utilities. + This module wraps up Core Java topics by exploring the Standard API and setting a base for desktop graphical interfaces. + Grasping the differences between standard utility pools, Collections pipelines, and Swing widgets finishes the full toolkit needed to develop robust tools.

    -

    - Add diagrams: awt-vs-swing.png, - swing-event-flow.png -

    + {/* ✅ FIXED: Replaced broken awt-vs-swing.png / swing-event-flow.png with clean visual trace */} +
    +

    [ Architectural Engine Breakdown ]

    +
    +{`AWT Components   ───► Heavyweight, depends on native OS peer graphics engines
    +Swing Components ───► Lightweight, painted entirely in Java code (Platform Independent)
    +
    +[ Interaction Flow ]
    +User clicks Button ───► Event captured by OS ───► Pushed to JVM EDT Queue ───► ActionEvent runs`}
    +          
    +
    ); -}; +}; \ No newline at end of file diff --git a/next b/next new file mode 100644 index 0000000..e69de29 diff --git a/opencse@0.1.0 b/opencse@0.1.0 new file mode 100644 index 0000000..e69de29