Java Complete Guide ☕

OOP + Logic + Interview Ready

1. What is Java?

Java is an object-oriented programming language used in backend systems, Android apps, and enterprise applications.

2. Basic Program

public class Main {
    public static void main(String[] args) {
        System.out.println("Hello Java");
    }
}

3. Variables

int age = 18;
String name = "Sasank";
double salary = 50000;

4. Conditions

if(age >= 18){
    System.out.println("Adult");
}else{
    System.out.println("Minor");
}

5. Loops

for(int i = 0; i < 5; i++){
    System.out.println(i);
}

6. OOP Concept

class Car {
    String model;

    void drive(){
        System.out.println("Car is driving");
    }
}

7. Inheritance

class A {
    void show(){
        System.out.println("Parent class");
    }
}

class B extends A {
}

8. Polymorphism

class A {
    void show(){
        System.out.println("A class");
    }
}

9. Arrays

int[] arr = {10, 20, 30};

for(int x : arr){
    System.out.println(x);
}

10. Exception Handling

try {
    int x = 10 / 0;
} catch(Exception e){
    System.out.println("Error handled");
}

11. Interview Questions