1. What is Java?
- Java is a high-level, object-oriented, and platform-independent programming language developed by James Gosling at Sun Microsystems in 1995.
- Initially called Oak, later renamed Java.
- Java programs are compiled into bytecode, which can run on any machine that has a Java Virtual Machine (JVM).
2. Features of Java
- Simple – Easy to learn and use.
- Object-Oriented – Everything is treated as an object.
- Platform-Independent – “Write Once, Run Anywhere” (WORA).
- Secure – No explicit pointers, runs inside JVM sandbox.
- Robust – Strong memory management and exception handling.
- Multithreaded – Supports multiple threads (parallel execution).
- Portable – Bytecode works across platforms.
- High Performance – Uses Just-In-Time (JIT) compiler.
- Distributed – Can be used for internet-based applications.
3. Java Editions
- JSE (Java Standard Edition): Core Java for desktop applications.
- JEE (Java Enterprise Edition): For web and enterprise applications.
- JME (Java Micro Edition): For mobile and embedded devices.
4. Java Program Structure
Example:
class Hello {
public static void main(String args[]) {
System.out.println("Hello, World!");
}
}
Explanation:
class→ defines a class.main()→ entry point of Java program.System.out.println()→ displays output.
5. Java Compilation Process
- Write code →
Hello.java - Compile →
javac Hello.java(createsHello.class) - Run →
java Hello - JVM executes bytecode.
6. Java Virtual Machine (JVM)
- Converts bytecode into machine code.
- Provides platform independence.
- Handles memory management and garbage collection.
7. Tokens in Java
Basic building blocks:
- Keywords (e.g.,
class,public,static,if,else) - Identifiers (names of variables, classes, methods)
- Literals (constants like
10,"Hello") - Operators (
+,-,*,/,%,==, etc.) - Separators (
;,{},[],()) - Comments (
//for single-line,/* */for multi-line)
8. Data Types in Java
- Primitive: byte, short, int, long, float, double, char, boolean.
- Non-Primitive: String, Arrays, Classes, Interfaces.
9. Variables and Constants
- Variable: stores data value.
int age = 18; - Constant: defined using
finalkeyword.final double PI = 3.14;
10. Operators
- Arithmetic, Relational, Logical, Assignment, Unary, Ternary, etc.
11. Input and Output in Java
import java.util.Scanner;
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
System.out.println("Number = " + num);
🧾 In Short
- Java = Simple + Object-Oriented + Platform Independent.
- Code → Bytecode → JVM → Execution.
- Java programs run safely and consistently across platforms.
