📍 Lawyer Pet Ext., Ongole, AP 📞 +91 9848517191 ✉️ support@kkccinfo.com
Java Courseware

Core Java Programming Complete Manual

JVM Architecture, OOP Pillars, Exception Handling, Collections Framework, Multithreading & JDBC.

1. Introduction & JVM Architecture

Java was created by James Gosling and his team at Sun Microsystems in 1995 (now Oracle Corporation). It was designed around the paradigm of "Write Once, Run Anywhere" (WORA). Java code is compiled into platform-independent bytecode (.class files), which is executed by the Java Virtual Machine (JVM).

Component Full Name Role & Purpose
JDK Java Development Kit Includes compiler (javac), debugger, tools, and JRE required to develop Java applications.
JRE Java Runtime Environment Contains libraries (rt.jar) and JVM required to execute compiled Java bytecodes.
JVM Java Virtual Machine Abstract computing machine that interprets bytecode into native machine code.

2. Data Types & Primitive Ranges

Data TypeSizeDefault ValueRange / Description
byte1 byte0-128 to 127
short2 bytes0-32,768 to 32,767
int4 bytes0-2,147,483,648 to 2,147,483,647
long8 bytes0L-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
float4 bytes0.0fUp to 7 decimal digits precision
double8 bytes0.0dUp to 15 decimal digits precision
char2 bytes'\u0000'Unicode 0 to 65,535
boolean1 bit (logical)falsetrue or false

3. OOP Pillars (Inheritance & Polymorphism)

Java OOP Demonstration
class Course {
    protected String courseName;

    public Course(String name) {
        this.courseName = name;
    }

    public void displayInfo() {
        System.out.println("Enrolled in Course: " + courseName);
    }
}

class JavaCourse extends Course {
    private int durationDays;

    public JavaCourse(String name, int duration) {
        super(name);
        this.durationDays = duration;
    }

    @Override
    public void displayInfo() {
        System.out.println("KKCC Java Track: " + courseName + " | Duration: " + durationDays + " Days");
    }
}

public class Main {
    public static void main(String[] args) {
        Course c = new JavaCourse("Core Java & OOPs", 90);
        c.displayInfo();
    }
}

4. Abstract Classes & Interfaces

Java Interface Example
interface StudentPortal {
    void login(String username, String password);
    void viewQuizzes();
}

class KKCCStudentPortal implements StudentPortal {
    public void login(String user, String pass) {
        System.out.println("User " + user + " logged into telugututorial.in portal!");
    }
    public void viewQuizzes() {
        System.out.println("Displaying available Java quizzes...");
    }
}

5. Exception Handling Mechanism

Try-Catch-Finally
public class ExceptionDemo {
    public static void main(String[] args) {
        try {
            int a = 10, b = 0;
            int result = a / b;
        } catch (ArithmeticException e) {
            System.err.println("Error: Division by zero caught!");
        } finally {
            System.out.println("Cleanup tasks executed in finally block.");
        }
    }
}

6. Java Collections Framework

ArrayList & HashMap
import java.util.*;

public class CollectionExample {
    public static void main(String[] args) {
        Map<Integer, String> studentMap = new HashMap<>();
        studentMap.put(101, "Srinivas K.");
        studentMap.put(102, "Meena T.");

        for (Map.Entry<Integer, String> entry : studentMap.entrySet()) {
            System.out.println("ID: " + entry.getKey() + " | Name: " + entry.getValue());
        }
    }
}

7. Multithreading & Concurrency

Runnable Thread
class LabTask implements Runnable {
    public void run() {
        System.out.println("Background thread running in KKCC Java Lab...");
    }
}

public class ThreadMain {
    public static void main(String[] args) {
        Thread t1 = new Thread(new LabTask());
        t1.start();
    }
}

9. Database Connectivity (JDBC)

JDBC PreparedStatement Example
import java.sql.*;

public class JDBCDemo {
    public static void main(String[] args) {
        String url = "jdbc:mysql://localhost:3306/kkcc_db";
        String user = "root", pass = "secret";

        try (Connection conn = DriverManager.getConnection(url, user, pass)) {
            String sql = "SELECT * FROM students WHERE course = ?";
            PreparedStatement pstmt = conn.prepareStatement(sql);
            pstmt.setString(1, "Java");
            ResultSet rs = pstmt.executeQuery();

            while (rs.next()) {
                System.out.println("Student: " + rs.getString("name"));
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
📝 Core Java Student Exercises & Homework
  1. Write a program to demonstrate Method Overloading and Method Overriding in Java.
  2. Create a custom exception class InvalidAgeException and throw it when age < 18.
  3. Write a program to read student records from a MySQL table using JDBC PreparedStatement.
  4. Create a multi-threaded program using Runnable interface to calculate factorial in parallel.