JVM Architecture, OOP Pillars, Exception Handling, Collections Framework, Multithreading & JDBC.
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. |
| Data Type | Size | Default Value | Range / Description |
|---|---|---|---|
byte | 1 byte | 0 | -128 to 127 |
short | 2 bytes | 0 | -32,768 to 32,767 |
int | 4 bytes | 0 | -2,147,483,648 to 2,147,483,647 |
long | 8 bytes | 0L | -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 |
float | 4 bytes | 0.0f | Up to 7 decimal digits precision |
double | 8 bytes | 0.0d | Up to 15 decimal digits precision |
char | 2 bytes | '\u0000' | Unicode 0 to 65,535 |
boolean | 1 bit (logical) | false | true or false |
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();
}
}
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...");
}
}
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.");
}
}
}
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());
}
}
}
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();
}
}
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();
}
}
}
InvalidAgeException and throw it when age < 18.Runnable interface to calculate factorial in parallel.