LECTURE NOTE: INTRODUCTION TO JAVA PROGRAMMING LANGUAGE
---
1.0 Introduction
Java is one of the most popular programming languages used in the world today. It is a high-level,
object-oriented, and platform-independent programming language that is used for developing various
types of applications such as mobile apps, desktop software, web applications, and even large enterprise
systems. Java was first developed by James Gosling and his team at Sun Microsystems in 1995, and it is
now owned and maintained by Oracle Corporation.
The main goal of Java’s creation was to design a language that can run on any computer or device
without modification. This gave rise to the famous slogan, “Write Once, Run Anywhere (WORA).”
Because of this feature, Java has become one of the most widely used languages in the technology
world — from Android phones to banking systems, servers, and even embedded systems.
---
2.0 Features and Characteristics of Java
Java has several unique features that make it very powerful and flexible. Below are the main
characteristics:
1. Simple – Java is easier to learn than languages like C++ because it removes complex features such as
pointers, operator overloading, and multiple inheritance.
2. Object-Oriented – Java uses the concept of objects and classes to model real-world problems.
Everything in Java is treated as an object.
3. Platform Independent – Java code can run on any device or operating system that has the Java Virtual
Machine (JVM) installed.
4. Secure – Java runs programs in a controlled environment and prevents direct access to system
memory, reducing the risk of viruses.
5. Robust – Java provides strong memory management and exception handling, which helps prevent
program crashes.
6. Multithreaded – Java allows you to perform several tasks simultaneously within a single program.
7. Portable – Java programs are compiled into bytecode, which can be executed anywhere without
recompilation.
8. Distributed – Java supports networking and remote communication, which allows developers to
create distributed applications that run across multiple computers.
---
3.0 The Java Platform
The Java platform is a collection of programs and libraries that allow you to write and run Java
applications. There are three major platforms in Java:
1. Java SE (Standard Edition) – This is the basic platform for developing general-purpose desktop and
console applications.
2. Java EE (Enterprise Edition) – This edition is used for developing large-scale enterprise or web-based
applications.
3. Java ME (Micro Edition) – This edition is designed for mobile devices and embedded systems.
Together, these platforms make Java a complete programming environment that can handle almost
every type of software development.
---
4.0 Java Architecture
To understand how Java works, you must know how a Java program is processed from writing to
execution. The process follows these steps:
1. Writing the Source Code: You write the program in a text file with a .java extension.
2. Compilation: The Java compiler (javac) converts the source code into bytecode, which is stored in
a .class file.
3. Execution: The Java Virtual Machine (JVM) interprets the bytecode and runs it on the system.
This process makes Java platform-independent because the same bytecode can run on any system that
has a JVM installed, regardless of the operating system.
---
5.0 Components of Java Environment
The Java environment includes three main components:
Java Development Kit (JDK): This is the complete package used by developers. It includes the compiler,
debugger, and tools to develop applications.
Java Runtime Environment (JRE): This is used to run Java programs. It contains the JVM and core
libraries.
Java Virtual Machine (JVM): This executes the Java bytecode and provides a layer between the program
and the operating system.
---
6.0 Structure of a Simple Java Program
Every Java program must have at least one class and one main method.
Example 1: Basic Program
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
Explanation:
public class HelloWorld — Defines a class named HelloWorld.
public static void main(String[] args) — The entry point of every Java program.
System.out.println("Hello, World!"); — Prints the message Hello, World! on the screen.
---
7.0 Java Syntax and Coding Rules
Before writing complex Java programs, you must understand its basic syntax and rules:
1. Every statement ends with a semicolon (;).
Example: int x = 10;
2. Java is case-sensitive — Hello is not the same as hello.
3. The file name must match the public class name.
Example: Class HelloWorld → File HelloWorld.java.
4. Code blocks are written inside curly braces { }.
5. Comments are used to describe code:
Single-line: // This is a comment
Multi-line: /* This is a multi-line comment */
---
8.0 Java Data Types
Java is a strongly typed language, which means every variable must have a data type.
Category Data Type Example
Integer byte, short, int, long int age = 20;
Floating Point float, double double salary = 25000.75;
Character char char grade = 'A';
Boolean boolean boolean isStudent = true;
String (Non-primitive) String String name = "John";
---
9.0 Java Operators
Operators are special symbols used to perform operations on variables and values.
Examples include:
Arithmetic Operators: +, -, *, /, %
Comparison Operators: ==, !=, >, <, >=, <=
Logical Operators: &&, ||, !
Example:
int a = 10;
int b = 5;
System.out.println(a + b); // Output: 15
System.out.println(a > b); // Output: true
---
10.0 Object-Oriented Concepts in Java
Java is based on Object-Oriented Programming (OOP), which helps organize code using real-world
models.
The four major OOP principles are:
1. Encapsulation – Wrapping data and code into one unit (a class).
2. Inheritance – Allowing one class to use features of another class.
3. Polymorphism – Allowing a method to behave differently based on the object calling it.
4. Abstraction – Hiding complex details and showing only necessary parts.
These principles make Java code modular, reusable, and easier to maintain.
---
11.0 Advantages of Learning Java
It is easy to learn for beginners.
It runs on almost all devices (cross-platform).
Java developers are in high demand globally.
It is used in Android app development, web applications, IoT, and cloud computing.
It provides strong security and reliability.
---
12.0 Class Activity
1. Write and run a Java program that prints your full name and department.
2. Declare two integer variables and display their sum using System.out.println().
3. Research and list five real-life applications developed using Java.
---
13.0 Summary
In summary, Java is a simple, secure, and platform-independent language that supports object-oriented
programming. It remains one of the best languages for students to start with because it introduces core
concepts like data types, syntax, control structures, and OOP principles that are useful in other
languages too. With Java, you can develop anything — from small programs to complex enterprise
applications.