home
0%
Progress
CBSE Code 802 | Unit 3: Java Programming

01. Introduction to Java & OOP Principles

WORA, Bytecode, JVM, JRE vs JDK, Classes, Encapsulation, Abstraction, Inheritance, Polymorphism.

Unit 3: Java Programming

Chapter 1: Introduction to Java and OOP Principles

1. Origin and Evolution of Java

  • Created by James Gosling at Sun Microsystems (later acquired by Oracle Corporation) in 1995.
  • Originally named Oak (aimed at embedded smart consumer appliances), then renamed to Java.
  • Key design motto: "Write Once, Run Anywhere" (WORA).

2. Key Features of Java

  1. Simple and Familiar: Syntax derived from C/C++, but removed complex, error-prone concepts like explicit pointers, memory deallocation, and multiple inheritance of classes.
  2. Platform Independent & Portable:
  3. Java programs are not compiled into machine-specific native code.
  4. They are compiled into platform-neutral Bytecode (.class file).
  5. Any machine with a Java Virtual Machine (JVM) can execute this Bytecode.
  6. Object-Oriented: Almost everything in Java is an Object modeled from a Class.
  7. Robust & Secure:
  8. Strict compile-time and runtime type checking.
  9. Automatic Garbage Collection eliminates memory leaks.
  10. Absence of pointer arithmetic prevents unauthorized memory access.
  11. Multithreaded: Built-in support for executing concurrent threads to optimize CPU usage.

3. Java Execution Architecture: JDK, JRE, and JVM

+-----------------------------------------------------------------------------+
|                                    JDK                                      |
|  (Java Development Kit: javac, jar, javadoc, debugger, development tools)   |
|                                                                             |
|  +-----------------------------------------------------------------------+  |
|  |                                JRE                                    |  |
|  |     (Java Runtime Environment: Java Class Libraries + Core Files)     |  |
|  |                                                                       |  |
|  |  +-----------------------------------------------------------------+  |  |
|  |  |                              JVM                                |  |  |
|  |  |   (Java Virtual Machine: ClassLoader, Bytecode Verifier, JIT)  |  |  |
|  |  +-----------------------------------------------------------------+  |  |
|  +-----------------------------------------------------------------------+  |
+-----------------------------------------------------------------------------+

1. JVM (Java Virtual Machine)

  • An abstract computing machine that provides the runtime execution environment for Java Bytecode.
  • The JVM is platform-dependent (different for Windows, Linux, macOS), but the Bytecode is platform-independent.

2. JRE (Java Runtime Environment)

  • Provides the libraries, JVM, and other components required to run Java applications.
  • Does not contain compilers or development tools.

3. JDK (Java Development Kit)

  • The complete software package needed to develop, compile, and run Java programs.
  • Contains JRE + Development Tools (javac compiler, jar packager, javadoc, debugger).

4. Fundamental OOP (Object-Oriented Programming) Principles

1. Class and Object

  • Class: A user-defined blueprint or template from which individual objects are created. Defines attributes (variables) and behaviors (methods).
  • Object: A concrete instance of a class occupying physical memory.
// Class definition
class Student {
    int rollNo;         // Attribute / State
    String name;

    void display() {    // Behavior / Method
        System.out.println(rollNo + ": " + name);
    }
}

// Creating an object
Student s1 = new Student();

2. Encapsulation

  • Wrapping data (variables) and code (methods) together into a single unit (Class).
  • Data hiding is achieved by making variables private and exposing public getter/setter methods.

3. Data Abstraction

  • Displaying only essential features to the user while hiding internal implementation complexities.
  • Achieved using Abstract classes and Interfaces.

4. Inheritance

  • The mechanism by which a new class (Subclass / Child) acquires properties and methods of an existing class (Superclass / Parent).
  • Achieved using the extends keyword. Enhances code reusability.

5. Polymorphism

  • The ability of a message or method to take multiple forms.
  • Compile-time Polymorphism (Static Binding): Method Overloading (multiple methods with same name but different parameter signatures).
  • Runtime Polymorphism (Dynamic Binding): Method Overriding (subclass provides specific implementation of parent method).

5. Board Exam Focus Questions

  1. Explain the significance of Java Bytecode in achieving platform independence.
  2. Differentiate between JDK and JRE with a neat block diagram.
  3. Define Encapsulation and Data Abstraction. How are they related?
  4. What does the acronym WORA stand for? Explain how Java implements it.

Entity Details

Create New Item

help

Submit Technical Query

Have a question or run into an issue? Describe it below, upload an optional screenshot, and our engineering team will answer it!

image Attach image (optional)

Submit Feedback

build Free Developer Utility Free Tool
gavel

Privacy & Legal Disclaimer

1. Client-Side Browser Processing

All utility tools on DeepEngineerHub (including Image to PDF, Text Formatters, JSON Converters, and Encryptors) execute 100% locally within your client browser using WebAssembly and JavaScript. No uploaded images, text, or documents are transmitted, collected, or stored on remote servers.

2. Limitation of Liability ("As-Is" Provision)

Tools and services are provided free of charge for convenience and educational purposes "as-is" without warranties of any kind. DeepEngineerHub shall not be held liable for any data loss, formatting inconsistencies, or indirect damages resulting from tool usage.

3. Open Source & Third-Party Software

Certain utilities utilize open-source client libraries (such as jsPDF, Mermaid.js, Pyodide) licensed under MIT, Apache, or BSD open licenses. All intellectual property remains with their respective copyright holders.