Table of contents

Core Java

Core Java in One Shot: The Ultimate Core Java Cheat Sheet

A simple and structured revision guide covering all the essential Core Java concepts in one place. From OOP principles, collections, exception handling, multithreading, and file handling to JVM basics — this cheat sheet helps you quickly revise what truly matters.

1. Java Introduction

History of Java

Java was created by James Gosling and his team at Sun Microsystems in the early 1990s. Originally named "Oak," it was designed for interactive television, but the project was ahead of its time. The team pivoted, and in 1995, Java 1.0 was officially released. Its timing coincided perfectly with the explosive growth of the World Wide Web, as Java's ability to run small programs (applets) in browsers made web pages dynamic for the first time. Sun Microsystems was later acquired by Oracle Corporation in 2010, which now maintains and develops the language.

Features of Java

Java's enduring popularity stems from its robust design principles. It was built from the ground up to be reliable, secure, and portable.

WORA (Write Once, Run Anywhere)

This is the cornerstone philosophy of Java. When you write and compile Java code, it generates bytecode (.class files). This bytecode is not specific to any one operating system. To run it on a particular machine, you need a Java Virtual Machine (JVM) built for that specific operating system (Windows, Linux, macOS). The JVM acts as an intermediary, interpreting the bytecode into native machine code. This means you can compile your code on a Windows machine and run it without changes on a Linux server, provided a JVM is installed there.

JDK, JRE, JVM

Understanding the Java ecosystem starts with these three acronyms. They are nested layers of the Java platform.

JDK, JRE, JVM
Component Full Form What it Contains Purpose
JVM Java Virtual Machine Runtime engine, Interpreter, JIT Compiler Executes the bytecode. It is the runtime environment's heart.
JRE Java Runtime Environment JVM + Java standard libraries Provides the libraries and JVM needed to run Java applications. It is for end-users.
JDK Java Development Kit JRE + Development Tools (javac, jar, javadoc) Provides everything needed to develop and run Java applications. It is for developers.

Java Program Structure

Every Java application has a defined structure. The JVM looks for a specific entry point to start execution.


// 1. Package declaration (optional, but good practice for organizing classes)
package com.example.myapp;

// 2. Import statements (optional, for using classes from other packages)
import java.util.Scanner;

// 3. Class declaration (mandatory - the filename must match this class name)
public class Main {

    // 4. Main method (the mandatory entry point for any Java application)
    public static void main(String[] args) {

        // 5. Statements (the actual code to be executed)
        System.out.println("Hello, World!");

    }
}

2. Java Fundamentals

Data Types

Java is a statically-typed language, meaning every variable must have a declared type. Data types are divided into two categories.

2. Data Types

3. Operators

4. OOP Concepts

5. Inheritance

6. Polymorphism

7. Abstraction

8. Encapsulation

9. Exception Handling

10. Collections Framework

11. Multithreading

12. File Handling

13. JVM, JRE & JDK