Level 1: Introduction to Java

What is it? Java is a robust, high-level, class-based programming language.

Features:

Where Java is used: Android apps, enterprise software, large-scale web applications, and embedded systems.

Try This 🔥

Think about an Android app you use daily. It was likely built using Java!

✅ You learned this concept!

Level 2: Basic Program Structure

What is it? Every Java program must be enclosed in a class and contain a main method to execute.


public class Main
{

    public static void main(String[] args)
    {

        System.out.println("Hello World");

    }

}

Explanation:

Try This 🔥

Change "Hello World" to your own name and observe the output.

Try in Compiler ▶

✅ You wrote your first Java program!

Level 3: Variables & Data Types

What is it? Variables are containers for storing data. In Java, you MUST specify the data type.


int age = 18;

double marks = 85.5;

char grade = 'A';

String name = "Rajan";

Explanation: int holds whole numbers, double holds decimals, char holds a single character in single quotes, and String holds text in double quotes.

Try This 🔥

Create a String variable for your favorite subject and an int for your expected score.

Try in Compiler ▶

✅ You learned this concept!

Level 4: Operators

What is it? Symbols used to perform mathematical or logical operations.


int x = 10;

int y = 5;

int result = x + y;

Explanation: Java supports standard operators like + (add), - (subtract), * (multiply), and / (divide).

Try This 🔥

Change the operator to * and print the result using System.out.println(result);.

Try in Compiler ▶

✅ You learned this concept!

Level 5: Conditionals

What is it? Blocks of code that only run if a specific condition is evaluated as true.


if (x > 0)
{

    System.out.println("Positive");

}

Explanation: We use the if keyword to test a condition inside parentheses (). If true, the code inside the curly braces {} runs.

Try This 🔥

Add an else block to handle the scenario where x is less than 0.

Try in Compiler ▶

✅ You learned this concept!

Level 6: Loops

What is it? Structures that repeat a specific block of code as long as a condition is met.


for (int i = 0; i < 5; i++)
{

    System.out.println(i);

}

Explanation: A for loop initializes a variable (i = 0), sets a condition to check before each loop (i < 5), and increments the variable after each cycle (i++).

Try This 🔥

Modify the loop condition to i < 10 to print numbers from 0 to 9.

Try in Compiler ▶

✅ You learned this concept!

Level 7: Methods

What is it? Reusable blocks of code that perform a specific task when called.


int add(int a, int b)
{

    return a + b;

}

Explanation: A method has a return type (like int) and parameters. Method Overloading is when you create multiple methods with the exact same name but different parameters (e.g., add(int a, int b, int c)).

Try This 🔥

Create a method named multiply that takes two integers and returns their product.

Try in Compiler ▶

✅ You learned this concept!

Level 8: Arrays & Strings

What is it? Arrays store multiple values of the same type. Strings handle text sequences.


int[] arr = {1, 2, 3};

for (int i = 0; i < arr.length; i++)
{

    System.out.println(arr[i]);

}

Explanation: arr.length automatically gives the size of the array. The loop goes through each index systematically to print the values.

Try This 🔥

Create a String array containing three fruit names, and loop through to print them.

Try in Compiler ▶

✅ You learned this concept!

Level 9: Object-Oriented Programming (OOP)

What is OOP? OOP is a programming approach using objects and classes to model real-world concepts.


class Car
{

    String brand;

    void show()
    {

        System.out.println(brand);

    }

}

Try This 🔥

Add an int year variable to the Car class and print it inside the show() method.

Try in Compiler ▶

✅ You learned this concept!

Level 10: Classes & Objects

What is it? A Class is a blueprint. An Object is a real, usable instance of that blueprint.


Car c = new Car();

c.brand = "BMW";

c.show();

Explanation: We use the new keyword to create an object of the Car class. We then access its variables and methods using the dot (.) operator.

Try This 🔥

Create a second Car object named c2, set its brand to "Audi", and call its show() method.

Try in Compiler ▶

✅ You learned this concept!

Level 11: Constructors

What is it? A special method that runs automatically when an object is created, used to set initial values.


class Car
{

    Car()
    {

        System.out.println("Created");

    }

}

Explanation: The constructor must have the exact same name as the class and does not have a return type (not even void).

Try This 🔥

Create an object of this Car class to see the "Created" message automatically print.

Try in Compiler ▶

✅ You learned this concept!

Level 12: Access Modifiers

What is it? Keywords that set the visibility and security level of classes, variables, and methods.

Try This 🔥

Try making a variable private and accessing it from another class. You will get an error!

Try in Compiler ▶

✅ You learned this concept!

Level 13: Exception Handling

What is it? Managing runtime errors so your application doesn't completely crash.


try
{

    int x = 10 / 0;

}
catch (Exception e)
{

    System.out.println("Error");

}

Explanation: The program attempts the code in the try block. Since dividing by zero is impossible, it catches the error and runs the catch block instead.

Try This 🔥

Change the division to 10 / 2. The catch block will be skipped because there is no error.

Try in Compiler ▶

✅ You learned this concept!

Level 14: Practical Programs

What is it? Combining everything you've learned into full, working Java applications.

1. Simple Calculator Logic


int a = 10;

int b = 5;

System.out.println(a + b);

System.out.println(a - b);

2. Student Class Implementation


class Student
{

    String name;

    Student(String n)
    {

        name = n;

    }

    void display()
    {

        System.out.println(name);

    }

}

Try This 🔥

Open the compiler, combine the Student class, create a main method, instantiate a Student object, and run display().

Try in Compiler ▶

✅ You learned this concept!

Ready to master Java?

Start Java Quiz ☕