Object Oriented
Programming with Java
(OOPJ)
Session 1: Basics of Java
Kiran Waghmare
Introduction : Java
• Java is a high-level, object-
oriented, and platform-
independent programming
language.
• Developed by James Gosling at
Sun Microsystems and released
in 1995.
• Java follows the principle of
"Write Once, Run Anywhere"
(WORA), meaning programs can
run on any platform with a Java
Virtual Machine (JVM).
Key Features of Java
• Platform Independence
• – Code runs on any OS with a JVM.
•
Object-Oriented
• – Uses concepts like classes, objects, and inheritance.
•
Robust & Secure
• – Features like garbage collection and strong memory management.
•
Multi-threading
• – Supports concurrent execution of multiple threads.
•
Portable
• – Java applications can be moved between environments without modification.
•
High Performance
• – Uses Just-In-Time (JIT) compiler for faster execution.
JDK Software Installation Documentation
Introduction to Java & Features
• 1. Introduction to Java
• Java is a high-level, object-oriented, platform-independent programming
language.
• Developed by James Gosling at Sun Microsystems in 1995 (later acquired by
Oracle).
• Designed for portability, security, and robustness.
• Java programs are compiled into bytecode, which runs on the Java Virtual
Machine (JVM).
• Used in desktop applications, mobile apps (Android), web applications,
enterprise solutions, and cloud computing.
Features of Java
• A. Platform Independence (Write Once, Run Anywhere - WORA)
• Java code is compiled into bytecode (.class file).
• The JVM interprets bytecode, making Java platform-independent.
• Can run on Windows, Linux, Mac, etc., without modification.
• B. Object-Oriented Programming (OOP)
• Java is based on OOP principles:
• Encapsulation (Data hiding through access modifiers).
• Abstraction (Hiding implementation details).
• Inheritance (Reusing code via class hierarchy).
• Polymorphism (Method overloading & overriding).
Features of Java
• C. Simple & Familiar
• Java is easy to learn for programmers familiar with C and C++.
• No need to manage pointers or memory allocation manually.
• Provides automatic garbage collection.
• D. Secure
• No direct access to pointers, reducing memory leaks and security vulnerabilities.
• Java has a bytecode verifier that checks for illegal operations.
• Supports encryption and secure communication via APIs.
• E. Robust & Reliable
• Strong memory management with automatic garbage collection.
• Exception handling mechanism (try-catch-finally) to manage runtime errors.
• No direct memory manipulation (e.g., pointer arithmetic is not allowed).
Features of Java
• F. Multithreading Support
• Java supports multithreading, allowing multiple tasks to run concurrently.
• Threads can be created using Thread class or Runnable interface.
• Synchronization prevents data inconsistency in multi-threaded programs.
• G. High Performance
• Uses Just-In-Time (JIT) Compiler to convert bytecode into native machine
code at runtime.
• Optimization techniques like HotSpot Compiler improve performance.
• Slower than C/C++, but performance is optimized for real-world applications.
Features of Java
• H. Distributed Computing & Networking Support
• Java supports network programming via built-in APIs.
• Can develop socket programming, web applications, and RMI (Remote Method
Invocation) applications.
• Java applications can interact with databases, servers, and cloud services.
• I. Dynamic & Extensible
• Java supports dynamic memory allocation and loading of classes at runtime.
• Allows developers to extend existing applications using APIs, libraries, and
frameworks.
• Uses Reflection API to inspect and modify classes at runtime.
• J. Backward Compatibility
• Java ensures that older Java programs still work on newer versions of the language.
• New versions of Java introduce enhancements without breaking old code.
Java Editions & Their Uses
• Java SE (Standard Edition) – Core Java, desktop applications, utilities.
• Java EE (Enterprise Edition) – Web applications, enterprise solutions.
• Java ME (Micro Edition) – Embedded systems, mobile applications.
• JavaFX – GUI development.
Java Development Kit (JDK) & Java Runtime
Environment (JRE)
• JDK (Java Development Kit)
• Includes JVM, compiler (javac), and development tools.
• Required for developing Java applications.
• JRE (Java Runtime Environment)
• Includes JVM and standard libraries to run Java applications.
• No compiler, used for running Java programs (not for development).
• JVM (Java Virtual Machine)
• Converts bytecode to machine-specific code.
• Provides features like memory management, garbage collection, and
security.
The requirement for Java Hello World Example
• For executing any java program, you need to
• Install the JDK if you don't have installed it, download the JDK and install it.
• Set path of the jdk/bin directory
• Create the java program
• Compile and run the java program