1. Java Basics, Architecture & Environment Setup

Chapters 1-5: History of Java, JDK vs JRE vs JVM, WORA, Variables, Scanner input, Data Types, Casting & Operators

Module 1: Introduction to Java, History & JVM Architecture

Java is a high-level, class-based, object-oriented programming language created at Sun Microsystems in 1995.

🇬🇧 English Definition

Java is a statically typed, class-based, object-oriented programming language designed for portability, compiling source code (.java) into platform-neutral bytecode (.class) executed by a Java Virtual Machine (JVM).

🇮🇳 Hinglish Definition

Java ek statically typed programming language hai jisme classes, objects aur JVM ecosystem ka use hota hai. JDK = develop, JRE = run, JVM = execute bytecode.

Core Concepts & Rules

  • WORA (Write Once, Run Anywhere): Bytecode compiles once and runs on any OS with a compatible JVM.
  • JDK: Java Development Kit containing compiler (javac) and development tools.
  • JRE: Java Runtime Environment containing class libraries and JVM for execution.

🔍 Line-by-Line Code Breakdown

  1. Line 1: public class HelloWorld defines class name matching filename HelloWorld.java.
  2. Line 2: public static void main(String[] args) is the standard entry point method executed by JVM.
  3. Line 3: System.out.println('Hello, Java!') prints output string to terminal console.

🎯 Interview Focus & Questions

  • Q: What is WORA?
    A: Write Once, Run Anywhere: Java compiles to platform-neutral bytecode executed by JVM.
  • Q: JDK vs JRE vs JVM?
    A: JDK provides tools to develop; JRE provides runtime libraries; JVM executes bytecode.
💻 Practical Java Code Example - Introduction to Java, History & JVM Architecture
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, Java!");
    }
}
📤 Compiled Execution Output:
Hello, Java!

Module 2: Variables, Scanner Input & Primitive Data Types

Managing data memory storage, primitive types, wrapper classes, and console Scanner input.

🇬🇧 English Definition

Java has eight primitive types: byte, short, int, long, float, double, char, boolean. Wrapper classes (Integer, Double) represent primitives as objects enabling autoboxing and unboxing.

🇮🇳 Hinglish Definition

Java me 8 primitive types hote hain. Scanner class user input lene ke liye beginner-friendly hai. Autoboxing/unboxing primitives ko wrapper objects me convert karti hai.

Core Concepts & Rules

  • Widening Casting (Automatic): Converts smaller type to broader type (e.g., int to double).
  • Narrowing Casting (Manual): Converts larger type to smaller type with explicit cast (int b = (int) doubleVal;).
  • Scanner Input: java.util.Scanner reads formatted input tokens from System.in.

🔍 Line-by-Line Code Breakdown

  1. Line 1: import java.util.Scanner imports Scanner class for user input.
  2. Line 4: Scanner sc = new Scanner(System.in) initializes console input reader.
  3. Line 5: int age = sc.nextInt() reads integer value typed by user.

🎯 Interview Focus & Questions

  • Q: 8 Primitive types in Java?
    A: byte (1b), short (2b), int (4b), long (8b), float (4b), double (8b), char (2b), boolean.
  • Q: Autoboxing vs Unboxing?
    A: Autoboxing converts primitive int to Integer object; Unboxing converts Integer object to primitive int.
💻 Practical Java Code Example - Variables, Scanner Input & Primitive Data Types
import java.util.Scanner;

public class InputDemo {
    public static void main(String[] args) {
        int age = 22;
        double salary = 35000.50;
        boolean active = true;
        System.out.println("Age: " + age + " | Salary: " + salary);
    }
}
📤 Compiled Execution Output:
Age: 22 | Salary: 35000.5