Basics of Web Programming · Web Technology

Overview of Java

Watch lectures

Overview of Java

1. What is Java?

Java is a general-purpose, concurrent, class-based, object-oriented language designed to have as few implementation dependencies as possible. Key slogan: WORA — Write Once, Run Anywhere.

2. Java Compilation and Execution Model

 Source code      Compiler           Bytecode          JVM
 Hello.java  --->  javac  --->  Hello.class  --->  java (interpreter + JIT)
                                  (platform            |          |
                                   independent)        v          v
                                                 Windows JVM  Linux JVM
  • Compiler (javac) produces portable bytecode (.class files).
  • JVM interprets/JIT-compiles the bytecode on each platform → platform independence.
  • Java is both compiled and interpreted.

3. Java Platform Editions

Edition Use
Java SE Core platform — desktop, console, applets
Java EE / Jakarta EE Enterprise — servlets, JSP, EJB, JMS, web services
Java ME Embedded/mobile devices

4. Core Language Features

  • Simple — C++-like syntax but no pointers, no operator overloading, no multiple inheritance of classes, automatic garbage collection.
  • Object-oriented — everything meaningful is inside a class; supports encapsulation, inheritance, polymorphism, abstraction.
  • Platform independent — bytecode + JVM.
  • Secure — no pointer arithmetic; bytecode verifier, class loader and security manager sandbox applets/untrusted code.
  • Robust — strong type checking, exception handling, automatic memory management.
  • Multithreaded — built-in Thread class / Runnable interface; synchronization primitives.
  • Distributed — RMI, CORBA, sockets, HTTP client built into the library.
  • Dynamic — classes loaded at run time as needed; reflection API.
  • Portable & architecture neutral — fixed-size primitive types (int is always 32-bit) and IEEE 754 floats.

5. Basic Syntax Elements

public class Hello {                       // class declaration
    public static void main(String[] a) {  // entry point
        int n = 10;                        // primitive types: byte short int long
        double pi = 3.14;                  //   float double char boolean
        String s = "Java";                 // String is an object, immutable
        for (int i = 1; i <= n; i++) System.out.println(i);
        if (n > 5) System.out.println("big");
        try { int x = n / 0; }
        catch (ArithmeticException e) { System.out.println("caught: " + e); }
    }
}
  • Access modifiers: public, private, protected, (default).
  • Inheritance: extends (single class inheritance); implements for many interfaces.
  • Packages organise classes (import java.util.*;).

6. OOP in Java (quick tour)

Concept Java mechanism
Encapsulation private fields + public getters/setters
Inheritance class B extends A — reuse and override
Polymorphism method overloading (compile-time) & overriding (run-time, dynamic dispatch)
Abstraction abstract class, interface (100% abstraction, multiple inheritance of type)
Constructors same name as class, no return type, overloading allowed

7. JVM, JRE and JDK

 JDK  = javac + JRE + tools (javadoc, jdb, jar)
 JRE  = JVM + core libraries
 JVM  = class loader, bytecode verifier, interpreter, JIT, GC

Memory areas: heap (objects), stack (frames/locals), method area, PC register. Garbage collector reclaims unreachable objects automatically.

8. Relevance to Web Programming

  • Applets (Module III) are Java programs that run inside a browser.
  • Servlets/JSP/EJB (server side) are pure Java classes running in a container.
  • RMI/CORBA/DCOM interop use Java's distributed object libraries.

9. Exam Points

  • Explain the features of Java (any 8) — 5-7 marks.
  • Explain the JVM / bytecode / WORA architecture with diagram — 5-10 marks.
  • Differentiate JDK, JRE, JVM — 3-5 marks.
  • Write a small Java program demonstrating OOP concepts — 5-10 marks.
  • Why is Java both compiled and interpreted? — 3 marks.
Free AppAndroid App

Coursify Android App

Generate AI courses, take quick quizzes between classes, and master complex engineering concepts on the go.

← All Web Technology modules